mirror of
https://github.com/GayPizzaSpecifications/pork.git
synced 2025-08-03 05:10:55 +00:00
If Statement Support
This commit is contained in:
8
examples/fib.pork
Normal file
8
examples/fib.pork
Normal file
@ -0,0 +1,8 @@
|
||||
fib = { n in
|
||||
if n == 0
|
||||
then 0
|
||||
else if n == 1
|
||||
then 1
|
||||
else fib(n - 1) + fib(n - 2)
|
||||
}
|
||||
main = { in fib(20) }
|
@ -1,14 +1,18 @@
|
||||
main = {
|
||||
main = { in
|
||||
three = 3
|
||||
two = 2
|
||||
calculateSimple = {
|
||||
calculateSimple = { in
|
||||
(50 + three) * two
|
||||
}
|
||||
calculateComplex = {
|
||||
calculateComplex = { in
|
||||
three + two + 50
|
||||
}
|
||||
multiply = { a, b in
|
||||
a * b
|
||||
}
|
||||
calculateSimpleResult = calculateSimple()
|
||||
calculateComplexResult = calculateComplex()
|
||||
multiplyResult = multiply(50, 50)
|
||||
|
||||
list = [10, 20, 30]
|
||||
trueValue = true
|
||||
@ -17,6 +21,7 @@ main = {
|
||||
[
|
||||
calculateSimpleResult,
|
||||
calculateComplexResult,
|
||||
multiplyResult,
|
||||
list,
|
||||
trueValue,
|
||||
falseValue
|
||||
|
Reference in New Issue
Block a user