diff options
| author | mryouse | 2022-06-16 23:00:08 +0000 |
|---|---|---|
| committer | mryouse | 2022-06-16 23:00:08 +0000 |
| commit | 784eb9dfe7b7a017d0c33f80fe327f32dd6d3bf1 (patch) | |
| tree | 09b7e2dc0fb5cc19d3967d91ce01d3a1cf012bef /libs/dict.neb | |
| parent | 49cdaca7fc0df62e6582806b4a44169deb1bdc80 (diff) | |
add :list type to dicts, for now
Diffstat (limited to 'libs/dict.neb')
| -rw-r--r-- | libs/dict.neb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/libs/dict.neb b/libs/dict.neb index 7b474f4..dd7d5ba 100644 --- a/libs/dict.neb +++ b/libs/dict.neb @@ -5,20 +5,20 @@ (empty? (filter (lambda (x) (not (eq? x 2))) (map list-length in)))) -(func has? (in key) +(func has? (in :list key) (not (empty? (filter (lambda (x) (eq? (first x) key)) in)))) -(func get (d key) +(func get (d :list key) (first (rest (first (filter (lambda (x) (eq? (first x) key)) d))))) -(func set (d key val) +(func set (d :list key val) (if (has? d key) (map (lambda (x) (if (eq? key (first x)) (list (first x) val) x)) d) (append d (list key val)))) -(func keys (d) (map first d)) +(func keys (d :list) (map first d)) -(func drop (d key) +(func drop (d :list key) (filter (lambda (x) (not (eq? (first x) key))) d)) |
