Last active
March 4, 2019 12:10
-
-
Save camilstaps/51b8b82db5763662b989ee0b09493d95 to your computer and use it in GitHub Desktop.
Arity-agnostic fst function in Clean
This file contains 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
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