Skip to content

Command Map recurse depending on flag; Filter do not recurse#1649

Closed
evgaster wants to merge 5 commits intoc3d:stablefrom
evgaster:issue-1648
Closed

Command Map recurse depending on flag; Filter do not recurse#1649
evgaster wants to merge 5 commits intoc3d:stablefrom
evgaster:issue-1648

Conversation

@evgaster
Copy link
Copy Markdown

@evgaster evgaster commented Mar 4, 2026

With nested lists the commands Map and Filter operated not only on the top level list but recursively on the nested list(s) . The HP 50g map command also does this. The HP 50g has no filter command.

Most programming languages work on only the toplevel of a list and do not recurse
Introduced a MapRecursive / MapOneLevel flag to facilitate both behaviours.
The default behaviour of DB48x map corresponds to the HP 50g behaviour (MapRecursive = true).

The filter command no longer works recursively.

Fixes: #1648
Signed-off-by: Ed@vanGasteren.net

With nested lists the commands Map and Filter operated not only on the top level list
but recursively on the nested list(s) ... with the same provided rpl program.

Removed the recursive processing of the elements of a list.

Fixes: c3d#1648
Signed-off-by: Ed@vanGasteren.net
c3d added a commit that referenced this pull request Mar 9, 2026
The `map` function on the HP48 is supposed to be recursive.
Document that fact.

Related to #1649

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The HP 50g maps recursively.
Most other programming languages map only on level.

Introduce the flag MapRecursive / MapOneLevel.
Both behaviours are now possible.

Describes as such in the documentation.

Fixes: c3d#1648
Signed-off-by: Ed@vanGasteren.net
In a Previous commit I got the default flag behaviour wrong.

Fixes c3d#1648
Signed-off-by: Ed@vanGasteren.net
Fixes c3d#1648
Signed-off-by: Ed@vanGasteren.net
@evgaster evgaster changed the title src: Commands Map and Filter should not recurse src: Commands Map and Filter should not recurse; Mar 13, 2026
@evgaster evgaster changed the title src: Commands Map and Filter should not recurse; src: Commands Map should only recurse depending on flag; Filter should not recurse Mar 13, 2026
@evgaster evgaster changed the title src: Commands Map should only recurse depending on flag; Filter should not recurse Command Map recurse depending on flag; Filter do not recurse Mar 13, 2026
Signed-off-by: evgaster <Ed@vanGasteren.net>
@c3d
Copy link
Copy Markdown
Owner

c3d commented Apr 11, 2026

Hi @evgaster. Thanks a lot for the PR. In the end, I rewrote it somewhat significantly to make it a bit more general.

  1. I replaced your MapRecursive / MapOneLevel flag with a ListRecursionDepth setting so that you can for example map on two levels. A value of 0 means infinite
  2. I used the same setting for Map, Reduce and Filter. I see no reason to disable the mechanism for Filter, and I added it to Reduce where list processing was missing.

@c3d
Copy link
Copy Markdown
Owner

c3d commented Apr 11, 2026

Closing this for now, thanks a lot @evgaster

@c3d c3d closed this Apr 11, 2026
c3d pushed a commit that referenced this pull request Apr 12, 2026
The `ListRecursionDepth` controls the recusion depth for the `map`,
`reduce` and `filter` operation. This defaults to `1`, meaning that we
apply these functions only to the top level of the lists.

The idea derives from work in PR #1649, but generalizing the approach
in the PR, which only had a binary setting, disabled recursion for
`filter` entirely, and did not consider the case of `reduce`.

Fixes: #1648

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Suggested-by: Ed@vanGasteren.net
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Map command works (incorrect) recursively

2 participants