Skip to content

Conversation

@sogaiu
Copy link
Contributor

@sogaiu sogaiu commented Apr 6, 2025

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
13 checks passed
@bakpakin
Copy link
Member

bakpakin commented Apr 8, 2025

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

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