Created
May 12, 2020 12:14
-
-
Save tarquin-the-brave/dd63e32bd371555b8c73cee41d90d11c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Lib | |
( tot_1 | |
, tot_2 | |
) where | |
f :: Integral a => a -> a | |
f x = x `div` 3 - 2 | |
tot_1 :: Integral a => [a] -> a | |
tot_1 = tot f | |
g :: Integral a => a -> a | |
g x | |
| f x >= 0 = f x + g(f x) | |
| otherwise = 0 | |
tot_2 :: Integral a => [a] -> a | |
tot_2 = tot g | |
tot :: Integral a => (a -> a) -> [a] -> a | |
tot f = sum . fmap f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment