melsman / apltail

APL Compiler targeting a typed array intermediate language
MIT License
212 stars 9 forks source link

Make this tiny Mandelbrot work #16

Closed athas closed 7 years ago

athas commented 8 years ago

This one:

⎕←' #'[9>|⊃{⍺+⍵*2}/9⍴⊂¯3×.7j.5-⍉a∘.+0j1×a←(⍳n+1)÷n←98]

It needs complex numbers. Not sure what else.

athas commented 8 years ago

Here is one without nested arrays:

⎕←' #'[9>|m∘{⍺+⍵*2}⍣9⊢m←¯3×.7j.5-⍉a∘.+0j1×a←(⍳n+1)÷n←98]

And one that uses trains:

⎕←' #'[9>|m∘(2*⍨+)⍣9⊢m←¯3×.7j.5-⍉a∘.+0j1×a←(⍳n+1)÷n←98]
athas commented 8 years ago

(Credit to @arcfide for these.)

melsman commented 7 years ago

Do we have a ⎕IO←1 version of this code?

athas commented 7 years ago

No, but does it even do any array indexing?

melsman commented 7 years ago

it indexes into the character array ' #' and it uses iota. Fixing these quickly didn't work, though... Didn't spend a lot of time on this... ;)

melsman commented 7 years ago

The following version works now (test/mandel.apl):

⎕ ← ' #'[1+9>|({m+⍵×⍵}⍣9)(m←¯3×.7j.5-⍉a∘.+0j1×(a←(1+⍳n+1)÷(n←28)))]

Here is the result:

                #            
                 #           
               ###           
               ###           
            ######## #       
            ##########       
           ###########       
      #### ###########       
      ################       
     #################       
#####################        
     #################       
      ################       
      #### ###########       
           ###########       
            ##########       
            ######## #       
               ###           
               ###           
                 #           
                #            

It also works with tail2futhark...

ngn commented 7 years ago

1+⍳n+1 I think that should be ¯1+⍳n+1.