Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Import-Module functional
- function map($f) {
- $reducer = {Param($a, $b) @($a) + @(&$f $b)}
- @(@()) + $input | Compress-Object $reducer
- }
- function filter($f) {
- $reducer = {Param($a, $b) if (&$f $b) {@($a) + @($b)} else {$a}}
- @(@()) + $input | Compress-Object $reducer
- }
- $odd = {Param($a) $a % 2}
- $square = {Param($a) $a * $a}
- 1..10 | map $square | filter $odd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement