You can also use destructuring for this:
(def nested-ds ["foo", {:hi "there" :hello ["buddy"]}, "hi"])
(let [[foo {there :hi [buddy] :hello} hi] nested-ds]
(print foo there buddy hi))
James
On Jul 21, 6:31 am, Moses wrote:
> I come primarily from a perl programming background, but am tryi
The get-in that ataggart suggested is probably what you want but
destructuring can also be used here.
(def nested-ds ["foo", {:hi "there" :hello ["buddy"]}, "hi"])
(let [[foo {there :hi [buddy] :hello} hi] nested-ds]
(print foo there buddy hi))
On Jul 21, 6:31 am, Moses wrote:
> I come pri
On Mon, Jul 20, 2009 at 4:31 PM, Moses wrote:
>
> I come primarily from a perl programming background, but am trying
> to learn Clojure.
>
> I'm looking for a clojure equivalent to the following.
>
> Perl:
>
> my $nestedDS = [ "foo", { hi => there, hello => ["buddy"] }, "hi"]
>
> my $foo =
How about:
(get-in nestedDS [1 "hello" 0])
http://clojure.org/api#toc279
On Jul 20, 1:31 pm, Moses wrote:
> I come primarily from a perl programming background, but am trying
> to learn Clojure.
>
> I'm looking for a clojure equivalent to the following.
>
> Perl:
>
> my $nestedDS = [
You'll want to look at the -> macro. Read http://clojure.org/data_structures.
You can also omit nth in two cases.
(let [nestedDS ["foo", {"hi" "there", "hello", ["buddy"]}, "hi"]
foo (nestedDS 0)
there (-> nestedDS (nth 1) (get "hi"))
buddy (-> nestedDS (nth 1) (get "h