[Haskell-cafe] groupBy huh?

Joachim Breitner mail at joachim-breitner.de
Fri Mar 4 05:33:09 CET 2011


Hi,

Am Freitag, den 04.03.2011, 01:18 +0100 schrieb Jacek Generowicz:
> It seems that I don't understand what groupBy does.
> 
> I expect it to group together elements as long as adjacent ones  
> satisfy the predicate, so I would expect ALL four of the following to  
> give one group of 3 and a group of 1.
> 
> Prelude> :m + Data.List
> Prelude Data.List> groupBy (<) "abcb"
> ["abcb"]
> Prelude Data.List> groupBy (<) "abca"
> ["abc","a"]
> Prelude Data.List> groupBy (<) [1,2,3,2]
> [[1,2,3,2]]
> Prelude Data.List> groupBy (<) [1,2,3,1]
> [[1,2,3],[1]]
> 
> What am I missing?

this comes up repeatedly. Also see
http://hackage.haskell.org/trac/ghc/ticket/1408

Greetings,
Joachim

-- 
Joachim "nomeata" Breitner
  mail: mail at joachim-breitner.de | ICQ# 74513189 | GPG-Key: 4743206C
  JID: nomeata at joachim-breitner.de | http://www.joachim-breitner.de/
  Debian Developer: nomeata at debian.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110304/a32b23d8/attachment.pgp>


More information about the Haskell-Cafe mailing list