[#544] Add `CAR k` and `CDR k` macros
Description
This MR adds the newest CAR k
and CDR k
macros introduced with edo
. CAR k
gets the 2k+1
-th element of a right-combed pair, and CDR k
gets the 2k
-th element of a right-combed pair. Support for the new macros is also added in Lorentz.
For example, given the following right-combed pair:
0 Depth: 0
/ \ |
1 2 1
/ \ |
3 4 2
The following observations are made:
-
CAR 0
andCAR 1
are equivalent toCAR
andCDAR
, respectively. - More specifically,
CAR k
is equivalent toCDR
repeatedk
times followed byCAR
. -
CDR 0
is equivalent to a no-op.CDR 1
andCDR 2
are equivalent toCDR
andCDDR
, respectively. -
GET 0
works with any type (not only pair) and soCDR 0
also works with any type. - More specifically,
CDR k
is equivalent toCDR
repeatedk
times. -
CAR k
is simply{ GET (2k+1) }
andCDR k
is simply{ GET (2k) }
. -
CDR k
can be also thought as traversing the right-combed pair to a depth ofk
from the top.
Related issue(s)
Resolves #544 (closed)
✅ Checklist for your Merge Request
Related changes (conditional)
-
Tests (see short guidelines)
-
If I added new functionality, I added tests covering it. -
If I fixed a bug, I added a regression test to prevent the bug from silently reappearing again.
-
-
Documentation
Stylistic guide (mandatory)
-
My commits comply with the following policy. -
My code complies with the style guide.
Edited by Heitor Toledo Lassarote de Paula