builtins: add take n xs and drop n xs#188
Merged
Merged
Conversation
f124ae4 to
34d5b8f
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
c868ea0 to
26b19ef
Compare
Slicing prefixes and suffixes is a daily need that previously required sub start end with arithmetic. take n xs returns the first n elements, drop n xs returns everything after. Both clamp on out-of-range n. Opcodes allocated: take, drop. Works on lists and text. Negative n errors at runtime via the standard verify path.
26b19ef to
f692d14
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Slicing prefixes and suffixes is a daily need that previously required sub with arithmetic. take and drop give it a one-token form.
Implementation:
Tests: cross-engine regression tests + examples/take-drop.ilo with -- run: directives.