Adding with_trampoline function

This commit is contained in:
Sławomir Śledź 2018-02-14 01:19:43 +01:00
parent cb9eff8b81
commit b5a3c9eea0
2 changed files with 63 additions and 2 deletions

View file

@ -242,7 +242,7 @@ zip() {
done
}
function curry() {
curry() {
exportfun=$1; shift
fun=$1; shift
params=$*
@ -253,3 +253,25 @@ function curry() {
eval $cmd
}
with_trampoline() {
local f=$1; shift
local args=$@
while [[ $f != 'None' ]]; do
ret=$($f $args)
# echo $ret
f=$(tupl $ret)
args=$(echo $ret | tupx 2- | tr ',' ' ')
done
echo $args
}
res() {
local value=$1
tup "None" $value
}
call() {
local f=$1; shift
local args=$@
tup $f $args
}