Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Feb 29, 2024
2 parents da1ad91 + ce19727 commit 5c815fa
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
14 changes: 10 additions & 4 deletions eo-runtime/src/main/eo/org/eolang/tuple.eo
Expand Up @@ -57,10 +57,16 @@
index.lt 0
index.gte len
error "Given index is out of tuple bounds"
if.
index.lt (len.plus -1)
^.head.at index
^.tail
at-without-checks index

# Takes element from the tuple without index validation.
# Here `i` must be an object that can be comparable with `int` using `lt` attribute.
[i] > at-without-checks
i > idx!
if. > @
idx.lt head.length
^.^.head.at.at-without-checks idx
^.^.tail

# Create a new tuple with this element added to the end of it.
[x] > with
Expand Down
18 changes: 18 additions & 0 deletions eo-runtime/src/test/eo/org/eolang/tuple-tests.eo
Expand Up @@ -172,6 +172,24 @@
a.at 0
3

# Test
[] > at-without-checks-with-first-element
eq. > @
at-without-checks.
at.
* 100 101 102
0
100

# Test
[] > at-without-checks-with-last-element
eq. > @
at-without-checks.
at.
* 100 101 102
2
102

# Test.
[] > tuple-empty-fluent-with-indented-keyword
tuple
Expand Down

0 comments on commit 5c815fa

Please sign in to comment.