Skip to content

Instantly share code, notes, and snippets.

@mark-jay
Forked from abesto/curry.bash
Last active April 25, 2018 22:47
Show Gist options
  • Select an option

  • Save mark-jay/e5b55286635affb2a99c to your computer and use it in GitHub Desktop.

Select an option

Save mark-jay/e5b55286635affb2a99c to your computer and use it in GitHub Desktop.
Partial application in Bash
function curry() {
exportfun=$1; shift
fun=$1; shift
params=$*
cmd=$"function $exportfun() {
more_params=\$*;
$fun $params \$more_params;
}"
eval $cmd
}
function add() {
a=$1; shift
b=$1; shift
expr $a + $b
}
curry add3 add 3
$add3 9
# Guess the output :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment