Skip to content

Instantly share code, notes, and snippets.

View arialdomartini's full-sized avatar

Arialdo Martini arialdomartini

View GitHub Profile
@arialdomartini
arialdomartini / pi-wallis.lisp
Created May 13, 2018 14:54
Calculating Pi with John Wallis' formula
(define (range-rec from to)
(if (> from to)
()
(cons from
(range-rec (+ 1 from)
to))))
(define (range from to)
(define (range-iter from to result)
(if (> from to)
@arialdomartini
arialdomartini / sum_tuples.cs
Created May 11, 2018 05:36
Sum of tuples, pure functional
public class MyTupleIntTest
{
[Fact]
public void should_retain_values()
{
var tuple = MyTuple.Build(44, 100);
tuple.First().Should().Be(44);
tuple.Second().Should().Be(100);
}
@arialdomartini
arialdomartini / what-the-beam.md
Created May 10, 2018 09:44 — forked from gabrielelana/what-the-beam.md
Descrizione del corso "What the BEAM: Introduction to the Erlang/Elixir Virtual Machine"
  • Title: What the BEAM: Introduction to the Erlang/Elixir Virtual Machine

  • Abstract: Per sfruttare al massimo Erlang/Elixir non é sufficiente conoscere il linguaggio, la semantica di questi linguaggi é indissolubilmente legata al loro runtime: la virtual machine BEAM. Un corso di due giorni per esplorare la BEAM, le sue carateristiche, come sfruttarla al meglio e cosa evitare. Il corso é rivolto a tutte quelle persone che hanno messo gli occhi su Erlang/Elixir e vogliono fare un passo avanti per poter realizzare software production ready.

  • What: Il corso durerá due giorni e sará strutturato come segue

    • Primo giorno
      • Overview sulla BEAM
      • Cosa è un nodo Erlang/Elixir
      • Processi
  • Cosa sono

@arialdomartini
arialdomartini / tuple.cs
Created May 9, 2018 14:50
Tuples without fields nor variables
using System;
using FluentAssertions;
using Xunit;
namespace SamuraiTDD.WithSum
{
public class MyTupleIntTest
{
[Fact]
@arialdomartini
arialdomartini / mezzo.scm
Last active May 3, 2018 20:03
indice che divide una lista in due liste con somme uguali
(define (mezzo-index ns)
(define sum
(lambda (l)
(if (null? l)
0
(+ (car l) (sum (cdr l))))))
(define (iter sn dx)
(cond ((null? dx) (length sn))
((>= (sum sn) (sum dx)) (length sn))
@arialdomartini
arialdomartini / file.js
Last active April 20, 2018 10:56
gulp xunit cover
gulp.task('test', "Run all the tests", ["build", "tools:download:xunit-runner"], function() {
console.log(config.tools.xunit.path)
var options = {
executable: config.tools.xunit.path,
options: {
nologo: true,
xml: config.testResult
}
}
var assemblies = [`../**/bin/${config.buildConfiguration}/*.Test.dll`]
@arialdomartini
arialdomartini / Pm scala
Last active December 18, 2017 04:24
Patternmatching.scala
def flatten(ls: List[_]): List[Int] = ls match {
case Nil => Nil
case (a: Int) :: tail => a :: flatten(tail)
case (a: List[_]) :: tail => flatten(a) ::: flatten(tail)
case _ :: tail => flatten(tail)
}
// oppure adforittura
import java.io.FileOutputStream;
import java.io.PrintStream;
class Bar {
public static void Main() throws Exception {
StringChecker.CheckFirstCharacter("Foobar");
}
static class StringChecker {
public static void CheckFirstCharacter(String name) throws Exception {{
@arialdomartini
arialdomartini / guido-was-right.java
Created November 6, 2017 16:55
guido-was-right.java
public class Exercise2 {
public static void main(String[] args) {
int nums[] = new int[]{1, 2, 42, 4, 5, 6};
boolean value = SecretOfLife.lookFor(nums);
System.out.println(value);
}
@arialdomartini
arialdomartini / max_without_comparators.cs
Last active September 20, 2017 09:43
Max of 2 numbers, without comparators and conditionals
using System;
using System.Collections.Generic;
using System.Linq;
namespace MyMax2
{
public class Maximizer
{
public int Max(int a, int b)
{