Skip to main content
3 of 10
-6 combine 2 maps into 1
luser droog
  • 5k
  • 2
  • 37
  • 61

inca2 129 123

This mostly uses the formulas from the python example, but using jot-dots and iotas instead of double-looping. The i function performs the circular test for the j function which invokes jot-dot upon it. And the k function performs the triangle test for the l function. The c function catenates the results of j and l and reshapes it to N×N.

edit: -6 combine 2 maps into 1.

i:[((n%2)^2)>((x-(n-1)%2)^2)+(y-(n-1)%2)^2 j:,(~[y%2)i.(~y) k:2*[x>[|y-(n-1)%2 l:,(@1+~]y%2)k.(~y) c:y y#((jn<y),ly){' (V' 

In action (pasting the program into the REPL).

./inca2 i:[((n%2)^2)>((x-(n-1)%2)^2)+(y-(n-1)%2)^2 j:(,(~[y%2)i.(~y)){' (' k:[(x)>[|y-(n-1 )%2 l:(,(@1+~]y %2)k.(~y)){' V' c:y y#(jn<y) ,ly c1 V c2 (( VV c3 ((( VVV V c4 (( (((( VVVV VV c5 ((( ((((( VVVVV VVV V c6 (((( (((((( (((((( VVVVVV VVVV VV 
luser droog
  • 5k
  • 2
  • 37
  • 61