allow for one-line if and else bodies without {}

This commit is contained in:
r4
2021-12-26 19:18:52 +01:00
parent 46e7487cad
commit cda56d5b9c
3 changed files with 25 additions and 13 deletions

View File

@@ -10,13 +10,12 @@ if (!(op == "+" || op == "-" || op == "*" || op == "/")) {
n2 := float(getln())
put("Result: ")
if (op == "+") {
if (op == "+")
putln(n1 + n2)
} else if (op == "-") {
else if (op == "-")
putln(n1 - n2)
} else if (op == "*") {
else if (op == "*")
putln(n1 * n2)
} else if (op == "/") {
else if (op == "/")
putln(n1 / n2)
}
}

View File

@@ -65,19 +65,18 @@ while y < height {
it = it + 1
}
if it <= iterations / 5 {
if it <= iterations / 5
put(' ')
} else if it <= iterations / 5 * 2 {
else if it <= iterations / 5 * 2
put('.')
} else if it <= iterations / 5 * 3 {
else if it <= iterations / 5 * 3
put(',')
} else if it <= iterations / 5 * 4 {
else if it <= iterations / 5 * 4
put('*')
} else if it < iterations {
else if it < iterations
put('+')
} else if it == iterations {
else if it == iterations
put('#')
}
x = x + 1
}