Skip to content

Instantly share code, notes, and snippets.

@camilstaps camilstaps/fst.icl
Last active Mar 4, 2019

Embed
What would you like to do?
Arity-agnostic fst function in Clean
module fst
fst :: a -> b // (a,b)->a, (a,b,c)->a, (a,b,c,d)->a, etc.
fst _ = code {
get_node_arity 0
push_b 0
push_b 0
repl_args_b
decI
.o 2 1 i
:loop
updatepop_a 0 1
decI
eqI_b 0 0
jmp_false loop
pop_b 1
}
Start = [fst (1,2), fst (1,2,3), fst (1,2,3,4)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.