-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
list.reverse
intrinsic function (#1758)
``Expr(expression)`` has also been added. Co-authored-by: kabra1110 <[email protected]>
- Loading branch information
1 parent
9941f2c
commit 7727de2
Showing
8 changed files
with
190 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from lpython import i32, f64 | ||
|
||
def test_list_reverse(): | ||
l1: list[i32] = [] | ||
l2: list[i32] = [] | ||
l3: list[f64] = [] | ||
l4: list[f64] = [] | ||
l5: list[str] = [] | ||
l6: list[str] = [] | ||
l7: list[str] = [] | ||
i: i32 | ||
j: f64 | ||
s: str | ||
|
||
l1 = [1, 2, 3] | ||
l1.reverse() | ||
assert l1 == [3, 2, 1] | ||
|
||
l1 = [] | ||
for i in range(10): | ||
l1.reverse() | ||
l1.append(i) | ||
l2.insert(0, i) | ||
l1.reverse() | ||
assert l1 == l2 | ||
|
||
j = 0.0 | ||
while j < 2.1: | ||
l3.reverse() | ||
l3.append(j) | ||
l4.insert(0, j) | ||
l3.insert(0, j + 1.0) | ||
l4.append(j + 1.0) | ||
l3.reverse() | ||
assert l3 == l4 | ||
j += 0.1 | ||
|
||
l5 = ["abcd", "efgh", "ijkl"] | ||
for s in l5: | ||
l6.reverse() | ||
l6.insert(0, s) | ||
l7.append(s) | ||
l6.reverse() | ||
assert l6 == l7 | ||
|
||
|
||
test_list_reverse() |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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