This file contains 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
type←{ | |
''≡0↑⍵:'str' ⍝ if the first zero items are the empty string, this is a string. | |
⍬≢⍴⍵:'list' ⍝ if it is not a string, but it has more than zero dimensions, it is a list. | |
⍵=⌈⍵:'int' ⍝ if it is equal to its ceiling, it can be considered an int. | |
⍝ (there is literally no way to tell the difference between 1 and 1.0 in APL.) | |
'float' ⍝ if it isn't one of the above, it must then be a float. | |
} | |
round←{ | |
0::1 ⍝ if something goes wrong, return 1 |
This file contains 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
amoeba←{ | |
idx←,⍳⍴field←' '⍴⍨2/size←⌈4×0.5*⍨(+/!⍳⍵)÷○1 | |
field[G;G←⌈size÷2]←'0' | |
_←{ | |
prevs←idx/⍨,field=⍕⍵-1 | |
⍵∘{ | |
⍵∘{ | |
free←idx/⍨,field=' ' | |
+((⊃free[⍋+/¨|free-⊂⍺])⌷field)←⍕⍵ | |
}¨⍺/⍺ |