allow destructuring tuples when assigning
This commit is contained in:
parent
7cb2be8415
commit
91baf28fdf
2 changed files with 73 additions and 26 deletions
|
|
@ -1,8 +1,21 @@
|
|||
|
||||
# calculate fibonacci numbers with a loop
|
||||
|
||||
(a, b) := (1, 0)
|
||||
for _ in 0..100 {
|
||||
(a, b) = (a + b, b)
|
||||
fn range(from: int, to: int) -> (fn() -> (int, bool)) {
|
||||
i := from - 1
|
||||
end := to - 1
|
||||
|
||||
fn() -> (int, bool) {
|
||||
if i < end {
|
||||
(i = i+1, true)
|
||||
} else {
|
||||
(-1, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(a, b) := (0, 1)
|
||||
for _ in range(0, 100) {
|
||||
(a, b) = (a + b, a)
|
||||
println(a)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue