mirror of
https://github.com/denisidoro/navi
synced 2024-11-25 21:10:21 +00:00
27 lines
402 B
Bash
27 lines
402 B
Bash
#!/usr/bin/env bash
|
|
|
|
inc() {
|
|
local -r x="$1"
|
|
echo $((x+1))
|
|
}
|
|
|
|
sum() {
|
|
local -r x="$1"
|
|
local -r y="$2"
|
|
echo $((x*y))
|
|
}
|
|
|
|
func_map() {
|
|
func::list 1 2 3 \
|
|
| func::map inc \
|
|
| test::equals "$(func::list 2 3 4)"
|
|
}
|
|
|
|
func_reduce() {
|
|
func::list 1 2 3 \
|
|
| func::reduce sum 10 \
|
|
| test::equals 60
|
|
}
|
|
|
|
test::run "map works" func_map
|
|
test::run "reduce works" func_reduce
|