On Thursday, March 19, 2015 at 12:32:02 AM UTC-4, Brian Craft wrote:
>
> I found an earlier thread about case-insensitive maps, which pointed to a
> contrib lib, fnmap. It doesn't appear to have survived.
>
> Is there another lib that does this, or a better way of doing
> case-insensitive data structs?
>
I've been using this little function for similar purposes. I suppose you
could use deftype to make a map-like object that delegates to an inner map
but first calls this on keys passed to assoc and get:
(defn normalize
"Given a string, normalizes it so that it may be used as a key in a
hashmap
and compare equal to all strings representing the same word/spelling.
There are edge cases that .toLowerCase or .toUpperCase would not handle,
so the actual procedure uses java.text.Normalizer as well as both of the
above."
; => (= (normalize "ß") (normalize "sS"))
; true
; => (= (normalize "é") (normalize "é"))
; true
; ; Note that the latter are two different és, if this file encoding
preserved
; ; the difference. One uses a combining diacritic and one is integral.
[^String s]
(-> s
(java.text.Normalizer/normalize (java.text.Normalizer$Form/NFKC))
(.toUpperCase)
(.toLowerCase)))
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.