Nice. But I wonder if sorting and (count coll) actually forces the
algorithm to load everything into memory. My Clojure solution is more
convoluted (will post it later) and suffers the same due to a
recursive algorithm doing the transformation I described at  the end.
However I think I have something more compact and very readable in
Scala I wrote aferwords. And this reads the input sequence as needed:

List[Int](6, 7, 8, 1, 2, 3, 4, 1, 11, 10 ,11 ,12 ,13,
3).foldLeft(List[List[Int]]()){(a,b)=>
      if(a.isEmpty) List(List(b))
      else if(a.last.last < b) a.dropRight(1):::List(a.last:+b)
      else a:::List(List(b))
      }.filter(_.length>1).foldLeft(List[Int]()){(a,b)=>if(a.length>=b.length)
a else b}

I do not mean to rant here or anything, it is more like I have problem
expressing in Clojure this transformation:

(6, 7, 8, 1, 2, 3, 4, 1, 11, 10 ,11 ,12 ,13, 3) => ((6, 7, 8), (1, 2,
3, 4), (1, 11), (10, 11, 12, 13), (3)) in a nonrecursive way as well
as that I do not have to read entire sequence into a memory ...

hmm...

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