I really enjoyed solving the exercises, thank you for creating this awesome playlist! A small correction at 8:05, `replicate 3 'b'` actually returns "bbb" as opposed to ['b','b','b']
In this video the recommendation is to start out with the simplest cases for each kind of type, which for lists means just matching on empty and non-empty lists. The patterns you've used above also match on the first logical value, so are a nested pattern. This is the kind of thing you could do in the final simplification step if you wanted. But personally in this case I'd prefer to just write "and (b:bs) = b && and bs" in the non-empty list case, as it's then clear it's an example of foldr.
this is the most elegant merge sort implementation i've ever seen. just, wow!
I really enjoyed solving the exercises, thank you for creating this awesome playlist! A small correction at 8:05, `replicate 3 'b'` actually returns "bbb" as opposed to ['b','b','b']
In Haskell a string is a list of characters, so "bbb" is just a shorthand for ['b','b','b'].
Bonus Prelude function:
splitAt :: Int -> [a] -> ([a], [a])
Wow, that's brilliant! Thank you so much for sharing.
Glad you liked it!
Wonderful lecture. Thank you very much.
Can't we write a case like:
and [] = True
and (False:bs) = False
and (True:bs) = and bs
In this video the recommendation is to start out with the simplest cases for each kind of type, which for lists means just matching on empty and non-empty lists. The patterns you've used above also match on the first logical value, so are a nested pattern. This is the kind of thing you could do in the final simplification step if you wanted. But personally in this case I'd prefer to just write "and (b:bs) = b && and bs" in the non-empty list case, as it's then clear it's an example of foldr.