question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 12 years ago
  • Comments:34 (14 by maintainers)

github_iconTop GitHub Comments

2reactions
davidfestalcommented, Apr 16, 2018

Will we eventually consider “esoteric” compositions, like optional or spreading

don’t know about the best ascii syntax, but I’d like to have this feature.

2reactions
gavinkingcommented, Apr 16, 2018

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:

<|<
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found