diff --git a/.version b/.version index cd5ac03..879b416 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -2.0 +2.1 diff --git a/README.md b/README.md index b1c426c..03d5783 100644 --- a/README.md +++ b/README.md @@ -346,4 +346,5 @@ Adam,Monika,Slawek,Daniel,Bartek # Resources -* [Inspiration](https://quasimal.com/posts/2012-05-21-funsh.html) \ No newline at end of file +* [Inspiration](https://quasimal.com/posts/2012-05-21-funsh.html) +* [Functional Programming in Bash](https://medium.com/@joydeepubuntu/functional-programming-in-bash-145b6db336b7) \ No newline at end of file diff --git a/src/fun.sh b/src/fun.sh index 9608852..d0b3af8 100755 --- a/src/fun.sh +++ b/src/fun.sh @@ -193,6 +193,26 @@ filter() { done } +pass() { + echo > /dev/null +} + +dropw() { + local x + while read x && $(echo "$x" | "$@"); do + pass + done + [[ ! -z $x ]] && { echo $x; cat -; } +} + +peek() { + local x + while read x; do + ([ $# -eq 0 ] && 1>&2 echo $x || 1>&2 "$@" < <(echo $x)) + echo $x + done +} + stripl() { local arg=$1 cat - | map lambda l . 'ret ${l##'$arg'}'