Control Structures
These are examples of control structures. You may also be interested in:

 Conditional structures
 Exceptions
 Flow-control structures
 Loops

Task

List the conditional structures offered by a programming language. See Wikipedia: conditionals for descriptions.

Common conditional structures include if-then-else and switch.

Less common are arithmetic if, ternary operator and Hash-based conditionals.

Arithmetic if allows tight control over computed gotos, which optimizers have a hard time to figure out.



go =>
  N = 10,
 
  % "direct" test that will fail if not satisfied
  N < 14,
 
  % if/then/elseif/else
  if N < 14 then
    println("less than 14")
  elseif N == 14 then
    println("is 14")
  else
    println("not less than 14")
  end,
 
  % From Prolog: (condition -> then ; else)
  ( N < 14 ->
   println("less than 14")
   ;
   println("not less than 14")
  ),
 
  % Ret = cond(condition, then, else)
  println(cond(N < 14, "less than 14", "not less than 14")),
 
  % as a predicate
  test_pred(N),
 
  % as condition in a function's head
  println(test_func(N)),
 
  println(ok), % all tests are ok
 
  nl.
 
% as a predicate
test_pred(N) ?=>
  N < 14,
  println("less than 14").
test_pred(N) =>
  N >= 14,
  println("not less than 14").
 
% condition in function head
test_func(N) = "less than 14", N < 14 => true.
test_func(_N) = "not less than 14" => true. 