2011-11-03 14:21:08 +00:00
|
|
|
# ZSH higher order functions
|
|
|
|
|
2012-07-08 21:27:52 +00:00
|
|
|
You can look at [yogsototh's blogpost] for the idea of higher order functions
|
|
|
|
in zsh.
|
2011-11-03 14:21:08 +00:00
|
|
|
|
2012-07-10 14:39:13 +00:00
|
|
|
## Install
|
|
|
|
|
|
|
|
If you are lazy just copy paste the following line in your terminal:
|
|
|
|
|
|
|
|
cd /tmp && \
|
|
|
|
curl -O https://raw.github.com/yogsototh/zsh_functional/master/install.sh && \
|
|
|
|
chmod u+x install.sh && . ./install.sh
|
|
|
|
|
2012-07-08 21:27:52 +00:00
|
|
|
To install, clone this repo to `~/.zsh/functional` and add
|
2011-11-03 14:21:08 +00:00
|
|
|
|
2012-07-08 11:51:07 +00:00
|
|
|
. ~/.zsh/functional/load
|
2011-11-03 14:21:08 +00:00
|
|
|
|
|
|
|
to your `.zshrc`
|
2012-07-08 11:42:00 +00:00
|
|
|
|
2012-07-10 14:39:13 +00:00
|
|
|
|
2012-07-08 21:27:52 +00:00
|
|
|
## Usage and documentation
|
|
|
|
|
|
|
|
Please refer to the tests so far until I've written simple proper docs for each
|
|
|
|
function. The function `map` and family will print out documentation for you
|
|
|
|
when calling them with no arguments.
|
|
|
|
|
|
|
|
Each of the method families, `map`, `each`, `filter` and `fold` are having a
|
|
|
|
"normal version" accompanied with lambda function version and a arithmetic
|
|
|
|
lambda version.
|
|
|
|
|
|
|
|
### Lambda functions
|
|
|
|
|
|
|
|
Use the versions ending with `l`, like `mapl`, `eachl`, `foldl`.
|
|
|
|
|
|
|
|
### Arithmetic lambda functions
|
|
|
|
|
|
|
|
Similarly, use the functions ending with `a`.
|
|
|
|
|
|
|
|
## Contributing
|
|
|
|
|
|
|
|
Good idea! Just add a test and implement the new functionality and send away
|
|
|
|
your pull request! :)
|
|
|
|
|
|
|
|
## Creds
|
|
|
|
|
|
|
|
Yann Esposito for the *HoF* idea and big thanks to [Sterling's blogpost] for
|
|
|
|
discovering and starting implementing the anonymous function features.
|
|
|
|
|
|
|
|
[yogsototh's blogpost]: http://yannesposito.com/Scratch/en/blog/Higher-order-function-in-zsh/
|
|
|
|
[Sterling's blogpost]: http://nicholassterling.wordpress.com/2012/03/30/a-zsh-map-function/
|