all repos — min @ a8bb376d9fe0a1fac48be5c3e847225922e3f35e

A small but practical concatenative programming language.

Implemented new dpick symbol.
h3rald h3rald@h3rald.com
Sun, 06 Aug 2017 13:43:40 +0200
commit

a8bb376d9fe0a1fac48be5c3e847225922e3f35e

parent

7d7a3e1fd8cd94f92d8e3b412929374c1422d9b9

M Min_DeveloperGuide.htmMin_DeveloperGuide.htm

@@ -6118,6 +6118,20 @@ <div class="operator"><p><span class="kwd"> <span class="kwd">dict</span> <strong>&rArr;</strong> (<span class="kwd">string</span><span class="kwd"><sub>*</sub></span>)</span></p>

<p>Returns a quotation containing all the keys of dictionary <span class="kwd">dict</span>.</p></div> +<p><a id="op-dpick"></a> +<span class="reference-title">dpick</span></p> + +<div class="operator"><p><span class="kwd"> <span class="kwd">dict<sub>1</sub></span> <span class="kwd">quot</span> <strong>&rArr;</strong> <span class="kwd">dict<sub>2</sub></span></span></p> + +<p>Returns a new dictionary <span class="kwd">dict<sub>2</sub></span> containing the elements of <span class="kwd">dict<sub>1</sub></span> whose keys are included in <span class="kwd">quot</span>.</p> + +<div class="sidebar"><p>Example</p> + +<p>The following program returns <code>(("a" 4) ("d" 7))</code>:</p> + +<pre><code>(("q" 5) ("a" 4) ("c" 6) ("d" 7)) ("a" "d") dpick +</code></pre></div></div> + <p><a id="op-dset"></a> <span class="reference-title">dset</span></p>
M lib/min_seq.nimlib/min_seq.nim

@@ -349,6 +349,16 @@ let vals = i.expect("dict")

var d = vals[0] i.push d.qVal.sortedByIt(it.qVal[0].getString).newVal(i.scope) + def.symbol("dpick") do (i: In): + let vals = i.expect("quot", "dict") + var q = vals[0] + var d = vals[1] + var res = newSeq[MinValue](0) + for v in d.qVal: + if q.qVal.contains v.qVal[0]: + res.add v + i.push res.newVal(i.scope) + def.sigil("?") do (i: In): i.push("dhas?".newSym)
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 apply args ask atime bind bool boolean? call call! capitalize case cd chmod choose clear-stack cleave column-print concat confirm cons cp cpu crypto ctime datetime ddel debug decode define defined? delete dget dhas? dkeys dictionary? dip dir? dirname div dprint dprint! dset dsort dup dvalues encode env? error eval even? exists? exit expect fappend fatal find file? filename filter first flatten float float? foreach fperms fread from-json format-error fs fsize fstats ftype fwrite get gets get-env get-stack hardlink harvest hidden? id if import in? indent indexof info insert int integer? interpolate interval io join keep length linrec load load-symbol logic loglevel loglevel? lowercase ls ls-r map map-reduce match md5 mkdir mod module module-symbols module-sigils mtime mv newline nip not notice now num number? odd? opts os over partition password pick pop popd pred prepend print print! prompt publish puts puts! put-env q quotation? quote quote-bind quote-define random raise reduce regex reject remove remove-symbol repeat replace rest reverse rm rmdir run save-symbol scope scope? seal search seq set set-stack sha1 sha224 sha256 sha384 sha512 shorten sigils sip size sleep slice sort source split spread stack startup stored-symbols str string string? strip succ sum swap swons symbols symlink symlink? sys system take tap tap! tformat time timeinfo times timestamp titleize to-json to-timestamp try dequote uppercase unzip version warn when which while with xor zip +syntax keyword minDefaultSymbol ! != $ & ' * + # - % ^ -> . .. / : < <= == => =~ > >= @ ROOT aes all? and any? append apply args ask atime bind bool boolean? call call! capitalize case cd chmod choose clear-stack cleave column-print concat confirm cons cp cpu crypto ctime datetime ddel debug decode define defined? delete dget dhas? dkeys dictionary? dip dir? dirname div dpick dprint dprint! dset dsort dup dvalues encode env? error eval even? exists? exit expect fappend fatal find file? filename filter first flatten float float? foreach fperms fread from-json format-error fs fsize fstats ftype fwrite get gets get-env get-stack hardlink harvest hidden? id if import in? indent indexof info insert int integer? interpolate interval io join keep length linrec load load-symbol logic loglevel loglevel? lowercase ls ls-r map map-reduce match md5 mkdir mod module module-symbols module-sigils mtime mv newline nip not notice now num number? odd? opts os over partition password pick pop popd pred prepend print print! prompt publish puts puts! put-env q quotation? quote quote-bind quote-define random raise reduce regex reject remove remove-symbol repeat replace rest reverse rm rmdir run save-symbol scope scope? seal search seq set set-stack sha1 sha224 sha256 sha384 sha512 shorten sigils sip size sleep slice sort source split spread stack startup stored-symbols str string string? strip succ sum swap swons symbols symlink symlink? sys system take tap tap! tformat time timeinfo times timestamp titleize to-json to-timestamp try dequote uppercase unzip version warn when which while with xor zip syntax match minDefaultSigil ;\<[:@'~!?$%&$=<>#^*#+/]; contained
M site/contents/_includes/_reference-seq.mdsite/contents/_includes/_reference-seq.md

@@ -41,6 +41,17 @@

{#op||dkeys||{{d}}||({{s}}{{0p}})|| Returns a quotation containing all the keys of dictionary {{d}}. #} +{#op||dpick||{{d1}} {{q}}||{{d2}}|| +> Returns a new dictionary {{d2}} containing the elements of {{d1}} whose keys are included in {{q}}. +> +> > %sidebar% +> > Example +> > +> > The following program returns `(("a" 4) ("d" 7))`: +> > +> > (("q" 5) ("a" 4) ("c" 6) ("d" 7)) ("a" "d") dpick + #} + {#op||dset||{{d1}} {{any}} {{sl}}||{{d2}}|| Sets the value of the {{sl}} of {{d1}} to {{any}}, and returns the modified copy of the dictionary {{d2}}. #}
M tests/seq.mintests/seq.min

@@ -45,6 +45,8 @@ ((("a" 1)("b" 2)("c" 3)) dvalues (1 2 3) ==) assert

((("a" 4) ("c" 8) ("f" 2) ("b" 0)) dsort (("a" 4)("b" 0)("c" 8)("f" 2)) ==) assert + ((("a" 1) ("b" 2) ("c" 3) ("d" 4)) ("b" "c") dpick (("b" 2) ("c" 3)) ==) assert + ((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