-
-
Save DimaD/cfcf7ebdcb3f350f7aac 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
;; "Normal" operation order | |
(->> [1 2 3] | |
(map inc) | |
(map #(* 2 %) | |
(reduce +)) |
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
t :: [Integer] -> Integer | |
-- "Reverse" operation order | |
t x = foldr1 (+) $ map (*2) $ map (+1) x |
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
t :: [Integer] -> Integer | |
-- "Reverse" operation order | |
t x = foldr1 (+) $ map (*2) $ map (+1) x | |
-- Let's define forward-chaining operator | |
($>) = flip ($) | |
t2 :: [Integer] -> Integer | |
t2 x = x $> map (+1) $> map (*2) $> foldr1 (+) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment