mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-28 04:09:05 +00:00
feat: (partial) comprehension support
This commit is contained in:
parent
482f22374b
commit
3fd66f1a32
14 changed files with 483 additions and 158 deletions
|
@ -204,3 +204,30 @@ opened in a binary mode.
|
|||
newline := Str or NoneType,
|
||||
closefd := Bool,
|
||||
) => File!
|
||||
|
||||
'''
|
||||
Convert `iterable` into an array.
|
||||
'''
|
||||
'''erg
|
||||
assert array() == []
|
||||
assert array((1, 2)) == [1, 2]
|
||||
'''
|
||||
.array: |T| (iterable := Iterable(T)) -> [T; _]
|
||||
|
||||
'''
|
||||
Convert `iterable` into a dict.
|
||||
'''
|
||||
'''erg
|
||||
assert dict() == {:}
|
||||
assert dict([("a", 1), ("b": 2)]) == {"a": 1, "b": 2}
|
||||
'''
|
||||
.dict: |K, V| (iterable := Iterable((K, V))) -> {K: V}
|
||||
|
||||
'''
|
||||
Convert `iterable` into a set.
|
||||
'''
|
||||
'''erg
|
||||
assert set() == {}
|
||||
assert set([1, 2]) == {1, 2}
|
||||
'''
|
||||
.set: |T| (iterable := Iterable(T)) -> {T; _}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue