Anonymous
public text v1 · immutable> 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