On Thu, Dec 17, 2009 at 2:04 AM, Meikel Brandmeyer <m...@kotka.de> wrote:
> Hi,
>
> On Dec 16, 10:36 pm, Graham Fawcett <graham.fawc...@gmail.com> wrote:
>
>> Not sure it's better, but I find this more readable:
>>
>> (defn stack-apply [n f stack]
>>   (if (zero? n)
>>     stack
>>     (conj (stack-apply (dec n) f (pop stack))
>>           (f (last stack)))))
>
> Unrelated note: (last stack) turns the vector into a seq and walks it
> linearly. (peek stack) returns the last element in O(1) (or maybe O
> (log32 N)?) time.

Definitely related! Thanks, Miekel, I have not yet internalized all of
these seq operations.

Best,
Graham


>
> Sincerely
> Meikel
>
> --
> 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

-- 
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