;; A fixed array of strings, and of structs holding a string, as a map key. ;; Each element is hashed and compared by its own pair, so two keys built from ;; different storage with the same bytes are the same key. (defstruct Tag [name string n i32]) (defn main [] i32 (let [m (map-new [2 string] i32) a (the [2 string] ["ab" "cd"]) b (the [2 string] [(slice "xab" 1) (slice "cdx" 0 2)]) c (the [2 string] ["ab" "ce"])] (put m a 1) (put m c 3) (println (or-else (get m b) -1)) (println (or-else (get m c) -1)) (println (length m)) (put m b 2) (println (length m)) (println (or-else (get m a) -1)) (free m)) (let [t (map-new [3 Tag] i32) x (the [3 Tag] [(Tag "a" 1) (Tag "b" 2) (Tag "c" 3)]) y (the [3 Tag] [(Tag "a" 1) (Tag "b" 2) (Tag "c" 4)])] (put t x 10) (put t y 20) (println (or-else (get t (the [3 Tag] [(Tag "a" 1) (Tag "b" 2) (Tag "c" 3)])) -1)) (println (or-else (get t y) -1)) (println (length t)) (free t)) 0)