forked from erg-lang/erg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request erg-lang#520 from GreasySlug/fix-comprehension
Fix List Comprehension Syntax
- Loading branch information
Showing
2 changed files
with
9 additions
and
1 deletion.
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 |
---|---|---|
@@ -1,13 +1,21 @@ | ||
l = [i | i <- 1..4] | ||
assert l == [1, 2, 3, 4] | ||
lc = [i * 2 | i <- 1..4] | ||
assert lc == [2, 4, 6, 8] | ||
lc2 = [i + 1 | i <- 1..5 | i <= 3] | ||
assert lc2 == [2, 3, 4] | ||
lc3 = [i <- 1..10 | i <= 5] | ||
assert lc3 == [1, 2, 3, 4, 5] | ||
lc4 = [i * 5 | i <- 1..15 | i <= 5] | ||
assert lc4 == [5, 10, 15, 20, 25] | ||
|
||
s = {i | i <- [1, 2, 1, 2]} | ||
assert s == {1, 2} | ||
sc = {i * 2 | i <- 1..4} | ||
assert sc == {2, 4, 6, 8} | ||
sc2 = {i + 1 | i <- 1..5 | i <= 3} | ||
assert sc2 == {2, 3, 4} | ||
sc3 = {i <- 1..10 | i <= 5} | ||
assert sc3 == {1, 2, 3, 4, 5} | ||
sc4 = {i % 5 | i <- 1..100 | i % 5 != 0} | ||
assert sc4 == {1, 2, 3, 4} |