all repos — min @ a7aa8de6535c9dc7c80948ad75ae4315dfb5d9af

A small but practical concatenative programming language.

Added "last" symbol.
h3rald h3rald@h3rald.com
Sun, 06 Aug 2017 15:39:51 +0200
commit

a7aa8de6535c9dc7c80948ad75ae4315dfb5d9af

parent

7a2b383954ec1ddb21bb6d5556982200c64a2043

4 files changed, 19 insertions(+), 0 deletions(-)

jump to
M Min_DeveloperGuide.htmMin_DeveloperGuide.htm

@@ -6241,6 +6241,13 @@ <div class="operator"><p><span class="kwd"> <span class="kwd">quot<sub>1</sub></span> <span class="kwd">a</span> <span class="kwd">int</span> <strong>&rArr;</strong> <span class="kwd">quot<sub>2</sub></span></span></p>

<p>Inserts <span class="kwd">a</span> as the value of the <em>n<sup>th</sup></em> element <span class="kwd">quot<sub>1</sub></span> (zero-based), and returns the modified copy of the quotation <span class="kwd">quot<sub>2</sub></span>.</p></div> +<p><a id="op-last"></a> +<span class="reference-title">last</span></p> + +<div class="operator"><p><span class="kwd"> <span class="kwd">quot</span> <strong>&rArr;</strong> <span class="kwd">a</span></span></p> + +<p>Returns the last element of <span class="kwd">quot</span>.</p></div> + <p><a id="op-map"></a> <span class="reference-title">map</span></p>
M lib/min_seq.nimlib/min_seq.nim

@@ -28,6 +28,13 @@ if q.qVal.len == 0:

raiseOutOfBounds("Quotation is empty") i.push q.qVal[0] + def.symbol("last") do (i: In): + let vals = i.expect("quot") + let q = vals[0] + if q.qVal.len == 0: + raiseOutOfBounds("Quotation is empty") + i.push q.qVal[q.qVal.len - 1] + def.symbol("rest") do (i: In): let vals = i.expect("quot") let q = vals[0]
M site/contents/_includes/_reference-seq.mdsite/contents/_includes/_reference-seq.md

@@ -121,6 +121,9 @@

{#op||insert||{{q1}} {{any}} {{i}}||{{q2}}|| Inserts {{any}} as the value of the _n^th_ element {{q1}} (zero-based), and returns the modified copy of the quotation {{q2}}. #} +{#op||last||{{q}}||{{any}}|| +Returns the last element of {{q}}. #} + {#op||map||{{q1}} {{q2}}||{{q3}}|| Returns a new quotation {{q3}} obtained by applying {{q2}} to each element of {{q1}}.#}
M tests/seq.mintests/seq.min

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

((1 2) (3 4) concat (1 2 3 4) ==) assert ((1 2 3) first 1 ==) assert + + ((1 2 3) last 3 ==) assert ((1 2 3) rest (2 3) ==) assert