# C(a|d)ⁿr - car, cdr, caaaaddddr, and everything in between

**URL:** <https://racket.discourse.group/t/c-a-d-r-car-cdr-caaaaddddr-and-everything-in-between/1876>\
**Category:** Show & Tell\
**Tags:** package\
**Created:** [April 19, 2023, 9:44am UTC](https://racket.discourse.group/t/c-a-d-r-car-cdr-caaaaddddr-and-everything-in-between/1876 "2023-04-19T09:44:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eutro](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/eutro/32/2275_2.png) [@Eutro](https://racket.discourse.group/u/Eutro)\
**Post date:** [April 19, 2023, 9:44am UTC](https://racket.discourse.group/t/c-a-d-r-car-cdr-caaaaddddr-and-everything-in-between/1876/1 "2023-04-19T09:44:15Z")

</div>

c(a|d)ⁿr is an fun little library I hacked together last night, leveraging Racket's incredible flexibility for language extensions.

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:

```plaintext
> (caddddddddddr '(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15))
11
> (succcccc 1)
6
> (sub1234 5678)
4444

```

Read [the full documentation](https://docs.racket-lang.org/cadnr/index.html) and try it out!

---

<div class="post-metadata">

**Author:** ![spdegabrielle](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/spdegabrielle/32/95_2.png) [@spdegabrielle](https://racket.discourse.group/u/spdegabrielle)\
**Post date:** [April 20, 2023, 12:31pm UTC](https://racket.discourse.group/t/c-a-d-r-car-cdr-caaaaddddr-and-everything-in-between/1876/2 "2023-04-20T12:31:49Z")

</div>

Am I getting this right - this is happening at macro expansion - extending the racket compiler handle arbitrary combinations?

Am I right in assuming it be approximately as fast as the native functions at run time?

Stephen

---

<div class="post-metadata">

**Author:** ![Eutro](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/eutro/32/2275_2.png) [@Eutro](https://racket.discourse.group/u/Eutro)\
**Post date:** [April 24, 2023, 1:15am UTC](https://racket.discourse.group/t/c-a-d-r-car-cdr-caaaaddddr-and-everything-in-between/1876/3 "2023-04-24T01:15:04Z")

</div>

That's right, they are expanded at compile time. They are compiled to normal `lambda` expressions, so they're as efficient as those.
