all repos — min @ 1f4fb40ab3a36f9d5bc3cf683cabacee447aadd2

A small but practical concatenative programming language.

Implemented reverse operator.
h3rald h3rald@h3rald.com
Sun, 26 Mar 2017 12:14:50 +0200
commit

1f4fb40ab3a36f9d5bc3cf683cabacee447aadd2

parent

45964bcd6c5b5296145cfadf93c384160dc04fcf

3 files changed, 13 insertions(+), 4 deletions(-)

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

@@ -436,8 +436,15 @@ if res.boolVal == true:

var t = c.qVal[1] i.unquote(t) break + + .symbol("reverse") do (i: In): + var q: MinValue + i.reqQuotation q + var res = newSeq[MinValue](0) + for c in countdown(q.qVal.len-1, 0): + res.add q.qVal[c] + i.push res.newVal(i.scope) - .symbol("while") do (i: In): var d, b: MinValue i.reqTwoQuotations d, b
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 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 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 reverse 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 tests/lang.mintests/lang.min

@@ -4,8 +4,8 @@

newline symbols size :total-symbols sigils size :total-sigils -"Total Symbols: $1" (total-symbols) % puts! -"Total Sigils: $1" (total-sigils) % puts! +"Total Symbols: $1" (total-symbols) => % puts! +"Total Sigils: $1" (total-sigils) => % puts! newline "lang" describe

@@ -111,6 +111,8 @@

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