Restyling; much reorganisation of documentation.
This commit is contained in:
parent
05e9daf662
commit
c15cd08159
17 changed files with 217 additions and 257 deletions
|
|
@ -3063,20 +3063,11 @@ further rules can be applied.</p>
|
|||
(cond
|
||||
(ifn? rule) (apply-rule cell world rule nil)
|
||||
(seq? rule) (let [[afn src] rule] (apply-rule cell world afn src))))
|
||||
;; {:afn afn :src src})))
|
||||
;; (apply-rule cell world (first rule) (first (rest rule)))))
|
||||
([cell world rule source]
|
||||
(try
|
||||
(let [result (apply rule (list cell world))]
|
||||
(cond
|
||||
(and result source) (merge result {:rule source})
|
||||
true result))
|
||||
(catch Exception e
|
||||
(merge cell {:error (format "%s at generation %d when in state %s"
|
||||
(.getMessage e)
|
||||
(:generation cell)
|
||||
(:state cell))
|
||||
:error-rule source})))))</pre></td></tr><tr><td class="docs"><p>Derive a cell from this cell of this world by applying these rules.</p>
|
||||
(let [result (apply rule (list cell world))]
|
||||
(cond
|
||||
(and result source) (merge result {:rule source})
|
||||
true result))))</pre></td></tr><tr><td class="docs"><p>Derive a cell from this cell of this world by applying these rules.</p>
|
||||
</td><td class="codes"><pre class="brush: clojure">(defn- apply-rules
|
||||
[cell world rules]
|
||||
(cond (empty? rules) cell
|
||||
|
|
@ -3095,15 +3086,16 @@ further rules can be applied.</p>
|
|||
(format "%s at generation %d when in state %s"
|
||||
(.getMessage e)
|
||||
(:generation cell)
|
||||
(:state cell))})))) </pre></td></tr><tr><td class="docs"><p>Return a row derived from this row of this world by applying these rules to each cell.</p>
|
||||
(:state cell))}))))</pre></td></tr><tr><td class="docs"><p>Return a row derived from this row of this world by applying these rules to each cell.</p>
|
||||
</td><td class="codes"><pre class="brush: clojure">(defn- transform-world-row
|
||||
[row world rules]
|
||||
(map #(transform-cell % world rules) row))</pre></td></tr><tr><td class="docs"><p>Return a world derived from this world by applying these rules to each cell.</p>
|
||||
(apply vector (map #(transform-cell % world rules) row)))</pre></td></tr><tr><td class="docs"><p>Return a world derived from this world by applying these rules to each cell.</p>
|
||||
</td><td class="codes"><pre class="brush: clojure">(defn transform-world
|
||||
[world rules]
|
||||
(map
|
||||
#(transform-world-row % world rules)
|
||||
world))</pre></td></tr><tr><td class="docs"><p>Consider this single argument as a map of <code>:world</code> and <code>:rules</code>; apply the rules
|
||||
(apply vector
|
||||
(map
|
||||
#(transform-world-row % world rules)
|
||||
world)))</pre></td></tr><tr><td class="docs"><p>Consider this single argument as a map of <code>:world</code> and <code>:rules</code>; apply the rules
|
||||
to transform the world, and return a map of the new, transformed <code>:world</code> and
|
||||
these <code>:rules</code>. As a side effect, print the world.</p>
|
||||
</td><td class="codes"><pre class="brush: clojure">(defn- transform-world-state
|
||||
|
|
@ -3486,7 +3478,7 @@ that every cell's :x and :y properties reflect its place in the matrix.</p>
|
|||
* `width` total width of the matrix, in cells;
|
||||
* `height` total height of the matrix, in cells."
|
||||
(cond (= index height) nil
|
||||
true (cons (make-world-row 0 width index)
|
||||
true (cons (apply vector (make-world-row 0 width index))
|
||||
(make-world-rows (+ index 1) width height))))</pre></td></tr><tr><td class="docs"><p>Make a world width cells from east to west, and height cells from north to
|
||||
south.</p>
|
||||
|
||||
|
|
@ -3496,7 +3488,7 @@ that every cell's :x and :y properties reflect its place in the matrix.</p>
|
|||
</ul>
|
||||
</td><td class="codes"><pre class="brush: clojure">(defn make-world
|
||||
[width height]
|
||||
(make-world-rows 0 width height))</pre></td></tr><tr><td class="docs"><p>Truncate the print name of the state of this cell to at most limit characters.</p>
|
||||
(apply vector (make-world-rows 0 width height)))</pre></td></tr><tr><td class="docs"><p>Truncate the print name of the state of this cell to at most limit characters.</p>
|
||||
</td><td class="codes"><pre class="brush: clojure">(defn truncate-state
|
||||
[cell limit]
|
||||
(let [s (:state cell)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue