Function composition: Difference between revisions
Content added Content deleted
(Update Lang example: Use new operation parser syntax and add print function calls) |
|||
Line 1,799: | Line 1,799: | ||
# In Lang this task can be achieved with the concat operator |
# In Lang this task can be achieved with the concat operator |
||
parser.op(fp.g ||| fp.f)($x) # Prints 21 [Internal execution: fp.f(fp.g($x))] |
fn.println(parser.op((fp.g ||| fp.f)($x))) # Prints 21 [Internal execution: fp.f(fp.g($x))] |
||
# Creating a user-defined function doing the same thing is a bit more difficult |
# Creating a user-defined function doing the same thing is a bit more difficult |
||
Line 1,807: | Line 1,807: | ||
} |
} |
||
fp.compose(fp.f, fp.g)($x) # Prints also 21 |
fn.println(fp.compose(fp.f, fp.g)($x)) # Prints also 21 |
||
</syntaxhighlight> |
</syntaxhighlight> |
||