all repos — min @ 64b5b3977bf06564d7cd498257f8916376708147

A small but practical concatenative programming language.

Dictionaries are now immutable.
h3rald h3rald@h3rald.com
Sat, 05 Nov 2016 13:34:27 +0100
commit

64b5b3977bf06564d7cd498257f8916376708147

parent

8059da38dbcc91a2e2c1a992d2162309715f6889

2 files changed, 8 insertions(+), 6 deletions(-)

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

@@ -31,8 +31,9 @@ if v.qVal[0].getString == s.getString:

return true return false -proc ddel*(q: var MinValue, s: MinValue): MinValue {.discardable.} = +proc ddel*(i: In, p: MinValue, s: MinValue): MinValue {.discardable.} = # Assumes q is a dictionary + var q = newVal(p.qVal, i.scope) var found = false var c = -1 for v in q.qVal:

@@ -44,8 +45,9 @@ if found:

q.qVal.delete(c) return q -proc dset*(i: In, q: var MinValue, s: MinValue, m: MinValue): MinValue {.discardable.}= +proc dset*(i: In, p: MinValue, s: MinValue, m: MinValue): MinValue {.discardable.}= # Assumes q is a dictionary + var q = newVal(p.qVal, i.scope) var found = false var c = -1 for v in q.qVal:

@@ -646,13 +648,13 @@ var d, k: MinValue

let m = i.pop i.reqStringLike k i.reqDictionary d - i.dset(d, k, m) + i.push i.dset(d, k, m) .symbol("ddel") do (i: In): var d, k: MinValue i.reqStringLike k i.reqDictionary d - d.ddel(k) + i.push i.ddel(d, k) .symbol("dprint") do (i: In): var d: MinValue
M tests/lang.mintests/lang.min

@@ -157,9 +157,9 @@ (((a 1)(b 2)(c 3)) dictionary?) assert

(((a 1)(b 2)(c 3)) 'b dget 2 ==) assert - (((a 1)(b 2)(c 3)) ' :dict dict 'b 5 dset dict ((a 1)(b 5)(c 3)) ==) assert + (((a 1)(b 2)(c 3)) ' :dict dict 'b 5 dset ' :newdict newdict ((a 1)(b 5)(c 3)) == dict ((a 1)(b 2)(c 3)) == and) assert - (((a 1)(b 2)(c 3)) ' :dict dict 'b ddel dict ((a 1)(c 3)) ==) assert + (((a 1)(b 2)(c 3)) ' :dict dict 'b ddel ' :newdict newdict ((a 1)(c 3)) == dict ((a 1)(b 2)(c 3)) == and) assert (((a 1)(b 2)(c 3)) keys (a b c) ==) assert