[release] merge previous version into master to avoid the increased version number
This commit is contained in:
commit
14dd7c3993
3 changed files with 22 additions and 5 deletions
2
.version
2
.version
|
@ -1 +1 @@
|
|||
2.1
|
||||
2.2
|
||||
|
|
12
src/fun.sh
12
src/fun.sh
|
@ -66,10 +66,22 @@ lambda() {
|
|||
}
|
||||
|
||||
map() {
|
||||
if [[ $1 != "λ" ]] && [[ $1 != "lambda" ]]; then
|
||||
|
||||
local has_dollar=$(list $@ | grep '\$' | wc -l)
|
||||
|
||||
if [[ $has_dollar -ne 0 ]]; then
|
||||
args=$(echo $@ | sed -e 's/\$/\$a/g')
|
||||
map λ a . $args
|
||||
else
|
||||
map λ a . "$@"' $a'
|
||||
fi
|
||||
else
|
||||
local x
|
||||
while read x; do
|
||||
echo "$x" | "$@"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
foldl() {
|
||||
|
|
|
@ -30,4 +30,9 @@ testFlatMap() {
|
|||
assertEquals "d e h l l l o o r w" "$(list hello world | map lambda x . 'command fold -w 1 <<< $x' | sort | unlist)"
|
||||
}
|
||||
|
||||
testMapNoLambdaSyntax() {
|
||||
assertEquals "1 2 3" "$(list 1 2 3 | map echo | unlist)"
|
||||
assertEquals "1 is a number 2 is a number 3 is a number" "$(list 1 2 3 | map 'echo $ is a number' | unlist)"
|
||||
}
|
||||
|
||||
. ./shunit2-init.sh
|
Loading…
Reference in a new issue