Skip to content

Instantly share code, notes, and snippets.

@DonaldKellett
Created December 31, 2018 16:06
Show Gist options
  • Save DonaldKellett/dc8700a821b454c5dd8dad7d882c679b to your computer and use it in GitHub Desktop.
Save DonaldKellett/dc8700a821b454c5dd8dad7d882c679b to your computer and use it in GitHub Desktop.
PureScript by Example - 4.7 Filtering Arrays - Exercise 1-3 Solutions
module MapAndFilter where
-- 4.7 Filtering Arrays of PureScript by Example
import Prelude
import Data.Array
-- Exercise 1
squared :: Array Number -> Array Number
squared = map (\n -> n * n)
-- Exercises 2-3
infixr 5 filter as <$?>
sansNegative :: Array Number -> Array Number
sansNegative = (<$?>) (\n -> n >= 0.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment