chore: add examples
This commit is contained in:
6
examples/01_variables.peb
Normal file
6
examples/01_variables.peb
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
let var1 = 13
|
||||||
|
let var2 = "Hello"
|
||||||
|
let var3 = false
|
||||||
|
let var4 = var3
|
||||||
|
var4 = var2
|
||||||
|
var3 = null
|
||||||
5
examples/02_operations.peb
Normal file
5
examples/02_operations.peb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
let a = 4
|
||||||
|
let b = 5
|
||||||
|
let c = a + b
|
||||||
|
c *= 7
|
||||||
|
let d = (3.2 - 0.2) + 4 * 6 / 2
|
||||||
9
examples/03_comparisons.peb
Normal file
9
examples/03_comparisons.peb
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
let a = 5
|
||||||
|
let b = 7
|
||||||
|
|
||||||
|
let equal = a == b
|
||||||
|
let not_equal = a != b
|
||||||
|
let less = a < b
|
||||||
|
let more = a > b
|
||||||
|
let less_eq = a <= b
|
||||||
|
let more_eq = a >= b
|
||||||
18
examples/04_if_else.peb
Normal file
18
examples/04_if_else.peb
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
let age = 14
|
||||||
|
|
||||||
|
if age >= 18 {
|
||||||
|
print("You are an adult")
|
||||||
|
} else {
|
||||||
|
print("You are a child)
|
||||||
|
}
|
||||||
|
|
||||||
|
let guess = 12
|
||||||
|
let secret = 14
|
||||||
|
|
||||||
|
if guess == secret {
|
||||||
|
print("You guessed the secret !")
|
||||||
|
} else if guess < secret {
|
||||||
|
print("You're too low")
|
||||||
|
} else {
|
||||||
|
print("You're too high")
|
||||||
|
}
|
||||||
17
examples/05_loop.peb
Normal file
17
examples/05_loop.peb
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
for i from 1 to 5 {
|
||||||
|
print(i)
|
||||||
|
}
|
||||||
|
|
||||||
|
for j from 0 until 10 by 2 {
|
||||||
|
print(j)
|
||||||
|
}
|
||||||
|
|
||||||
|
for k to 4 {
|
||||||
|
print(k)
|
||||||
|
}
|
||||||
|
|
||||||
|
let l = 0
|
||||||
|
while l < 10 {
|
||||||
|
print(l)
|
||||||
|
l += 3
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user