compose 0.1.1 copy "compose: ^0.1.1" to clipboard
compose: ^0.1.1 copied to clipboard

Compose functions in dart(https://en.wikipedia.org/wiki/Function_composition). Try to use it with language operators.

Compose with language operators #

Try to use composition functions with language operators! You can use right (classic) and left composition.

You have two ways to define your composition: >> and *. Its same! For calling you need to use < (from left function) or > (from right function).

Examples #

var addOne = (x) => x + 1;
var minusOne = (x) => x - 1;
var add = (x, v) => x + v;

print(c() >> addOne >> minusOne >> ((_) => add(1, _ * 2)) > 3); // 7
print(c() >> addOne >> minusOne >> ((_) => add(1, _ * 2)) < 3); // 7

print(c() * addOne * ((_) => _ * 2) > 4); // 9
print(c() * addOne * ((_) => _ * 2) < 4); // 10
0
likes
35
pub points
0%
popularity

Publisher

unverified uploader

Compose functions in dart(https://en.wikipedia.org/wiki/Function_composition). Try to use it with language operators.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

More

Packages that depend on compose