Skip to content
Turtle Kitty edited this page Aug 7, 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.

(if foo?
    (seq
        (sys.print x)
        (set! x x.inc)
        x)
    x)) -> x

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