Skip to content

Instantly share code, notes, and snippets.

@gerardpaapu
Last active June 18, 2018 23:38
Show Gist options
  • Save gerardpaapu/d3ac537c586af54c9fd0099d183a88ac to your computer and use it in GitHub Desktop.
Save gerardpaapu/d3ac537c586af54c9fd0099d183a88ac to your computer and use it in GitHub Desktop.
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