-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Woven functional programming #18915
Comments
And another post: Agreed, less verbose, more flexible.
In some cases, the amount of dots compared to ~ is cut down on. Eg. |
And another: Agreed that the pure math aspect of things gets lost. There are allocation free ways of going about this:
And in fact, ChainMap has some convenience macros for doing this:
But to do this you need to make assumptions about argument order (put the anonymous function first, the woven arguments last).
|
The reason why I don't see this as a usable replacement for the |
@bramtayl I think this would be quite interesting. Could you make a package? The syntax can come later. Edit: Never mind, I see that you already have https://github.com/bramtayl/ChainMap.jl |
https://github.com/bramtayl/ChainMap.jl |
Note that I just tagged a new version; hasn't made it into METADATA yet. Fixes mostly minor |
I think if you're worried about "hiding" broadcast, it should be relatively easy to make this the "default". For example, Although less flexible, this still retains some of the advantages:
This could be used along with syntax above |
ChainMap master now has
|
Ok, well, this can stay in ChainMap.jl for now. |
I've been thinking about this again. Currently |
I think discourse is better for general julia questions like this one. |
I got a request in #16285 to open up a new issue for this suggestion.
I'm copying the original post:
OK, I've gotten ChainMap into a place where it's relatively stable, and I'd like to propose an alternate method of dot vectorization based on the work there.
Here's an alternative.
Here's how the syntax would change:
map( ~ sin(~x + y) )
goes tomap( LazyCall(x -> sin(x + y), x) )
broadcast( ~ sin(~x + ~y) )
goes tobroadcast( LazyCall( (x, y) -> sin(x + y), x, y) )
mapreduce( ( ~ sin(~x + y) ), +)
goes tomapreduce( LazyCall( x -> sin(x + y), x), +)
Splats (needs more thought, I think)
~ f(~(x...) )
goes toLazyCall( (x...) -> f(x...), x...)
~ f(~(;x...) )
goes toLazyCall( (;x...) -> f(;x...); x...)
Advantages over the current system:
Disadvantages:
All of this is implemented in ChainMap at the moment, aside from the new methods for map and friends. It can probably stay in a package for now if people aren't interested in adding it to base.
The text was updated successfully, but these errors were encountered: