View Problem

Perform different actions depending on a boolean condition (IF .. THEN .. ELSE)

Given a variable age, if the value is greater than 42 display "You are old", otherwise display "You are young"
DiskEdit
python
if age > 42:
print 'You are old'
else:
print 'You are young'
DiskEdit
python
print age > 42 and 'You are old' or 'You are young'
DiskEdit
clojure clojure
(def age 41)
(if (> age 42) "You are old" "You are young")
ExpandDiskEdit
erlang
if Age > 42 -> io:format("You are old~n") ; true -> io:format("You are young~n") end.
ExpandDiskEdit
erlang
Message = if Age > 42 -> "old" ; true -> "young" end, io:format("You are ~s~n", [Message]).
ExpandDiskEdit
erlang
case Age > 42 of true -> io:format("You are old~n") ; false -> io:format("You are young~n") end.
ExpandDiskEdit
erlang
case Age of _ when Age > 42 -> io:format("You are old~n") ; _ -> io:format("You are young~n") end.
ExpandDiskEdit
erlang
Message = case Age of _ when Age > 42 -> "old" ; _ -> "young" end, io:format("You are ~s~n", [Message]).
ExpandDiskEdit
erlang
Age > 42 andalso (begin io:format("You are old~n"), true end) orelse (begin io:format("You are young~n"), true end).
ExpandDiskEdit
erlang
(fun (X) when X > 42 -> io:format("You are old~n"); (_) -> io:format("You are young~n") end)(Age).
ExpandDiskEdit
erlang
(fun () when Age > 42 -> io:format("You are old~n"); () -> io:format("You are young~n") end)().
ExpandDiskEdit
erlang
io:format("You are ~s~n", [if Age > 42 -> "old" ; true -> "young" end]).
ExpandDiskEdit
fantom
if (age > 42)
echo("You are old")
else
echo("You are young")
ExpandDiskEdit
fantom
echo((age > 42) ? "You are old" : "You are young")

Submit a new solution for python, clojure, erlang, or fantom
There are 21 other solutions in additional languages (cpp, csharp, fsharp, groovy ...)