all repos — min @ 45964bcd6c5b5296145cfadf93c384160dc04fcf

A small but practical concatenative programming language.

Implemented any? and all? operators.
h3rald h3rald@h3rald.com
Sun, 26 Mar 2017 12:06:27 +0200
commit

45964bcd6c5b5296145cfadf93c384160dc04fcf

parent

9878033f69ab5a0d3fbb8e1268c99f2d7c2e1c8b

4 files changed, 30 insertions(+), 2 deletions(-)

jump to
M lib/min_lang.nimlib/min_lang.nim

@@ -462,6 +462,30 @@ if check.isBool and check.boolVal == true:

res.add e i.push res.newVal(i.scope) + .symbol("any?") do (i: In): + var filter, list: MinValue + i.reqTwoQuotations filter, list + for e in list.qVal: + i.push e + i.unquote(filter) + var check = i.pop + if check.isBool and check.boolVal == true: + i.push true.newVal + return + i.push false.newVal + + .symbol("all?") do (i: In): + var filter, list: MinValue + i.reqTwoQuotations filter, list + for e in list.qVal: + i.push e + i.unquote(filter) + var check = i.pop + if check.isBool and check.boolVal == false: + i.push false.newVal + break + i.push true.newVal + .symbol("sort") do (i: In): var cmp, list: MinValue i.reqTwoQuotations cmp, list
M min.vimmin.vim

@@ -11,7 +11,7 @@

setl iskeyword=@,36-39,+,-,/,*,.,:,~,!,48-57,60-65,94-95,192-255 setl iskeyword+=^ -syntax keyword minDefaultSymbol ! != $ & ' * + # - % ^ -> . .. / : < <= == => =~ > >= @ ROOT aes and append ask at atime b bind bool bool? bury1 bury2 bury3 c call call! capitalize case cd chmod choose column-print concat confirm cons cp cpu crypto ctime datetime ddel debug decode define delete dget dictionary? dig1 dig2 dig3 dip dir? dirname div dprint dprint! dset dup dupd encode env? error eval even? exists? exit fappend fatal file? filename filter first float float? foreach fperms fread from-json format-error fs fsize fstats ftype fwrite gets getenv hardlink hidden? id ift ifte import indent info inspect int int? interpolate interval io join k keys length linrec load load-symbol logic loglevel loglevel? lowercase ls ls-r map match md5 mkdir mod module module-symbols module-sigils mtime mv newline newstack not notice now num number? odd? os password pop popd pred prepend print print! prompt publish puts puts! putenv q quotation? quote quote-bind quote-define random raise regex remove-symbol repeat replace rest rm rmdir run save-symbol scope scope? seal search sha1 sha224 sha256 sha384 sha512 sigils sip size sleep sort source split stack startup stored-symbols str string string? strip succ swap swapd swons symbols symlink symlink? sys system take tformat time timeinfo times timestamp titleize to-json try unquote unstack uppercase unzip values version warn which while with xor zip contains +syntax keyword minDefaultSymbol ! != $ & ' * + # - % ^ -> . .. / : < <= == => =~ > >= @ ROOT aes all? and any? append ask at atime b bind bool bool? bury1 bury2 bury3 c call call! capitalize case cd chmod choose column-print concat confirm cons cp cpu crypto ctime datetime ddel debug decode define delete dget dictionary? dig1 dig2 dig3 dip dir? dirname div dprint dprint! dset dup dupd encode env? error eval even? exists? exit fappend fatal file? filename filter first float float? foreach fperms fread from-json format-error fs fsize fstats ftype fwrite gets getenv hardlink hidden? id ift ifte import indent info inspect int int? interpolate interval io join k keys length linrec load load-symbol logic loglevel loglevel? lowercase ls ls-r map match md5 mkdir mod module module-symbols module-sigils mtime mv newline newstack not notice now num number? odd? os password pop popd pred prepend print print! prompt publish puts puts! putenv q quotation? quote quote-bind quote-define random raise regex remove-symbol repeat replace rest rm rmdir run save-symbol scope scope? seal search sha1 sha224 sha256 sha384 sha512 sigils sip size sleep sort source split stack startup stored-symbols str string string? strip succ swap swapd swons symbols symlink symlink? sys system take tformat time timeinfo times timestamp titleize to-json try unquote unstack uppercase unzip values version warn which while with xor zip contains syntax match minDefaultSigil ;\<[:@'~!$%&$=<>#^*#+/]; contained
M prelude.minprelude.min

@@ -11,4 +11,4 @@ 'crypto import

; Unsealed symbols () :startup -("[$1]$$ " (.) %) :prompt +("[$1]$$ " (.) => %) :prompt
M tests/lang.mintests/lang.min

@@ -108,6 +108,10 @@ c 10 ==) assert

((1 2 3 4 5) (even?) filter (2 4) ==) assert + ((1 2 3 4 5) (even?) any?) assert + + ((2 4 6 8) (even?) all?) assert + (5 (dup 0 ==) (1 +) (dup 1 -) ( * ) linrec 120 ==) assert ;factorial of 5