-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
9 changed files
with
227 additions
and
9 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,26 @@ | ||
fun main() -> Int { | ||
if 1000 > 100 { | ||
42 | ||
} | ||
|
||
100 | ||
} | ||
|
||
fun another() -> Int { | ||
if 100 > 1000 { | ||
assert true; | ||
} | ||
} | ||
|
||
fun yet_another() -> Int { | ||
if 100 > 1000 { | ||
assert true; | ||
assert false; | ||
assert false; | ||
} | ||
100 | ||
} | ||
|
||
fun raise_ok() -> Int { | ||
raise; | ||
} |
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,11 @@ | ||
type A = B; | ||
type B = C; | ||
type C = D; | ||
type D = A; | ||
|
||
type E = F; | ||
type F = E; | ||
|
||
fun main() -> A { | ||
true | ||
} |
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,23 @@ | ||
fun main() -> Int { | ||
a(5) | ||
} | ||
|
||
fun a(num: Int) -> Int { | ||
if num > 0 { | ||
b(num - 1) | ||
} else { | ||
c() | ||
} | ||
} | ||
|
||
fun b(num: Int) -> Int { | ||
if num > 0 { | ||
a(num - 1) | ||
} else { | ||
0 | ||
} | ||
} | ||
|
||
fun c() -> Int { | ||
52 | ||
} |
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,19 @@ | ||
fun main(value: Int) -> Int { | ||
fun inner_1(num: Int) -> Int { | ||
outer_1() * value + num | ||
} | ||
|
||
fun inner_2(num: Int) -> Int { | ||
outer_2(num, inner_1) | ||
} | ||
|
||
outer_1() + inner_1(inner_2(value)) * outer_2(value, inner_2) | ||
} | ||
|
||
fun outer_1() -> Int { | ||
96 | ||
} | ||
|
||
fun outer_2(num: Int, closure: fun(num: Int) -> Int) -> Int { | ||
num * closure(num) | ||
} |
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,8 @@ | ||
fun main() -> Int { | ||
let a = [1, 2, 3]; | ||
let b = [4, 5, 6]; | ||
|
||
assume !(a is Nil) && !(b is Nil); | ||
|
||
a.first + b.first | ||
} |
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,8 +1,57 @@ | ||
fun main() -> Int { | ||
let a = [1, 2, 3]; | ||
let b = [4, 5, 6]; | ||
let items = [1, 2, 3]; | ||
let bytes = "Hello, world!"; | ||
sum(...items) + (bytes is Bytes32) as Int | ||
} | ||
|
||
fun sum(...nums: Int[]) -> Int { | ||
if nums is (Int, Int[]) { | ||
nums.first + sum(...nums.rest) | ||
} else { | ||
0 | ||
} | ||
} | ||
|
||
fun bytes_guard(value: Any) -> Bool { | ||
if value is Bytes { | ||
value.length > 1 | ||
} else { | ||
false | ||
} | ||
} | ||
|
||
assume !(a is Nil) && !(b is Nil); | ||
fun bytes32_guard(value: Any) -> Bool { | ||
assert value is Bytes; | ||
|
||
if value is Bytes32 { | ||
value.length > 1 | ||
} else { | ||
false | ||
} | ||
} | ||
|
||
fun public_key_guard(value: Any) -> Bool { | ||
assert value is Bytes; | ||
|
||
if value is PublicKey { | ||
value.length > 1 | ||
} else { | ||
false | ||
} | ||
} | ||
|
||
fun inverted_guard(value: Any) -> Bool { | ||
if !(value is (Any, Any)) { | ||
value.length > 1 | ||
} else { | ||
false | ||
} | ||
} | ||
|
||
a.first + b.first | ||
fun pair_guard(value: Any) -> Int { | ||
if value is (Any, Any) { | ||
pair_guard(value.first) + pair_guard(value.rest) | ||
} else { | ||
value as Int | ||
} | ||
} |
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,15 @@ | ||
fun main() -> Int { | ||
let empty = []; | ||
let empty_hinted: Int[] = empty; | ||
|
||
let items = [1, 2, 3]; | ||
let items_hinted: Int[] = items; | ||
|
||
let spread = [...items]; | ||
let spread_hinted: Int[] = [...items]; | ||
|
||
let prepend = [0, ...items]; | ||
let prepend_hinted: Int[] = [0, ...items]; | ||
|
||
items[0] + items_hinted[1] + spread[2] + spread_hinted[0] + prepend[1] + prepend_hinted[2] | ||
} |
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,6 @@ | ||
fun main() -> Int { | ||
let pair = (20, 24); | ||
let pair_hinted: (Int, Int) = pair; | ||
|
||
pair.first + pair.rest + pair_hinted.first + pair_hinted.rest | ||
} |