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.
- Loading branch information
1 parent
1d5a7e7
commit b661d10
Showing
3 changed files
with
30 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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from lpython import i32, Callable | ||
|
||
|
||
def f(x: i32) -> i32: | ||
return x + 1 | ||
|
||
def f2(x: i32) -> i32: | ||
return x + 10 | ||
|
||
def f3(x: i32) -> i32: | ||
return f(x) + f2(x) | ||
|
||
|
||
def g(func: Callable[[i32], i32], arg: i32) -> i32: | ||
ret: i32 | ||
ret = func(arg) | ||
return ret | ||
|
||
|
||
def check(): | ||
assert g(f, 10) == 11 | ||
assert g(f2, 20) == 30 | ||
assert g(f3, 5) == 21 | ||
|
||
|
||
check() |
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