all repos — min @ ea21d459d9661f4ffb66011a353832341392ee97

A small but practical concatenative programming language.

Added shorten symbol.
h3rald h3rald@h3rald.com
Fri, 14 Apr 2017 14:12:48 +0200
commit

ea21d459d9661f4ffb66011a353832341392ee97

parent

ba00b4695bc5de4266512dd616ca2033a98a8422

4 files changed, 14 insertions(+), 1 deletions(-)

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

@@ -1,6 +1,7 @@

import critbits, tables, + sequtils, algorithm import ../core/parser,

@@ -143,6 +144,13 @@ var qList = list.qVal

sort[MinValue](qList, minCmp) i.push qList.newVal(i.scope) + .symbol("shorten") do (i: In): + var n, q: MinValue + i.reqIntAndQuotation n, q + if n.intVal > q.qVal.len: + raiseInvalid("Quotation is too short") + i.push q.qVal[0..n.intVal.int-1].newVal(i.scope) + # Operations on dictionaries .symbol("dhas?") do (i: In):
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 cleave 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 if import in? indent info int int? interpolate interval io join k keep 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 nip not notice now num number? odd? os over password pick 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 spread stack startup stored-symbols str string string? strip succ sum 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 when which while with xor zip +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 cleave 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 if import in? indent info int int? interpolate interval io join k keep 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 nip not notice now num number? odd? os over password pick 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 shorten sigils sip size sleep sort source split spread stack startup stored-symbols str string string? strip succ sum 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 when which while with xor zip syntax match minDefaultSigil ;\<[:@'~!$%&$=<>#^*#+/]; contained
M site/contents/_includes/_reference-seq.mdsite/contents/_includes/_reference-seq.md

@@ -70,6 +70,9 @@

{#op||reverse||(1)||(\*)|| Returns a new quotation {{q}} containing all elements of {{1}} in reverse order. #} +{#op||shorten|(\*) I||(\*)|| +Returns a quotation containing the first {{i}} values of the input quotation. #} + {#op||size||(\*)||I|| Returns the length of {{q}}.#}
M tests/seq.mintests/seq.min

@@ -39,5 +39,7 @@ ((3 4 7 2 4 6 5 6) '> sort (2 3 4 4 5 6 6 7) ==) assert

((3 4 7 2 4 6 5 6) '< sort (7 6 6 5 4 4 3 2) ==) assert + ((1 2 3 4 5) 3 shorten (1 2 3) ==) assert + report newstack