Re: difference between first & peek; rest & pop

2017-11-10 Thread Gary Verhaegen
Using a dynamic language doesn't mean you should not think in terms of (abstract) types; it only means that you're note relying on the compiler to check types for you. If anything, that should encourage you to be more disciplined in your thought processes (as you don't have anything else to rely on

Re: difference between first & peek; rest & pop

2017-11-10 Thread Justin Smith
first and rest are defined in terms of position, and work on anything that can be treated as an ordered collection peek and pop work in terms of "natural insertion order" and only work with things that behave like a stack - (so not lazy-seqs, strings, etc.) lists push and pop from the front, vect

Re: difference between first & peek; rest & pop

2017-11-09 Thread Ethan Brooks
Also, pop throws an exception on the empty list whereas rest returns (). On Thursday, May 30, 2013 at 12:43:14 AM UTC-4, Seven Hong wrote: > > Hi all, > > Could some one explain what's the difference between first and peek, rest > and pop? For me it looks like they behave exactly same on sequence

Re: difference between first & peek; rest & pop

2013-05-29 Thread MichaƂ Marczyk
They are equivalent when operating on lists, but not so when operating on vectors (peek = constant time last, pop = log time remove last element) or queues (peek = first, pop = remove first element returning a queue -- rest/next would return a seq). Also, they refuse to work with non-list sequence

difference between first & peek; rest & pop

2013-05-29 Thread Seven Hong
Hi all, Could some one explain what's the difference between first and peek, rest and pop? For me it looks like they behave exactly same on sequences.. Thanks! Best, Seven Hong -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this g