Sierpinski carpet: Difference between revisions
Content added Content deleted
(→{{header|Nascom BASIC}}: Added) |
m (J: remove failing golfed code, and clean up presentation slightly) |
||
Line 3,149: | Line 3,149: | ||
That said, using spaces and '#' characters takes a bit more work. One approach would be: |
That said, using spaces and '#' characters takes a bit more work. One approach would be: |
||
<lang j> |
<lang j> |
||
' #'{~(#:7 5 7) ,/@(1 3 ,/"2@|: */)^: |
scarp=:{{' #'{~(#:7 5 7) ,/@(1 3 ,/"2@|: */)^:y ,.1}} |
||
scarp 2 |
|||
######### |
######### |
||
# ## ## # |
# ## ## # |
||
Line 3,160: | Line 3,161: | ||
# ## ## # |
# ## ## # |
||
######### |
######### |
||
N=:3 |
|||
scarp 3 |
|||
' #'{~(#:7 5 7) ,/@(1 3 ,/"2@|: */)^:N ,.1 |
|||
########################### |
########################### |
||
# ## ## ## ## ## ## ## ## # |
# ## ## ## ## ## ## ## ## # |
||
Line 3,191: | Line 3,192: | ||
Here, what we are doing is forming a tensor product of our #:7 5 7 boolean array with our argument and then collapsing two of the dimensions so they line up right. Our starting argument is the 1 by 1 array with the value 1. Once we have repeated this process enough times, we select spaces for our zeros and pound signs for our 1s. |
Here, what we are doing is forming a tensor product of our #:7 5 7 boolean array with our argument and then collapsing two of the dimensions so they line up right. Our starting argument is the 1 by 1 array with the value 1. Once we have repeated this process enough times, we select spaces for our zeros and pound signs for our 1s. |
||
===Golfed code=== |
|||
<lang j>' #'{~]9&([:,/_3,./\0"+4}(#,:)),:@1</lang> |
|||
=={{header|Java}}== |
=={{header|Java}}== |