Simple Conditional Expressions

Try:
if 1<2
then 5
else 6;
Hope replies:
>> 5 : num

Now try:

if 1>2
then 5
else 6;
This time Hope replies:
>> 6 : num
These are conditional expressions. Hope first evaluates the boolean expression after the key word if. If it evaluates to true, Hope goes on to evaluate the then expression. If it evaluates to false, then Hope evaluates the else expression.



Subsections

s.danicic@gold.ac.uk
Sebastian Danicic BSc MSc PhD (Reader in Computer Science)
Dept of Computing, Goldsmiths, University of London, London SE14 6NW
Last updated 2010-12-29