This site is a static rendering of the Trac instance that was used by R7RS-WG1 for its work on R7RS-small (PDF), which was ratified in 2013. For more information, see Home. For a version of this page that may be more recent, see ConditionalProceduresSamizdat in WG2's repo for R7RS-large.

Conditional­Procedures­Samizdat

cowan
2014-12-23 03:34:59
3history
source

These are Scheme procedures that correspond to basic syntax. They are derived from the If class of Samizdat.

(begin-procedure thunk ...)

Invokes thunks in order, and returns what the last thunk returns, or an unspecified value if there are no thunks.

(if-procedure value then-thunk [ else-thunk ])

If value is true, invokes then-thunk and returns what it returns. Otherwise, invokes else-thunk and returns what it returns, or if else-thunk is not specified, returns an unspecified value.

(if-not-procedure value else-thunk)

If value is true, returns an unspecified value. Otherwise, invokes else-thunk and returns what it returns.

(value-procedure value then-proc else-thunk)

If value is true, invokes then-proc on it and returns what then-proc returns. Otherwise, invokes else-thunk and returns what it returns.

(case-procedure value thunk-alist [ else-thunk ])

Searches thunk-alist for value (as if by assv). If there is no such entry in thunk-alist, invokes else-thunk and returns what it returns, or returns an unspecified value if else-thunk is not provided. If there is a matching entry in thunk-alist, its cdr is invoked as a thunk, and case-procedure returns what the thunk returns.

(and-procedure thunk ...)

Invokes each thunk in the order given, and returns #f immediately if any of them return #f. Otherwise returns the value of the last thunk, or #t if there are none.

(or-procedure thunk ...)

Invokes each thunk in the order given, and if any of them returns true, or-procedure returns that value immediately. Otherwise returns #f.

(loop-procedure thunk)

Invokes thunk repeatedly. Does not return.

(while-procedure thunk)

Invokes thunk repeatedly until it returns #f. Returns an unspecified value.