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
// Try to make mutations explicit | |
function transition(obj, prop, current, next cb) { | |
obj[prop] = current; | |
return cb(function () { | |
obj[prop] = next; | |
}); | |
} |
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
let doSomething a b = | |
let plusOne = a + 1 | |
let result = plusOne*b | |
result | |
let doSomething2 a b = | |
(fun plusOne -> | |
(fun result -> | |
result |
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
let memo = ref Map.empty | |
let rec memoizedFibs n = | |
if Map.containsKey n !memo | |
then Map.find n !memo | |
else | |
let result = | |
match n with | |
| 1L -> 1L |
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
let valueOr someDefault perhaps = | |
match perhaps with | |
| Some v -> v | |
| None -> someDefault | |
let valueOr2 someDefault = | |
fun perhaps -> | |
match perhaps with | |
| Some v -> v | |
| None -> someDefault |
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
(* | |
Examples: | |
\x.x -----> \x.x | |
x -----> error!!! | |
(\x.x \y.y) -----> \y.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
(* | |
Examples: | |
\x.x -----> \x.x | |
x -----> error!!! | |
(\x.x \y.y) -----> \y.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
(* | |
Examples: | |
\x.x -----> \x.x | |
x -----> error!!! | |
(\x.x \y.y) -----> \y.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
type Measurements<'a> = { | |
Water: 'a | |
Wood: 'a | |
Coal: 'a | |
Iron: 'a | |
Stone: 'a | |
Obsidian: 'a | |
Copper: 'a | |
Gold: 'a | |
Silver: 'a |
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
type StepDirection = | |
| Down | |
| Up | |
type SpecifcStair = int | |
type Index = int | |
let input = "-+-++---" | |
let charToStepDir = function |
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
fromStream('book-return-example') | |
.when({ | |
$init: () => ({ | |
current: 0, | |
results: [] | |
}), | |
SteppedDown: (s, e) => { | |
if (s.current === 0) { | |
s.results.push(parseInt(e.sequenceNumber)+1); | |
} |