Last active
June 18, 2018 23:38
-
-
Save gerardpaapu/d3ac537c586af54c9fd0099d183a88ac 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 Main where | |
import Prelude | |
import Data.Foldable (sum) | |
import Data.List.Lazy (filter, takeWhile) | |
import Data.List.Lazy.Types (List) | |
import Data.Maybe (Maybe(..)) | |
import Data.Tuple (Tuple(..)) | |
import Data.Unfoldable (unfoldr) | |
import Control.Monad.Eff.Console (logShow) | |
import TryPureScript (render, withConsole) | |
fibs :: List Int | |
fibs = | |
unfoldr next (Tuple 1 2) | |
where | |
next (Tuple i j) = Just (Tuple i (Tuple j (i + j))) | |
result :: Int | |
result = | |
fibs | |
# filter (\n -> n `mod` 2 == 0) | |
# takeWhile (_ <= 4000000) | |
# sum | |
main :: _ | |
main = render =<< withConsole do | |
logShow result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment