Skip to content

Instantly share code, notes, and snippets.

@camilstaps
Last active March 4, 2019 12:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save camilstaps/51b8b82db5763662b989ee0b09493d95 to your computer and use it in GitHub Desktop.
Save camilstaps/51b8b82db5763662b989ee0b09493d95 to your computer and use it in GitHub Desktop.
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