www.delorie.com/gnu/docs/guile/r5rs_30.html   search  
 
Buy GNU books!


Revised(5) Scheme

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1.5 Conditionals

syntax: if <test> <consequent> <alternate>
syntax: if <test> <consequent>

Syntax: <Test>, <consequent>, and <alternate> may be arbitrary expressions.

Semantics: An `if' expression is evaluated as follows: first, <test> is evaluated. If it yields a true value (see section see section 6.3.1 Booleans), then <consequent> is evaluated and its value(s) is(are) returned. Otherwise <alternate> is evaluated and its value(s) is(are) returned. If <test> yields a false value and no <alternate> is specified, then the result of the expression is unspecified.

 
(if (> 3 2) 'yes 'no)                  ==>  yes
(if (> 2 3) 'yes 'no)                  ==>  no
(if (> 3 2)
    (- 3 2)
    (+ 3 2))                           ==>  1


  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003