Files
pork/examples/syntax.pork

56 lines
865 B
Plaintext
Raw Normal View History

export func main() {
let three = 3
let two = 2
2023-09-02 20:22:08 -07:00
let calculateSimple = { in
2023-09-02 20:22:08 -07:00
(50 + three) * two
}
let calculateComplex = { in
2023-09-02 20:22:08 -07:00
three + two + 50
}
let multiply = { a, b in
2023-09-02 20:22:08 -07:00
a * b
}
// calculates the result
let calculateSimpleResult = calculateSimple()
let calculateComplexResult = calculateComplex()
let multiplyResult = multiply(50, 50)
2023-09-02 20:22:08 -07:00
let list = [10, 20, 30]
let trueValue = true
let falseValue = false
2023-09-02 20:22:08 -07:00
let invert = { value in
2023-09-02 20:22:08 -07:00
!value
}
let notEqual = { a, b in
2023-09-02 20:22:08 -07:00
a != b
}
let equal = { a, b in
2023-09-02 20:22:08 -07:00
a == b
}
let results = [
2023-09-02 20:22:08 -07:00
calculateSimpleResult,
calculateComplexResult,
multiplyResult,
list,
trueValue,
falseValue,
invert(true),
invert(false),
equal(5, 5),
equal(5, 6),
notEqual(5, 5),
notEqual(5, 6)
]
println("results:")
println(results)
2023-08-19 15:29:07 -07:00
}