-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
878 Proposed extension to subsequence #874
Conversation
<code>$input</code> whose 1-based position | ||
is greater than or equal to <code>$start</code> (rounded to an integer). | ||
No error occurs if <code>$start</code> is zero or negative.</p> | ||
|
||
<p>In the three-argument case, The function returns a sequence comprising those items of | ||
<p>In the case where <code>$input</code>, <code>$start</code>, and <code>$length</code> | ||
are supplied, he function returns a sequence comprising those items of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are supplied, he function returns a sequence comprising those items of | |
are supplied, the function returns a sequence comprising those items of |
We should probably raise an error…
|
Yes, we should add specific error conditions for invalid combinations of arguments. Yes, it is intended that if start and length are both defaulted, you get the whole sequence back. It's not a useful combination of options, but since it falls out naturally, there's no point disallowing it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. One or two examples and an explanatory note – or some equivalent code – could be added for the positional argument ($pos
).
For an interesting use case where the new function might be convenient, see |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My summarized comments:
- We should raise an error…
- if both
$start
and$from
are supplied, or - if more than one of
$length
,$while
, or$until
is supplied.
- One or two examples and an explanatory note – or some equivalent code – should be added for the positional argument (
$pos
).
Notes from discussion on 9th Jan. There was a feeling the proposed function was too complex. I agreed to explore the idea of a simpler subsequence-where() function. Perhaps
|
Related: #844 (comment) |
Dropped, in favor of #940. |
Following discussion under issue #844, I decided to explore the possibility of extending subsequence() with optional parameters, with the aim of making the quartet of items-before/after/starting-with/ending-with unnecessary.
This is the spec that results. I feel it's a good trade-off; by adding three optional parameters to
fn:subsequence
, we can eliminate 4 functions that we are having trouble finding names for. The examples feel to me to be intuitive and readable; and there is more capability in the new function than we had before, for example by combining a predicate for the start position with an integer for the length.I haven't explored arity-2 callbacks - these certainly need some notes and examples.