let-values -- r7rs Definition syntax;
let-values (from vonuvoli);Syntax keywords:
variable: identifier;initializer: identifier;binding: pattern with variants:
((variable |...|) initializer);bindings: pattern with variants:
();(binding |...|);expression: expression;Syntax variants:
(_ bindings)(_ bindings expression |...|)scheme:base -- (scheme base);scheme -- (scheme);(let-values <mv-binding-spec> <body>)Syntax:
<Mv-binding-spec>has the form((<formals_1> <init_1>) ...)where each
<init>is an expression, and<body>is zero or more definitions followed by a sequence of one or more expressions as described in section onlambda. It is an error for a variable to appear more than once in the set of<formals>.Semantics: The
<init>s are evaluated in the current environment (in some unspecified order) as if by invokingcall-with-values, and the variables occurring in the<formals>are bound to fresh locations holding the values returned by the<init>s, where the<formals>are matched to the return values in the same way that the<formals>in alambdaexpression are matched to the arguments in a procedure call. Then, the<body>is evaluated in the extended environment, and the values of the last expression of<body>are returned. Each binding of a<variable>has<body>as its region.It is an error if the
<formals>do not match the number of values returned by the corresponding<init>.(let-values (((root rem) (exact-integer-sqrt 32))) (* root rem)) ===> 35
The text herein was sourced and adapted as described in the "R7RS attribution of various text snippets" appendix.