Syntax for function composition
See original GitHub issue[@gavinking] I would like an operator for composing functions, but I’m not sure what actual symbol to use. I suppose =>
and <=
could work.
function times2plus1(Integer i) = 2.times => 1.plus;
or
function times2plus1(Integer i) = 1.plus <= 2.times;
Another possibility would be @
which sorta kinda looks a little bit like the traditional symbol in mathematics if you squint. But it doesn’t make the direction of composition clear, and is less flexible than =>
and <=
because you can’t choose the direction of composition.
Any suggestions?
[Migrated from ceylon/ceylon-spec#123]
Issue Analytics
- State:
- Created 12 years ago
- Comments:34 (14 by maintainers)
Top Results From Across the Web
Function composition - Wikipedia
In mathematics, function composition is an operation ∘ that takes two functions f and g, and produces a function h = g ∘...
Read more >Composition of Functions - Math is Fun
Example: f(x) = 2x+3. (f º f)(x) = f(f(x)). First we apply f, then apply f to that result: Function Composition. (f º...
Read more >Function Composition Syntax - Racket Documentation
This library provides an alternative #%app syntax that interprets double dots as (unary) function composition. The syntax is lightweight and extensible ...
Read more >Function Composition in Python - GeeksforGeeks
Function composition is the way of combining two or more functions in such a way that the output of one function becomes the...
Read more >Function Composition in Python - Mathieu Larose
Function composition is a way of combining functions such that the result of each function is passed as the argument of the next...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
don’t know about the best ascii syntax, but I’d like to have this feature.
Wait wait wait, isn’t it “obvious” that the correct syntax for composition, given that a pipe is written
|>
must clearly be:Since composition has a function on both ends, whereas a pipe has a function only as the RHS.
And then reversed composition, if we need it, would be: