[Haskell-beginners] data constructors

Michael Mossey mpm at alumni.caltech.edu
Mon Apr 20 01:24:21 EDT 2009



Michael Mossey wrote:
> 
> toVerticals :: [[NamedTimedChord]] -> [[NamedTimedChord]]
> toVerticals [] = []
> toVerticals staves = firstVertical : toVerticals remainder
>     where
>       time3 (_,time,_) = time
>       firstVertT = minimum $ map (time3 . head) staves
>       usingStaves = [ s | s <- staves, time3 (head s) == firstVertT ]
>       notUsingStaves = [ s | s <- staves, time3 (head s) /= firstVertT ]

realized I could use Data.List.partition for this

>       firstVertical = map head usingStaves
>       remainder = leftOfUsing ++ notUsingStaves
>       leftOfUsing = filter (not . null) (map tail usingStaves)
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners


More information about the Beginners mailing list