Skip to content

Fix mapcat and keep docstrings - #1581

Merged
bakpakin merged 1 commit into
janet-lang:masterfrom
sogaiu:fix-mapcat-and-keep-docstrings
Apr 8, 2025
Merged

bakpakin merged 1 commit into
janet-lang:masterfrom
sogaiu:fix-mapcat-and-keep-docstrings

Conversation

@sogaiu

@sogaiu sogaiu commented Apr 6, 2025

Copy link
Copy Markdown
Contributor

Sorry, I think I messed up the mapcat and keep docstrings in #1578.


For mapcat the docstring said:

The resulting array has a length that is the shortest
of `ind` and each of `inds`.

This is not correct, as shown by this example:

(mapcat |(tuple ;$&) [:a :b] [:x :y :z] [0 1])
# =>
@[:a :x 0 :b :y 1]

This PR suggests instead the text:

Note that `f` is only applied to values at indeces up
to the largest index of the shortest of `ind` and each
of `inds`.

For keep, the docstring said:

The resulting array has a length that is the shortest of
`ind` and each of `inds`.

This is not necessarily correct, as shown by this example:

(keep |(when (pos? (+ ;$&)) $0) [1 2 3] [-1 1 1])
# =>
@[2 3]

This PR suggests instead the text:

The resulting array has a length that is no longer than
the shortest of `ind` and each of `inds`.

Hopefully, the above suggestions correct the errors.

(Sorry about the mess up with #1580 as well.)

@bakpakin
bakpakin merged commit 06d01c0 into janet-lang:master Apr 8, 2025
@bakpakin

bakpakin commented Apr 8, 2025

Copy link
Copy Markdown
Member

No problem, I appreciate the help with making the docstrings more precise.

@sogaiu
sogaiu deleted the fix-mapcat-and-keep-docstrings branch September 2, 2026 11:29
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.

2 participants