Prev Up Next

Like all languages, Scheme provides conditionals. The basic form is the if:

(if test-expression

If test-expression evaluates to true (ie, any value other than #f), the then-expression is evaluated. If not, the else-expression is evaluated. else-expression is optional.

(if (= (+ 2 3) 5)
=> schemes-addition-works!

(if (< 3 2)
=> three-isnt-less-than-two

Scheme provides some other conditional forms for convenience. They can all be defined as macros (chap 8) that expand into if-expressions.

Prev Up Next

Log in or register to write something here or to contact authors.