Function Composition Syntax
This library provides an alternative #%app syntax that interprets double dots as (unary) function composition. The syntax is lightweight and extensible through syntax parameters, allowing alternative base forms of #%app to be substituted. Included with this package is integration with the fancy-app module, to make composition of anonymous functions as painless as possible.
Source code for this library is avaible at https://github.com/jackfirth/compose-app
1 API Reference
(require compose-app) | package: compose-app |
syntax
(compose-app func-expr dotted-func-expr ...)
func-expr = single-expr | many-expr ... dotted-func-expr = .. func-expr
> ((add1 .. string->number .. first) '("15" "2" "96")) 16
> (define ((mapped f) vs) (map f vs)) > ((rest .. (mapped string->symbol) .. string-split) "foo bar baz") '(bar baz)
> ((rest .. mapped string->symbol .. string-split) "foo bar baz") '(bar baz)
The composition produced by compose-app is a single-argument function defined in terms of compose-app-base-lambda, which defaults to lambda from racket/base.
syntax
syntax
syntax
syntax
2 Integration with fancy-app
(require compose-app/fancy-app) | package: compose-app |
syntax
> ((map string->number _ .. rest .. string-split) "1 10 100") '(10 100)