match condition {
true => { ... }
false => { ... }
}
In fact you can create a language without if/else and pattern-matching, if you have something like first-class functions to handle branching. One notable example of such a language is lambda-calculus: true = λtf.t
false = λtf.f
if = λctf.ctf
Which in more familiar syntax is true = (t, f) => t()
false = (t, f) => f()
if = (c, t, f) => c(t, f)
And would evaluate like so if(true, workCorrectly, crashAndBurn)
==> true(workCorrectly)
==> workCorrectly()
However in practice, most high-level languages have if/else. Even lesser-known functional languages like Coq and Haskell which rely more on their pattern matching, still include it simply because it's convenient and easy to implement. Worst case, the compiler can (and sometimes does) just desugar the conditional into one of the above.
3 < 4 ifTrue: [ 'true' ] ifFalse: [ 'false' ]
But very arguably that is still if-then-else, it's just not a special construct in the language. Avoiding Boolean values is also sometimes better to convey intent more precisely ("Boolean blindness"), but that's just a stylistic thing and not forbidding Boolean values entirely.
You can, however, do away with else using unconditional branches - a.k.a. "goto". Pseudocode:
goto :positive if input > 0
goto :negative if input < 0
print "Got zero"
goto :end
:positive
print "Got a positive number"
goto :end
:negative
print "Got a negative number"
:end
Whether this is an improvement is questionable, but I've seen some industrial and enterprise systems with their own "graphical" languages that do this. I've also seen (in similar environments) the inverse where everything is an if/else (or pass/fail), like so: start: compare(input > 0) pass: positive fail: next
: compare(input < 0) pass: negative fail: next
: out("Got zero") pass: end fail: end
positive: out("Got positive") pass: end fail: end
negative: out("Got negative") pass: end fail: end
end: exit() pass: next fail: next
Generally, this type of refactoring converts code to a more declarative style: tell the computer what to do instead of how to do it (if-then-else): https://www.wikiwand.com/en/Declarative_programming
So you're probably looking for a declarative programming paradigm. (A single programming language can support multiple paradigms.)
def print(true), do: IO.puts("true")
def print(_), do: IO.puts("not true")
In fact it's typically best practice to do this. I almost never write if statements in elixir. It makes chaining much easier.
value |> change_1() |> change_2() |> print()
I mean you can sugar up if as "when" or "cond" or "unless," but unless you have conditional branching you won't really have logic within the program.
More philosophically, a language that doesn't have conditional branching will still be running on hardware that has it, so long as it is running on a computer.
Good luck.
(if predicate consequent alternate) might be missing in favour of only (if predicate consequent), or you might only have the variadic form (cond p0 c0 p1 c1 p2 c2 alternate).