[Haskell-cafe] Can i split a String by its element ?

Richard O'Keefe ok at cs.otago.ac.nz
Wed Feb 23 00:01:11 CET 2011

On 22/02/2011, at 7:46 PM, z_axis wrote:

> I want to split "2,15,33,0,8,1,16,18" to ([2,15,33],[8,1,16,18]).  the "0"
> will by discarded.
> However, it seems that there isnot any standard function to do it.

let (front,(_:back)) = List.span (/= 0) xs in (front,back)

What do you plan to do if there is no 0 there?

[Yes, I know this can be done in point free style.  I hereby announce
defeat in code golf.]

More information about the Haskell-Cafe mailing list