(defn get-in
([m ks]
(reduce get m ks))
([m ks not-found]
(if-let [res (get-in m ks)] res not-found)))
Longer but still uses reduce
On Tue, May 18, 2010 at 12:20 PM, Stefan Kamphausen
<[email protected]>wrote:
> Hi,
>
> On May 17, 9:34 pm, braver <[email protected]> wrote:
> > If get-in is to be consistent with get, it better allow to specify a
> > default value:
> >
> > (get-in nested-structure [k1 k2 ... kN] :default something)
> >
> > -- would it make sense to add that to the standard get-in?
>
> while I certainly agree from the users point of view, as an
> implementer, I'd hate to break the very nice implementation of get-
> in. One would have to change reduce first. ;-)
>
> Cheers,
> stefan
>
> --
> 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]<clojure%[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 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