c(a|d)ⁿr
#%top
1 Composable c(a|d)ⁿr
define-default-cadnr-top
8.12

c(a|d)ⁿr🔗

Eutro

car, cdr, caaaaddddr, and everything in between.

 (require cadnr) package: cadnr

c(a|d)ⁿr

This module extends a number of built-in Racket functions that have obvious arbitrary extensions.

For instance, the caaaar-cddddr family of functions are defined for all combinations of as and ds, but only up to four! The obvious extension is to allow for an arbitrary number of each, and to simply generate them on the fly when they are referred to.

With this module required, it’s possible to use these functions just by naming them:

Examples:
> (caddddddddddr '(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15))

11

> (succcccc 1)

6

> (sub1234 5678)

4444

syntax

(#%top . id)

Overrides the #%top from racket/base, see Expansion Steps for how this is introduced implicitly.

Pattern matches id to see if it matches one of the default c(a|d)ⁿr patterns. If one of them matches, this form expands to a suitable lambda expression, otherwise it expands to the #%top from racket/base.

The patterns are as follows:

1 Composable c(a|d)ⁿr🔗

 (require cadnr/defaults) package: cadnr

syntax

(define-default-cadnr-top new-top old-top)

Define new-top the same way as #%top above, but such that it falls back to old-top instead of the one from racket/base.

This is included for composability reasons, so as not to introduce conflicts with other modules that override the binding of '#%top the way as cadnr does.