Built-in
- map
- input | %{ expression($_) }
- forEach
- input | %{ [void]expression($_) }
- filter
- input | ?{ expression($_) }
- indexOf
- input.indexOf(value)
Close to built-in
- some
- if (input | ?{ expression($_) }) { ... }
- every
- if (-not input | ?{ !expression($_) }) { ... }
- lastIndexOf
- [array]::lastIndexOf(input, value)
Write it yourself
- reduce
- function reduce($fn, $a, $init) { $s = $init; $a | %{ $s = &$fn $s $_; }; $s; }
No comments:
Post a Comment