Hi Marek,

> > - To sort the nicks by karma in descending order, instead of sorting
> > by the negation of the karma, I used (reverse (sort-by ...)); again,
> > just a subjective thing, makes the intent more clear to me.
>
> It does, but doesn't that make it less lazy? To reverse something, it
> needs to evaluate the whole sequence. I yet have to learn how to
> deal with lazyness.

You're right, I hadn't realized 'reverse' is not lazy (I have a lot to
learn about lazyness management myself :)).  In this case, though, I
don't think it has too much impact, since:

1) The reversing is done just before we evaluate and print everything
anyway.
2) 'sort-by' is not lazy either; has to evaluate everything in order
to find the first item.

FYI, 'reduce' is also not lazy.

> Great! I was wondering whether Clojure supports something like
> tuple-unpacking in Python. Does it also support "patterned"
> destructuring like:
>
> first, *middle, last = sequence(...)
> -or-
> first, rest = sequence(...)
>
> The latter could be achived by something like `first+rest', I suppose,
> but don't know the "Clojure" name for it.

The latter is definitely supported; the name after a '&' will be bound
to the remainder of a sequence:

user=> (let [[fst & rst] [1 2 3]] (println "first:" fst "rest:" rst))
first: 1 rest: (2 3)

But I don't know of a way to bind the 'middle' elements of a sequence
to something.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to