Skip to content

Instantly share code, notes, and snippets.

@lepoetemaudit
lepoetemaudit / sum.c
Created July 10, 2018 09:34
C version of recursive sum (with sentinel)
#include <stdio.h>
int sum(int *numbers) {
if (numbers[0] == -1) {
return 0;
} else {
return numbers[0] + sum(numbers + 1);
}
}
@lepoetemaudit
lepoetemaudit / sum.go
Created July 8, 2018 12:40
sum in golang
package main
import "fmt"
func sum(numbers []int) int {
if len(numbers) == 0 {
return 0
} else {
return numbers[0] + sum(numbers[1:])
}
@lepoetemaudit
lepoetemaudit / install.sh
Last active June 25, 2018 10:53
Install Luml - macOS / Darwin
echo "Installing Luml - sudo required" && sudo echo "Ok, installing!" && mkdir -p /tmp/luml && curl -Ls https://github.com/luml-lang/luml/releases/download/v0.0.1/luml-0.0.1-darwin.tgz | tar -xz -C /tmp/luml && sudo cp -r /tmp/luml/release/bin/* /usr/local/bin && sudo cp -r /tmp/luml/release/lib/* /usr/local/lib && rm -r /tmp/luml && echo "Luml successfuly installed"

Keybase proof

I hereby claim:

  • I am lepoetemaudit on github.
  • I am sopost_dj (https://keybase.io/sopost_dj) on keybase.
  • I have a public key ASAXEY6a_byrLsGjd6tlSSGl7TM8J-FCT8bDt3PTjKplzAo

To claim this, I am signing this object:

@lepoetemaudit
lepoetemaudit / parser.alp
Created September 1, 2017 17:26
Quick Alpaca parser/combinator tests
module main
type result 'a 'b = Error 'a | Ok 'b
type parser 'a = fn binary -> result string ('a, binary)
let (<|) f x = f x
let (|>) x f = f x
let assertEquals a b =
module Program
let add x y = x + y
let add10 = add 10
let explicit_add_10 x = x + 10
(* the above types as:
@lepoetemaudit
lepoetemaudit / codegenstack.erl
Created July 19, 2017 13:33
Stack trace for lambdas in match statement fail
[{alpaca_codegen,gen_expr,
[{env,[{<<"fails">>,1},{<<"succeeds">>,1}],alpaca_bad,0,0},
{alpaca_fun,6,undefined,1,undefined,
[{alpaca_fun_version,0,
[{'Symbol',
#{'__struct__' => record,
line => 6,
name => <<"svar_1">>,
@lepoetemaudit
lepoetemaudit / dril.sh
Created May 25, 2017 14:49
Alias for interactively running the last build docker image
alias dril="docker run -it `docker images | head -n 2 | tail -n 1 | awk '{print $3}'`"
@lepoetemaudit
lepoetemaudit / hackney.alp
Last active March 2, 2017 17:47
Wrapping hackney in Alpaca
module hackney
export main
-- simple result ADT
type result 'a 'b = Error 'a | Ok 'b
-- define 'bind' for result
let (*>>=) a f =
match a with
@lepoetemaudit
lepoetemaudit / curry.mlfe
Last active December 1, 2016 13:03
Faked currying in mlfe
-- In MLFE
module curry_fun
export curried/1
curried arg1 =
let curried2 arg2 =
let curried3 arg3 =
arg1 + arg2 + arg3