Skip to content
Turtle Kitty edited this page Oct 6, 2015 · 4 revisions

seq

This is used to execute a set of expressions in order, returning the last one. Its primary use is for side effects. Since functions, operators, and derived control structures (like let) have an implied seq, this operator is primarily of use in conditionals, which expect consequents and alternatives to be single expressions.

(def x 1)
(def y 2)

(if true
    (seq
        (sys.print x)
        (set! x x.inc)
        x)
    x)
1
-> 2

(cond
    0 (foo x y)
    "" (bar (+ x y))
    1 (seq (sys.print (+ x y)) "BAZZED!"))
4
-> "BAZZED!"
Clone this wiki locally