Open atifaziz opened 9 years ago
scan
is basically a verbose fold
, and fold requires an initial value by its definition.
I think it should be an empty array.
scanl1 :: (a -> a -> a) -> [a] -> [a]
Empty array fits the expected type.
i rather have undefined
for failed operations because a empty array is not falsy.
it's [a]
not []
. and therefor undefined behavior.
@anko scanl1
in Haskell returns an empty list and so do many other implementations, which is what prompted me to open this issue. fold
has a different problem. It aggregates to a single result therefore it's understandable that its result is undefined if there's no seed. In the case of scan1
if there's no seed then there are no intermediate computations to report and an empty list would be a reasonable answer.
@igl If it always returns a list then your falsy test just goes against its length instead.
Is that any particular reason why
scan1
/scanl1
returnsvoid
when the input is an empty list? Why not just return an empty list instead?