add filter-map command to std iter (#8926)

# Description
as title says
This commit is contained in:
mike
2023-04-19 20:09:10 +03:00
committed by GitHub
parent 1855dfb656
commit ed64a44b82
2 changed files with 50 additions and 31 deletions

View File

@ -48,3 +48,14 @@ export def test_iter_scan [] {
let scanned = ([a b c d] | iter scan "" {|x, y| [$x, $y] | str join} -n)
assert equal $scanned ["a" "ab" "abc" "abcd"]
}
export def test_iter_filter_map [] {
let res = ([2 5 "4" 7] | iter filter-map {|it| $it ** 2})
assert equal $res [4 25 49]
let res = (
["3" "42" "69" "n" "x" ""]
| iter filter-map {|it| $it | into int}
)
assert equal $res [3 42 69]
}