diff options
| author | Joel Martin <github@martintribe.org> | 2015-02-15 22:04:45 -0600 |
|---|---|---|
| committer | Joel Martin <github@martintribe.org> | 2015-02-15 22:04:45 -0600 |
| commit | f618f6a11c661a74e5805a75b51815a0cafebaaf (patch) | |
| tree | 4bb059e6346da66336783d12a69c9e162a497097 /miniMAL/core.json | |
| parent | 1981bf5766d9bb75a652cc781b817cc3150d12ef (diff) | |
| download | mal-f618f6a11c661a74e5805a75b51815a0cafebaaf.tar.gz mal-f618f6a11c661a74e5805a75b51815a0cafebaaf.zip | |
miniMAL: step8.
Diffstat (limited to 'miniMAL/core.json')
| -rw-r--r-- | miniMAL/core.json | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/miniMAL/core.json b/miniMAL/core.json index a1549db..a5c44bd 100644 --- a/miniMAL/core.json +++ b/miniMAL/core.json @@ -7,6 +7,16 @@ 0, ["count", "a"]]]], +["def", "_nth", ["fn", ["seq", "idx"], + ["if", [">=", "idx", ["count", "seq"]], + ["throw", "nth: index out of range"], + ["nth", "seq", "idx"]]]], + +["def", "_first", ["fn", ["seq"], + ["if", ["empty?", "seq"], + null, + ["first", "seq"]]]], + ["def", "core-ns", ["hash-map", ["`", "="], "equal?", @@ -38,6 +48,9 @@ ["`", "cons"], "cons", ["`", "concat"], "concat", + ["`", "nth"], "_nth", + ["`", "first"], "_first", + ["`", "rest"], ["fn", ["a"], ["rest", "a"]], ["`", "empty?"], "empty?", ["`", "count"], "_count"]], |
