reasoning behind nth and take-nth inconsistent parameter pos.

2014-01-03 Thread Alex Miller
return a sequence. Sequence functions like map, reduce, filter, take, take-nth etc take the sequence as the last arg. You'll see -> thread macro is better for collection calls and ->> thread macro is better for sequence fns. Alex -- -- You received this message because you are

Re: reasoning behind nth and take-nth inconsistent parameter pos.

2014-01-03 Thread Jozef Wagner
Hi, nth takes collection and returns item of that collection. In such cases, collection comes first. nth follows the semantics of first, second, get, ... take-nth takes collection and returns other collection. In such cases, collection comes last. take-nth follows the semantics of take, map

reasoning behind nth and take-nth inconsistent parameter pos.

2014-01-03 Thread John Kida
(take-nth i coll) (nth coll i) or (nth coll i not-found) Why is one using the index as the first parameter and the other uses index as its second parameter..? Is there any good articles out there for clojure idioms that may explain some of these things? -- -- You received this message

Re: take-nth

2009-10-28 Thread John Harrop
an think of it as the index of the SECOND item to > > take, so (take-nth 3 foo) takes index 0 of foo, then index 3, and so on.) > > Yes I agree it makes perfect sense, but I don't think the doc string > really says that. They probably thought it d

Re: take-nth

2009-10-28 Thread Timothy Pratley
On Oct 28, 6:04 pm, John Harrop wrote: > It always starts with the zeroth item and skips ahead however many elements > were specified. The second argument is the n in > "every nth item". (You can think of it as the index of the SECOND item to > take, so (take-nth 3 foo) take

Re: take-nth

2009-10-28 Thread John Harrop
On Tue, Oct 27, 2009 at 9:50 PM, Josh Daghlian wrote: > The docs could use clarification, but it looks like take-nth is doing > what's advertised. > I don't see anything odd about the behavior of take-nth in regards to indexing: user=> (take 10 (take-nth 1 (range 100))

Re: take-nth

2009-10-27 Thread Josh Daghlian
The docs could use clarification, but it looks like take-nth is doing what's advertised. Is there ever a case (I can't think of one) where a programmer really wants to feed this function a non-positive n? That is, should take-nth crap out if (< n 1)? --josh On Oct 27, 5:26 pm, Ti

Re: take-nth

2009-10-27 Thread Timothy Pratley
Oh that is confusing! nth indexes from 0 where-as take-nth indexes from 1. The doc string could be considered misleading, as it says that take- nth makes a sequence of "nth" items, but clearly it does not: clojure.core/take-nth ([n coll]) Returns a lazy seq of every nth item in c

take-nth

2009-10-27 Thread alxtoth
Hi, Started tinkering with Clojure, and wonderring why (take-nth 0 (range 10)) returns an infinite sequence .. Is this really the expected behaviour? ; ;code bellow is public domain ; (defn take-nth-proposal "Returns a lazy seq of every nth item in coll . Or nil if n less than 1."

Re: nth and take-nth argument order

2008-11-08 Thread Michael Wood
On Sat, Nov 8, 2008 at 10:08 PM, Rich Hickey <[EMAIL PROTECTED]> wrote: > > On Nov 8, 2:44 pm, "Michael Wood" <[EMAIL PROTECTED]> wrote: >> Is there any particular reason for the reversal of the order of >> arguments between nth and take-nth? >

Re: nth and take-nth argument order

2008-11-08 Thread Rich Hickey
On Nov 8, 2:44 pm, "Michael Wood" <[EMAIL PROTECTED]> wrote: > Is there any particular reason for the reversal of the order of > arguments between nth and take-nth? Short answer - take-nth is more like take. Longer answer: http://groups.google.com/group/clo

nth and take-nth argument order

2008-11-08 Thread Michael Wood
Is there any particular reason for the reversal of the order of arguments between nth and take-nth? I would have expected something like: clojure/nth ([n coll]) clojure/take-nth ([index coll]) ([index coll not-found]) or else: clojure/nth ([coll n]) clojure/take-nth ([coll index]) ([coll