forked from lcompilers/lpython
-
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 lcompilers#1653 from harshsingh-24/dict-funcs
Initial Support for Global Dictionaries
- Loading branch information
Showing
3 changed files
with
30 additions
and
0 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,21 @@ | ||
from lpython import i32 | ||
|
||
# GLOBAL Dictionary | ||
x: dict[i32, i32] | ||
x = {0 : 0, 1: 1000, 2: 2000, 3 : 3000} | ||
|
||
x[4] = 4000 | ||
assert len(x) == 5 | ||
x[5] = 5000 | ||
assert x[2] == 2000 | ||
i: i32 | ||
for i in range(len(x)): | ||
assert x[i] == i * 1000 | ||
|
||
# Copy of Dictionary | ||
tmp: dict[i32, i32] | ||
tmp = x | ||
tmp[6] = 6000 | ||
assert len(tmp) == 7 | ||
assert tmp[6] == 6000 | ||
assert tmp[1] == 1000 |
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