1.2.0 permalink Arrow_down_16x16
  • (cell type & data)
Build a standard cell, like this:

(cell fred
(* ?mary ?joe))

Which creates a cell named fred that is the product of a cell mary and cell joe

Or:

(cell joe
(apply * ?*sally))

Which creates a cell that applies * to the collection of all cells named sally

Or:

(cell :source fred 0)

Which builds a source cell fred with initial value 0

Or:

(cell :validator (when (< ?fred ?sally)
(throwf "%s must be greater than %s" ?fred ?sally))

Which will perform the validation

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/contrib/dataflow.clj:305 top

(defmacro cell
  "Build a standard cell, like this:

    (cell fred
       (* ?mary ?joe))

   Which creates a cell named fred that is the product of a cell mary and cell joe

   Or:

    (cell joe
      (apply * ?*sally))

   Which creates a cell that applies * to the collection of all cells named sally

   Or:

    (cell :source fred 0)

   Which builds a source cell fred with initial value 0

   Or:

     (cell :validator (when (< ?fred ?sally)
                          (throwf \"%s must be greater than %s\" ?fred ?sally))

   Which will perform the validation"
  [type & data]
  (cond
   (symbol? type) (let [name type ; No type for standard cell
                        expr (first data) ; we ignore extra data!
                        deps (get-deps expr)
                        fun (build-fun expr)]
                    `(build-standard-cell '~name ~deps ~fun '~expr))
   (= type :source) (let [[name init] data]
                      `(build-source-cell '~name ~init))
   (= type :validator) (let [[expr] data
                             deps (get-deps expr)
                             fun (build-fun expr)]
                         `(build-validator-cell ~deps ~fun '~expr))))
Vars in clojure.contrib.dataflow/cell: = cond defmacro let name symbol? type concat list seq
Used in 0 other vars

Comments top

No comments for cell. Log in to add a comment.