-> eval 42
= 42
-> eval 3.14
= 3.14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generic implementation of the `contains` function. | |
// No dependencies, runs on any unix machine with a go compiler! | |
// | |
// Build instruction: | |
// | |
// $ go generate | |
// $ go run gen.go | |
// | |
package main |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func sum(x int, y int) { | |
return x + y | |
} | |
func sum_partial(x int) { | |
return func(y int) { | |
return x + y | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() { | |
switch (42) { | |
case 0: | |
puts("not 42"); | |
break; | |
case 42: | |
puts("yes 42"); | |
break; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def max(input: List[Int]): Option[Int] = { | |
def loop(result: Option[Int], list: List[Int]): Option[Int] = { | |
(result, list) match { | |
case (_, Nil) => result | |
case (None, x::xs) => loop(Some(x), xs) | |
case (Some(prev), x::xs) if x > prev => loop(Some(x), xs) | |
case (_, _::xs) => loop(result, xs) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Returns -1 if x is 2 and x otherwise. | |
(defn check-two [x] | |
(if (= x 2) | |
-1 | |
x)) | |
(assert (check-two 1) 1) | |
(assert (check-two 2) -1) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(int argc, char *argv[]) { | |
puts("Hello!"); | |
return 0; | |
} |
- no dependencies
- minimal and sufficient
- foundation for functional patterns
- shared interfaces for interoperability between libraries
- not opinionated, sufficiently generic and simple to be accepted as common sense by almost any one with good fp background.
This file contains the benchmark results for different iteration models proposed for inclusion in the OCaml's standard library.
- Machine: Intel(R) Xeon(R) CPU E3-1245 V2 @ 3.40GHz (x86_64)
- Compiler: 4.03.0 (-O3 -unbox-closures -unbox-closures-factor 20)
| name | description | simplified type |