On Mon, Aug 8, 2011 at 2:29 PM, MarisO wrote:
> Do you know of any trick to reverse a sequence without reverse or
> rseq ?
>
> I wrote it like this:
>
> ((fn rev
> ([s] (rev '() s))
> ([r s] (if (seq s) (rev (cons (first s) r) (rest s)) r )) )
> '[1 2
(into () [1 2 3 5])
On Aug 8, 11:29 am, MarisO wrote:
> Do you know of any trick to reverse a sequence without reverse or
> rseq ?
>
> I wrote it like this:
>
> ((fn rev
> ([s] (rev '() s))
> ([r s] (if (seq s) (rev (cons (first s) r) (rest s)) r ))
user> (source reverse)
(defn reverse
"Returns a seq of the items in coll in reverse order. Not lazy."
{:added "1.0"}
[coll]
(reduce conj () coll))
On Mon, Aug 8, 2011 at 2:29 PM, MarisO wrote:
> Do you know of any trick to reverse a sequence without rever
Do you know of any trick to reverse a sequence without reverse or
rseq ?
I wrote it like this:
((fn rev
([s] (rev '() s))
([r s] (if (seq s) (rev (cons (first s) r) (rest s)) r )) )
'[1 2 3 5] )
https://gist.github.com/1132357
I wonder if it can be written more shortly