Cheddar Documentation
Search…
Cheddar Documentation
Introduction
Syntax
Literals
Mathematics
Variables
Functions
Defining
Operations
Functional Bonding
Functional Composition
Default Operators
Control Flow
Standard Library
Developing
Powered By
GitBook
Functional Composition
Syntax
1
f
+
g
Copied!
Explanation
Performs functional composition on the two operands. Returns a function which passes its arguments to
g
and then too
f
.
The following are equivilent:
1
(
f
+
g
)(
a
,
b
)
==
f
(
g
(
a
,
b
))
Copied!
Examples
An example to change a zero-indexed function to a one-indexed function utilizing composition is:
1
let
fibonacci
=
n f
->
n
<
2
?
1
:
f
(
n
-
1
)
+
f
(
n
-
2
);
2
let
increment
=
(
+
)
&
1
;
3
4
(
fibonacci
+
increment
)(
5
)
==
13
Copied!
Previous
Functional Bonding
Next
Default Operators
Last modified
1yr ago
Copy link
Contents
Syntax
Explanation
Examples