Sequencing instructions in Scheme

Benutzeravatar
sewe
Sonntagsinformatiker
Sonntagsinformatiker
Beiträge: 295
Registriert: 16. Jan 2009 14:53
Kontaktdaten:

Sequencing instructions in Scheme

Beitrag von sewe »

This question popped up several times: How to sequence instructions in Scheme? To do so, use the begin special form:

Code: Alles auswählen

(define x 1)
(begin
  (! x 2)
  x)
The above doesn't do much but it evaluates to 1, the value of x after the set!. (Note that the value of x is now 2 even outside the begin block.)

Zurück zu „Archiv“