Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
pp:l03 [2022/03/16 22:25] bogdan.deac |
pp:l03 [2022/03/20 15:13] (current) bogdan.deac |
||
---|---|---|---|
Line 115: | Line 115: | ||
===== 3.3. Brain twisters ===== | ===== 3.3. Brain twisters ===== | ||
3.3.1. Implement ''map'' using ''foldl'' and ''foldr'' | 3.3.1. Implement ''map'' using ''foldl'' and ''foldr'' | ||
+ | |||
+ | <code haskell> | ||
+ | mapr :: (a -> b) -> [a] -> [b] | ||
+ | mapl :: (a -> b) -> [a] -> [b] | ||
+ | </code> | ||
3.3.2. Implement ''filter'' using ''foldl'' and ''foldr'' | 3.3.2. Implement ''filter'' using ''foldl'' and ''foldr'' | ||
- | 3.3.3. Implement ''foldl'' using ''foldr'' | + | <code haskell> |
+ | filterl :: (a -> Bool) -> [a] -> [a] | ||
+ | filterr :: (a -> Bool) -> [a] -> [a] | ||
+ | </code> | ||
+ | 3.3.3. Implement ''foldl'' using ''foldr'' | ||
+ | <code haskell> | ||
+ | myfoldl :: (a -> b -> a) -> a -> [b] -> a | ||
+ | </code> | ||
3.3.4. Implement ''bubbleSort''. It must use at least one fold | 3.3.4. Implement ''bubbleSort''. It must use at least one fold | ||
<code haskell> | <code haskell> |