Skip to content

Instantly share code, notes, and snippets.

@sshastry
Created July 26, 2015 18:57
Show Gist options
  • Save sshastry/cb0591ea8797083c6d70 to your computer and use it in GitHub Desktop.
Save sshastry/cb0591ea8797083c6d70 to your computer and use it in GitHub Desktop.
-- http://www.reddit.com/r/haskell/comments/2xmp9j/what_to_you_think_about_the_fsharp_piping/
(|>) :: a -> (a -> b) -> b
(|>) x f = f x
($>) :: Functor r => r a -> (a -> b) -> r b
($>) xs f = fmap f xs
(?>) :: [a] -> (a -> Bool) -> [a]
(?>) xs f = filter f xs
{-
>>> [1..10] |> filter even |> reverse |> take 3
[10,8,6]
>>> [1..10] ?> even |> reverse |> take 3
[10,8,6]
>>> [1..10] $> (^2) $> (/10) $> (+100)
[100.1,100.4,100.9,101.6,102.5,103.6,104.9,106.4,108.1,110.0]
>>> [1..10] ?> even
[2,4,6,8,10]
>>> [1..10] ?> even $> (+1)
[3,5,7,9,11]
e.g.
parseCSVcont content = (header,matrix)
where
header = content |> splitLines
$> splitComma
|> head
matrix = content |> splitLines
$> splitComma
|> tail
$> map readDouble
-}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment