all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
2
Task/Variables/E/variables-1.e
Normal file
2
Task/Variables/E/variables-1.e
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
def x := 1
|
||||
x + x # returns 2
|
||||
3
Task/Variables/E/variables-2.e
Normal file
3
Task/Variables/E/variables-2.e
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
def var x := 1
|
||||
x := 2
|
||||
x # returns 2
|
||||
7
Task/Variables/E/variables-3.e
Normal file
7
Task/Variables/E/variables-3.e
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
def var x := 1
|
||||
x += 1 # equivalent to x := x + 1, or x := x.add(1)
|
||||
x # returns 2
|
||||
|
||||
def var list := ["x"]
|
||||
list with= "y" # equivalent to list := list.with("y")
|
||||
list # returns ["x", "y"]
|
||||
1
Task/Variables/E/variables-4.e
Normal file
1
Task/Variables/E/variables-4.e
Normal file
|
|
@ -0,0 +1 @@
|
|||
def [hair, eyes, var shirt, var pants] := ["black", "brown", "plaid", "jeans"]
|
||||
1
Task/Variables/E/variables-5.e
Normal file
1
Task/Variables/E/variables-5.e
Normal file
|
|
@ -0,0 +1 @@
|
|||
[shirt, pants] := ["white", "black"] # This does not do anything useful.
|
||||
2
Task/Variables/E/variables-6.e
Normal file
2
Task/Variables/E/variables-6.e
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
def list := [def x := timer.now(), x] # two copies of the current time
|
||||
list[0] == x # x is still visible here; returns true
|
||||
10
Task/Variables/E/variables-7.e
Normal file
10
Task/Variables/E/variables-7.e
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
def makeSum() {
|
||||
var a := 0
|
||||
var b := 0
|
||||
return [&a, &b, fn { a + b }]
|
||||
}
|
||||
|
||||
def [&x, &y, sum] := makeSum()
|
||||
x := 3
|
||||
y := 4
|
||||
sum() # returns 7
|
||||
8
Task/Variables/E/variables-8.e
Normal file
8
Task/Variables/E/variables-8.e
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
def getUniqueId(&counter) {
|
||||
counter += 1
|
||||
return counter
|
||||
}
|
||||
|
||||
var idc := 0
|
||||
getUniqueId(&idc) # returns 1
|
||||
getUniqueId(&idc) # returns 2
|
||||
Loading…
Add table
Add a link
Reference in a new issue