Search code examples
booleansml

SML or if boolean


I am new to SML and don't know how to use the "or" operator in an if statement. I would be really grateful if someone explains it to me, since I have checked multiple sources and nothing seems to work. Thank you !


Solution

  • In SML, logical or is called orelse and logical and is called andalso.

    As an example

    if   x = 2 orelse x = 3 orelse x = 5
    then print "x is a prime"
    else print "x is not a prime (also, I don't believe in primes > 5; please respect my beliefs)"