j
k
j a
j l
so it doesn't work in all cases. The idea is nice, though: import Data.Maybe finit = catMaybes . foldr f [Nothing] . map Just where f x ys = case ys of [Nothing] -> [] _ -> x:ys will do fine.
so it doesn't work in all cases. The idea is nice, though:
import Data.Maybe
finit = catMaybes . foldr f [Nothing] . map Just where f x ys = case ys of [Nothing] -> [] _ -> x:ys
will do fine.
Ooooops, only for nonempty lists!
Back to the thread
Back to the list