-
Notifications
You must be signed in to change notification settings - Fork 0
Guide Operators
Jonathan Potter edited this page Jun 3, 2014
·
5 revisions
The following operators are functions that can be accessed on the tlc.op object. For example: tlc.op["+"](1, 2).
-
-
-
- /
- ===
- <
- <=
-
-
=
- &&
- ||
For logical negation we use tlc.not instead of tlc.op["!"] because it's shorter and more readable.
Defining these operator functions is useful because JavaScript operators are not first class. For example, this allows you to do:
tlc.reduce(tlc.op["+"], 0, [1, 2, 3]); // 6There are also flipped versions of all of these operators (except the ones that are commutative) in the corresponding tlc.fop object. tlc.fop will often be useful when you're partially applying an operator. For example:
tlc.filter(tlc.fop["<"](3), [1, 2, 3]); // [1, 2]