diff options
| author | 2024-12-26 12:35:51 -0500 | |
|---|---|---|
| committer | 2024-12-26 12:35:51 -0500 | |
| commit | 370de2b95743b91b3d15fe0d93d84e06f1864ee4 (patch) | |
| tree | 2ba1940baa7a6580c61ee224bda45036dfec3836 /doc | |
cond-thunk
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/mcgoron.cond-thunk.scm | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/doc/mcgoron.cond-thunk.scm b/doc/mcgoron.cond-thunk.scm new file mode 100644 index 0000000..8f740da --- /dev/null +++ b/doc/mcgoron.cond-thunk.scm @@ -0,0 +1,58 @@ +(((name . "cond-thunk") + (signature syntax-rules (else) + ((_ clause ...))) + (subsigs (clause + (pattern + (expr clause ...) + (else expression1 expression2 ...))) + (expr (or (lambda () *) #f))) + (desc " +* It is an error if `expr` does not evaluate to a thunk or to `#f`. + +If `expr` evaluates to a thunk, then the thunk is tail-called as the +result of the expression. Otherwise the macro evalates the next clause. If +the `else` clause is reached, the expressions in the clause are evaluated +as the result of the expression. If there is no `else` clause and all +`expr` fail, then `cond-thunk` returns #f.")) + ((name . "any-thunk") + (signature case-lambda + ((list? thunks) *) + ((list? thunks) (procedure? else-thunk) *)) + (desc " +* It is an error if `thunks` is not a proper list of thunks that return + either `#f` or another thunk. +* It is an error if `else-thunk` isnot a thunk. + +This function is a procedural version of `cond-thunk`. + +Evaluate each `thunk` in `thunks` in order. If the `thunk` evaluates to +a thunk, the thunk is tail-called. Otherwise evaluate the next thunk in +the list. + +If all `thunks` evaluate to `#f`, then `else-thunk` is tail called. If +`else-thunk` is not supplied, the function returns `#f`.")) + ((name . "when-ct") + (signature syntax-rules ((_ conditional body ...))) + (desc " +* It is an error if `formal` is not a lambda formal. +* It is an error if `conditional` is not an expression. + +If `conditional` is true, return a thunk that when called executes +`body ...`. Otherwise return `#f`.")) + ((name . "lambda-ct") + (signature syntax-rules ((_ formal conditional body ...))) + (desc " +* It is an error if `formal` is not a lambda formal. +* It is an error if `conditional` is not an expression. + +Create a closure with arguments `formal` that evaluates `conditional`. +If `conditional` returns a truthy value, a thunk closure with +`body ...` as its body is returned. Otherwise the closure returns `#f`.")) + (name . "define-ct") + (signature syntax-rules ((_ (name . formal) conditional body ...))) + (desc " +* It is an error if `formal` is not a lambda formal. +* It is an error if `conditional` is not an expression. + +Define a procedure `name` as a conditional generating a thunk. See +`lambda-ct` for more details."))
\ No newline at end of file |
