mirror of
https://github.com/Dummi26/mers.git
synced 2026-01-26 10:47:04 +01:00
fixed examples
This commit is contained in:
@@ -10,7 +10,7 @@ fn print_linked_list(start elem) {
|
||||
println("[END]")
|
||||
true // break
|
||||
}
|
||||
elem start = elem // continue
|
||||
elem &start = elem // continue
|
||||
}
|
||||
}
|
||||
[]
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
list = [1 2 3 4 5 6 7 8 9 ...]
|
||||
|
||||
// second = &list.get_ref(2).assume1()
|
||||
// second.debug()
|
||||
// *second = 24
|
||||
// second.debug()
|
||||
|
||||
&list.get_ref(2).assume1() = 24
|
||||
should_not_be_changeable = &list.get(3).assume1()
|
||||
should_not_be_changeable = 24
|
||||
// calling get on an &list will get a reference
|
||||
&list.get(2).assume1() = 24
|
||||
// calling get on a list will get a value
|
||||
should_not_be_changeable = list.get(3).assume1()
|
||||
&should_not_be_changeable = 24
|
||||
|
||||
if list.get(2) != [24] println("[!!] list.get(2) != 24 (was {0})".format(list.get(2).to_string()))
|
||||
if list.get(3) == [24] println("[!!] list.get(3) == 24")
|
||||
|
||||
@@ -27,8 +27,8 @@ fn square_numbers() {
|
||||
i = 0
|
||||
val = 0
|
||||
() {
|
||||
val = val + { 2 * i } + 1
|
||||
i = i + 1
|
||||
&val = val + { 2 * i } + 1
|
||||
&i = i + 1
|
||||
[val]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,11 +12,10 @@ calculator = (max int) {
|
||||
sum = 0
|
||||
for i max {
|
||||
i = i + 1
|
||||
// println("i: {0}".format(i.to_string()))
|
||||
println("i: {0} s: {1}".format(i.to_string() sum.to_string()))
|
||||
sum = sum + i + 1
|
||||
// println("i: {0} s: {1}".format(i.to_string() sum.to_string()))
|
||||
&sum = sum + i
|
||||
if fake_delay sleep(1)
|
||||
v = i * 100 / max
|
||||
&progress = i * 100 / max
|
||||
}
|
||||
"the sum of all numbers from 0 to {0} is {1}!".format(max.to_string() sum.to_string())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user