packages feed

purescript-0.8.4.0: examples/passing/1991.purs

module Main where

import Prelude

singleton :: forall a. a -> Array a
singleton x = [x]

empty :: forall a. Array a
empty = []

foldMap :: forall a m. (Semigroup m) => (a -> m) -> Array a -> m
foldMap f [a, b, c, d, e] = f a <> f b <> f c <> f d <> f e

regression :: Array Int
regression =
  let as = [1,2,3,4,5]
      as' = foldMap (\x -> if 1 < x && x < 4 then singleton x else empty) as
  in as'
                  
main = Control.Monad.Eff.Console.log "Done"