Skip to content

Sequence comparison (starts, ends, contains) - issues 94, 96 - #222

Closed
michaelhkay wants to merge 3 commits into
qt4cg:masterfrom
michaelhkay:sequence-comparison
Closed

Sequence comparison (starts, ends, contains) - issues 94, 96#222
michaelhkay wants to merge 3 commits into
qt4cg:masterfrom
michaelhkay:sequence-comparison

Conversation

@michaelhkay

Copy link
Copy Markdown
Contributor

Add 3 functions starts-with-sequence, ends-with-sequence, contains-sequence as per issues #96 and part of #94

@michaelhkay

michaelhkay commented Oct 26, 2022

Copy link
Copy Markdown
Contributor Author

Some afterthoughts:

  • the examples using fn:compare as the callback function are wrong because fn:compare doesn't return a boolean
  • the examples all use the markup conventions for executable examples but some are not executable because they have unstated context dependencies
  • perhaps a better formalisation for contains-sequence($x, $y, $compare) would be starts-with-sequence($x, $y, $compare) or (exists(tail($x)) and contains-sequence(tail($x), $y, $compare)). Though it relies on short-cutting and/or for non-termination!
  • there's also an out-by-one bug in the current formalisation of contains-sequence. If the first sequence has length 5 and the second has length 2, then a match can occur at positions 1, 2, 3, or 4. However, testing at all positions does no harm, since subsequence() at later positions will return a sequence that is too short to satisfy the test.

@ndw

ndw commented Nov 16, 2022

Copy link
Copy Markdown
Contributor

Resolved by PR #244, a fixed version of this PR

@ndw ndw closed this Nov 16, 2022
@michaelhkay
michaelhkay deleted the sequence-comparison branch July 9, 2023 23:28
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