What's the equivalent of Clojure's "do" in Common Lisp?
Asked Answered
R

1

15

That is, a form that evaluates child forms in order and returns the last evaluated value,e.g.

(do (println "Hello World") 3) => 3
Rotifer answered 19/11, 2012 at 9:54 Comment(0)
I
36

It's called progn.

Special Operator PROGN

Syntax:

progn form* ⇒ result*

Description:

progn evaluates forms, in the order in which they are given.

The values of each form but the last are discarded.

Ivanaivanah answered 19/11, 2012 at 9:57 Comment(1)
About the name: It's called progn because it returns the value of the nth form. There's also prog1 that returns the value of the first form. (And even prog2 that returns the value of the second form, though it's hardly ever used!)Harlanharland

© 2022 - 2024 — McMap. All rights reserved.