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
defmodule LinkedList do | |
defstruct data: 0, | |
next: nil, | |
index: 0 | |
def new(data \\ 0, index \\ 0) do | |
%__MODULE__{data: data, index: index} | |
end | |
def push( |
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
class Monad { | |
static ret(input) { | |
return { | |
bind: (lambda, ...args) => this.bind(lambda, input, ...args), | |
flatten: function*() { | |
yield* input; | |
} | |
}; | |
} |