(func set? (val) (and (list? val) (not (dups val)))) (func pair? :bool (val) (and (list? val) (eq? 2 (length val)))) (type :pair :{:any} pair?) (func dups (lst :[:any]) (def out (list)) (not (empty? (drop-while lst (if (in? _item_ out) #false (block (redef out (append out _item_)) #true)))))) ; dicts (func dict? (val) (and (list? val) ; TODO should this be automatic? (reduce and (map pair? val) #true) (not (dups (map first val))))) (type :dict :[:pair] dict?) (func dict :dict () (list)) (func has? :bool (in :dict key) (not (empty? (filter (lambda (x) (eq? (first x) key)) in)))) (func get (d :dict key) (last (first (drop-while d (not (eq? key (first _item_))))))) (func set :dict (d :dict 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 :dict) (map first d)) (func drop (d :dict key) (filter (lambda (x) (not (eq? (first x) key))) d))