File: if

package info (click to toggle)
scheme9 2025.08.12-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,080 kB
  • sloc: lisp: 16,752; ansic: 11,869; sh: 806; makefile: 237; sed: 6
file content (18 lines) | stat: -rw-r--r-- 701 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
R4RS 4.1.5  (if <test> <consequent> <alternate>)  ==>  object
            (if <test> <consequent>)              ==>  object

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.1 Booleans), then <consequent> is evaluated and its value is
returned. Otherwise <alternate> is evaluated and its value is
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