Assignments

(set! {variable} {expression} ) syntax

Semantics: Expression is evaluated, and the resulting value is stored in the location to which variable is bound. It is an error if variable is not bound either in some region enclosing the set! expression or else globally. The result of the set! expression is unspecified.

(define x 2) (+ x 1) ==> 3 (set! x 4) ==> unspecified (+ x 1) ==> 5

Note that Husk will return the value of the expression evaluated by set!. This is not standard and may not be portable to other Schemes.

husk-scheme online documentation rev 3.2 (2021.03.04)