@@ -578,6 +578,9 @@ operate on these items when it makes sense. Therefore:
578578* As indicated [earlier](#representation-of-objects), quoted names in lists
579579 remain quoted, whereas on HP calculators, the quotes are removed.
580580
581+ * The `MAP` operation on the HP50G recurses on inner lists. On DB48x, it does
582+ not by default. This is controlled by the `ListDepthIteration` setting.
583+ A value of `0` restores HP50G-style infinite recursion.
581584
582585### Vectors and matrices differences
583586
@@ -12592,12 +12595,34 @@ first level of the stack should take one argument and return a single value.
1259212595
1259312596`{ A B ... }` `F` ▶ `{ F(A) F(B) ... }`
1259412597
12595- The operation applies recursively to inner lists.
12598+
12599+ ```rpl
12600+ { 1 2 A 42.2 [ 1 2 3 ]} « →STR » MAP
12601+ @ Expecting { "1" "2" "A" "42.2" "[ 1 2 3 ]" }
12602+ ```
12603+
12604+ Unlike on HP calculators, `Map` does not apply recursively to inner lists by default.
1259612605
1259712606```rpl
1259812607{ 1 2 { 3 4 } } « →STR » MAP
12608+ @ Expecting { "1" "2" "{ 3 4 }" }
12609+ ```
12610+
12611+ This can be changed by setting `ListRecursionDepth` to `0`.
12612+
12613+ ```rpl
12614+ 0 ListRecursionDepth
12615+ { 1 2 { 3 4 } } « →STR » MAP
1259912616@ Expecting { "1" "2" { "3" "4" } }
12617+ ```
12618+
12619+ `Map` can also be constrained to a given depth.
1260012620
12621+ ```rpl
12622+ 2 ListRecursionDepth
12623+ { 1 2 { 3 { 4 { 5 } } } } « →STR » MAP
12624+ @ Expecting { "1" "2" { "3" "{ 4 { 5 } }" } }
12625+ 'ListRecursionDepth' Purge
1260112626```
1260212627
1260312628## Reduce
@@ -12609,6 +12634,22 @@ operation to all elements.
1260912634
1261012635`{ A B ... }` `F` ▶ `F(F(A, B), ...)`
1261112636
12637+ For example, to sum all the elements in a list as text, one can use:
12638+
12639+ ```rpl
12640+ { X Y Z T 12 { Hello World } } « →STR + » REDUCE
12641+ @ Expecting "XYZT12{ Hello World }"
12642+ ```
12643+
12644+ Reduce obeys the `ListRecursionDepth` setting:
12645+
12646+ ```rpl
12647+ 0 ListRecursionDepth
12648+ { X Y Z T 12 { Hello World } } « →STR + » REDUCE
12649+ @ Expecting "XYZT12HelloWorld"
12650+ 'ListRecursionDepth' Purge
12651+ ```
12652+
1261212653
1261312654## Filter
1261412655
@@ -12618,6 +12659,22 @@ resulting list is built with all elements where the predicate is true.
1261812659
1261912660`{ A B ... }` `P` ▶ `{ A ... }` if `P(A)` is true and `P(B)` is false.
1262012661
12662+ For example, to filter all odd numbers in an array, one can use:
12663+
12664+ ```rpl
12665+ [ 1 2 3 4 5 6 42 ] « 2 MOD 0 = » FILTER
12666+ @ Expecting [ 2 4 6 42 ]
12667+ ```
12668+
12669+ `Filter` obeys the `ListRecursionDepth` setting:
12670+
12671+ ```rpl
12672+ 0 ListRecursionDepth
12673+ { 1 2 3 4 { 5 6 { 42 } } } « 2 MOD 0 = » FILTER
12674+ @ Expecting { 2 4 { 6 { 42 } } }
12675+ 'ListRecursionDepth' Purge
12676+ ```
12677+
1262112678
1262212679## Get
1262312680
@@ -15120,6 +15177,17 @@ from the HP implementations of RPL.
1512015177
1512115178The opposite setting is `TruthLogicForIntegers`.
1512215179
15180+ ## ListRecursionDepth
15181+
15182+ This setting selects the depth of recursion for `Map`, `Reduce` or `Filter`.
15183+ By default, it is set to `1`, indicating that recursion only applies to the
15184+ top-level of the list. This matches the way `Map`, `Reduce` and `Filter` work in
15185+ most programming languages.
15186+
15187+ A value larger than `1` can be used to recurse beyond the first level.
15188+ On the HP50G, `Map` applies recursively to all levels. This can be achieved by
15189+ setting `ListRecursionDepth` to `0`.
15190+
1512315191
1512415192# Evaluation settings
1512515193
0 commit comments