Conway's Game of Life: Difference between revisions

added Ursala
m (→‎{{header|Mathematica}}: Scrolled output.)
(added Ursala)
Line 1,687:
. . . . .</pre>
 
=={{header|Ursala}}==
 
Three functions are defined:
rule takes a pair (c,<n..>) representing a cell and its neighborhood to the new cell,
neighborhoods takes board of cells <<c..>..> to a board <<(c,<n..>)..>..> with neighborhoods,
and evolve(n) takes a board <<c..>..> to a sequence of n boards evolving from it.
 
<lang Ursala>
#import std
#import nat
 
rule = -: (^/~& ^|(~&,length@F); ~&l?/~&r-={2,3} ~&r-={3})*T ~&brlD@G\(0,&) ~&rSS zipp0*ziD iota256
 
neighborhoods = ~&thth3hthhttPCPthPTPTX**K7S+ swin3**+ swin3@hNSPiCihNCT+ --<0>*+ 0-*
 
evolve "n" = @iNC ~&x+ rep"n" ^C\~& rule**+ neighborhoods@h</lang>
test program:
<lang Ursala>blinker =
 
(==`O)**t -[
+++
OOO
+++]-
 
glider =
 
(==`O)**t -[
+O++++
++O+++
OOO+++
++++++
++++++]-
 
#show+
 
examples = mat0 ~&?(`O!,`+!)*** evolve2(blinker)-- evolve4(glider)</lang>
output:
<pre style="height:30ex;overflow:scroll">+++
OOO
+++
 
+O+
+O+
+O+
 
+++
OOO
+++
 
+O++++
++O+++
OOO+++
++++++
++++++
 
++++++
O+O+++
+OO+++
+O++++
++++++
 
++++++
++O+++
O+O+++
+OO+++
++++++
 
++++++
+O++++
++OO++
+OO+++
++++++
 
++++++
++O+++
+++O++
+OOO++
++++++</pre>
=={{header|Vedit macro language}}==
 
Anonymous user