All pastes #204087 Raw Edit

Anonymous

public text v1 · immutable
#204087 ·published 2006-10-15 17:24 UTC
rendered paste body
> cut 3 "hejbolbol" 

  ["hej","bol","bol"]


-- Tar en lista, t.ex en skär den i delar.
cut :: Int -> [a] -> [[a]]
cut n [] = []
cut n cake = slice : cut n rest
  where (slice,rest) = splitAt n cake


i see what it does, but why cant i pattern match on the "" ? isnt that the same as []?

:: Int -> [a] -> [[a]]
cut n cake = ""
cut n cake = slice : cut n rest
  where (slice,rest) = splitAt n cake