Next: , Previous: , Up: Blocks   [Contents]


3.1.2 Combining Blocks

Multiple blocks can be combined into one new block using the combine-blocks function.

combine-blocks* is a wrapper around combine-blocks that automatically inserts its arguments into a list.

(define-block ruby-set-variables
  #:code "x = 400"
  #:language ruby)

(define-block ruby-print-x
  ;; Language may be omitted or the same.
  #:code "print x")

(block-result
 (run-block (combine-blocks*
             ruby-set-variables ruby-print-x))) ;=> "400"

Combining blocks takes the #:code field of each block and appends them together. The #:separator field of the parent is placed in between the two blocks, by default "\n".

Combining blocks also updates the #:subblocks field, which is discussed later.