main
parent
b2fa9ad7e7
commit
833296693b
Binary file not shown.
|
@ -1,5 +0,0 @@
|
||||||
var x,y,z :int
|
|
||||||
x = 10
|
|
||||||
y = 25
|
|
||||||
z = x + y
|
|
||||||
echo "sum of ", x, " and ", y, " is ", z
|
|
Binary file not shown.
|
@ -1,37 +0,0 @@
|
||||||
proc plus(x, y: int): int = x + y
|
|
||||||
proc multi(x, y: int): int = x * y
|
|
||||||
|
|
||||||
let a = 2
|
|
||||||
let b = 3
|
|
||||||
let c = 4
|
|
||||||
|
|
||||||
echo a.plus(b) == plus(a, b) # True
|
|
||||||
echo c.multi(a) == multi(c, a) # True
|
|
||||||
|
|
||||||
# Verketteter Aufruf
|
|
||||||
echo a.plus(b).multi(c) # (2 + 3) * 4 = 20
|
|
||||||
|
|
||||||
# Alternativ
|
|
||||||
echo multi((a.plus(b)), c) # (2 + 3) * 4 = 20
|
|
||||||
|
|
||||||
|
|
||||||
proc findBiggest(a: seq[int]): int =
|
|
||||||
# result = 0
|
|
||||||
for number in a:
|
|
||||||
if number > result:
|
|
||||||
result = number
|
|
||||||
# Ende der proc
|
|
||||||
|
|
||||||
let d = @[3, -5, 11, 33, 7, -15]
|
|
||||||
echo findBiggest(d)
|
|
||||||
|
|
||||||
proc toString(x: int): string =
|
|
||||||
result = if x < 0: "negativ"
|
|
||||||
elif x > 0: "positiv"
|
|
||||||
else: "Null"
|
|
||||||
|
|
||||||
proc toString(x: bool): string =
|
|
||||||
result = if x: "ja" else: " ein"
|
|
||||||
|
|
||||||
echo toString(13) # "positiv"
|
|
||||||
echo toString(true) # "ja"
|
|
Binary file not shown.
|
@ -1 +0,0 @@
|
||||||
echo "Hallo Welt"
|
|
Loading…
Reference in New Issue