Dictionaries are now immutable.
h3rald h3rald@h3rald.com
Sat, 05 Nov 2016 13:34:27 +0100
2 files changed,
8 insertions(+),
6 deletions(-)
M
lib/min_lang.nim
→
lib/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.min
→
tests/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