diff options
| author | Joel Martin <github@martintribe.org> | 2014-12-18 20:33:49 -0600 |
|---|---|---|
| committer | Joel Martin <github@martintribe.org> | 2015-01-09 16:16:50 -0600 |
| commit | b8ee29b22fbaa7a01f2754b4d6dd9af52e02017c (patch) | |
| tree | f4d977ed220e9a3f665cfbf4f68770a81e4c2095 /ps/core.ps | |
| parent | aaba249304b184e12e2445ab22d66df1f39a51a5 (diff) | |
| download | mal-b8ee29b22fbaa7a01f2754b4d6dd9af52e02017c.tar.gz mal-b8ee29b22fbaa7a01f2754b4d6dd9af52e02017c.zip | |
All: add keywords.
Also, fix nth and count to match cloure.
Diffstat (limited to 'ps/core.ps')
| -rw-r--r-- | ps/core.ps | 20 |
1 files changed, 16 insertions, 4 deletions
@@ -87,8 +87,8 @@ end } def _list_from_array end } def -% [listA listB] -> concat -> [listA... listB...] -/concat { % replaces matric concat +% [listA listB] -> do_concat -> [listA... listB...] +/do_concat { dup _count 0 eq { %if just concat pop 0 _list }{ dup _count 1 eq { %elseif concat of single item @@ -102,6 +102,15 @@ end } def } ifelse } ifelse } def +% [obj] -> do_count -> number +/do_count { + 0 _nth dup _nil? { + pop 0 + }{ + _count + } ifelse +} def + % [obj ...] -> first -> obj /first { 0 _nth _first @@ -220,7 +229,10 @@ end } def (nil?) { 0 _nth _nil? } (true?) { 0 _nth _true? } (false?) { 0 _nth _false? } + (symbol) { 0 _nth _symbol } (symbol?) { 0 _nth _symbol? } + (keyword) { 0 _nth _keyword } + (keyword?) { 0 _nth _keyword? } (pr-str) { /data get ( ) true _pr_str_args } (str) { /data get () false _pr_str_args } @@ -254,12 +266,12 @@ end } def (sequential?) { 0 _nth _sequential? } (cons) { cons } - (concat) { concat } + (concat) { do_concat } (nth) { dup 0 _nth exch 1 _nth _nth } (first) { first } (rest) { rest } (empty?) { 0 _nth _count 0 eq } - (count) { 0 _nth _count } + (count) { do_count } (conj) { conj } (apply) { apply } (map) { map } |
