47 lines
856 B
Plaintext
47 lines
856 B
Plaintext
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.
|