Created
February 2, 2020 09:59
-
-
Save LdBeth/fef316fefb3deda801b56f6639a6d1d8 to your computer and use it in GitHub Desktop.
APL plot code for A New Kind of Science
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
acc ← {⍺←1 ⋄ ((⊢⍪(⍺⍺∘,¯1↑⊢))⍣⍺)⍵} | |
cell ← {((⍺⍺ ⍵⍵⊢)⌺3)⍵} | |
code ← {⎕IO←0 ⋄ (+/⍵)⌷⌽(7⍴3)⊤⍺} | |
expnd ← {(,⍉↑⍺)/,¯1 0 1(+⍤0 1)⍵} | |
gmob ← {⍵ snap⍨(⊂L),↓⍉↑(⍺⍺ ⍵⍵ ⍵⌷⍨∘⊂¯1 0 1∘+)¨L←⍸1<⍵} | |
gr ← {(A rule P)(B patn P)⊣A B←⍺⊣P←2|⍵} | |
initi ← {⍺←1 ⋄ ,[⎕IO-0.5]A,⍺,A←⍵⍴0} | |
mcomp ← {((⌽⍣(B rule P))0 0 2)+(⊃A B←⍺)patn⊢P←⍵-0 2 0} | |
mobile ← {((⍺⍺ ⍵⍵ ⍵⌷⍨⊂P)@P)⍵⊣P←¯1 0 1+⍸1<⍵} | |
msimp ← {((⌽⍣A)0 0 2)+(B@2)P⊣A B←⍺ rule¨⊂P←⍵-0 2 0} | |
patn ← {⎕IO←0 ⋄ (3⍴2)⊤(2⊥⍵)⌷⌽⍺} | |
pbm ← {'P1'(⍕⌽⍴⍵),⍕¨↓⍵} | |
pgm ← {'P2'(⍕⌽⍴⍵)(⍕M),⍕¨↓⍵-⍨M←⌈/,⍵} | |
rule ← {⎕IO←0 ⋄ (2⊥⍵)⌷⌽(8⍴2)⊤⍺} | |
snap ← {(2∘+@(X expnd L))(C@L)2|⍵⊣L C X←⍺} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment