melsman / apltail

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

Make this example from Dyalog work #18

Closed athas closed 7 years ago

athas commented 8 years ago

https://twitter.com/dyalogapl/status/755706056005877760

      {+/,⍵×⍵=+/¨⍳⍴⍵}?5 5⍴10

It's a modern version of this piece of ancestor worship: http://keiapl.org/anec/#Dijkstra

athas commented 8 years ago

Hm, the iota creates boxed arrays, doesn't it?

athas commented 8 years ago

Came up with this version. Not a fan of the duplication:

{+/+/⍵×⍵=((⍴⍵)⍴⍳1↓⍴⍵)+(⍴⍵)⍴⍳1↑⍴⍵}5 5⍴10
melsman commented 7 years ago

The following works in apltail:

{+/+/⍵×⍵=((⍴⍵)⍴⍳⊃⍴⍵)+(⍴⍵)⍴⍳⊃⍴⍵}5 5⍴10

The original version requires nested arrays and we require iota to take a scalar argument.