Hey Glen, it appears that zipmap most directly corresponds to your initial
question.
The only complicating aspect is your desire for nils, which (concat result
(repeat nil)) addresses.
(zipmap [:fullname :lastname :firstname :middlename] (concat result
(repeat nil)))
If it weren't for the
Just golfing for fun:
(apply hash-map (interleave [:fullname :lastname :firstname :middlename]
(concat ["John Lou Doe" "Doe" "John"] (repeat nil
;=> {:firstname "John", :lastname "Doe", :middlename nil, :fullname "John
Lou Doe"}
--
You received this message because you are subscribed to
These are both very good and usable answers. Thank you both!
On Sunday, June 1, 2014 9:36:58 AM UTC-7, James Reeves wrote:
>
> What about:
>
> {:fullname (get result 0), :lastname (get result 1), :firstname (get
> result 2), :middlename (get result 3)}
>
> If the "get" function can't find a resu
What about:
{:fullname (get result 0), :lastname (get result 1), :firstname (get result
2), :middlename (get result 3)}
If the "get" function can't find a result, it returns nil.
- James
On 1 June 2014 17:09, Glen Rubin wrote:
> I am doing some text processing using clojure and attempting to
Array destructuring appears to provide what you want with respect to nils
(note the extra set of square braces within the argument list):
(defn make-map
[[fullname lastname firstname middlename]]
{:fullname fullname
:lastname lastname
:firstname firstname
:middlename middl
I am doing some text processing using clojure and attempting to extract a
person's name by regex and then assign it to a map. The result I get takes
one of several forms:
nil (if i can't find the name)
[fullname]
[fullname lastname]
[fullname lastname firstname]
[fullname lastname firstname