sharkdp / shell-functools

Functional programming tools for the shell
MIT License
1.2k stars 49 forks source link

support for lambda expression #9

Closed leeexyz closed 6 years ago

leeexyz commented 6 years ago

It would be nice if we can add the lamdba expression support.

sharkdp commented 6 years ago

Was thinking about this, but this would probably involve writing a parser of some sorts? What kind of use cases and what kind of syntax do you have in mind?

leeexyz commented 6 years ago

Here is what i am thinking about, we can keep it as simple as possible just using eval function in python. We always assume that the input is a string of lambda expression.

>>> plus3 = "lambda x: x + 3"
>>> eval(plus3)
<function <lambda> at 0x1013a52f0>
>>> a = list(range(5))
>>> list(map(eval(plus3), a))
[3, 4, 5, 6, 7]
sharkdp commented 6 years ago

Thank you for your feedback!

To be honest, I would like to avoid using python-code-as-string arguments (and the usage of eval in particular).

I'm closing this in favor of #5 as I don't really see any concrete plan to implement this.