Skip to main content
added 1 character in body
Source Link
Moris Zucca
  • 1.6k
  • 11
  • 17

APL, 5

⍪⍳¨⍳⎕

creates a vector 1..n and for each element another such vector.

Then ⍪ makes a column out of all vectors. This avoids the problem with trailing blanks.

Try it on tryapl.org


Older solution:

{⎕←⍳⍵}¨⍳⎕

Creates a vector 1..n

{⎕←⍳⍵} is a function that outputs for each (¨) element a vector 1..n on a separate line

This one can't be tried on tryapl.org unfortunately, because ⎕← doesn't work there.

APL, 5

⍪⍳¨⍳⎕

creates a vector 1..n and for each element another such vector.

Then ⍪ makes a column out of all vectors. This avoids the problem with trailing blanks.

Try it on tryapl.org


Older solution:

{⎕←⍳⍵}¨⍳⎕

Creates a vector 1..n

{⎕←⍳⍵} is a function that outputs for each (¨) element a vector 1..n on a separate line

This one can't be tried on tryapl.org unfortunately, because ⎕← doesn't work there.

APL, 5

⍪⍳¨⍳⎕

creates a vector 1..n and for each element another such vector.

Then ⍪ makes a column out of all vectors. This avoids the problem with trailing blanks.

Try it on tryapl.org


Older solution:

{⎕←⍳⍵}¨⍳⎕

Creates a vector 1..n

{⎕←⍳⍵} is a function that outputs for each (¨) element a vector 1..n on a separate line

This one can't be tried on tryapl.org unfortunately, because ⎕← doesn't work there.

added 287 characters in body
Source Link
Moris Zucca
  • 1.6k
  • 11
  • 17

APL 10 9, 5

⍪⍳¨⍳⎕

creates a vector 1..n and for each element another such vector.

Then ⍪ makes a column out of all vectors. This avoids the problem with trailing blanks.

Try it on tryapl.org


Older solution:

{⎕←⍳⍵}¨⍳⎕

Creates a vector 1..n

{⎕←⍳⍵} is a function that outputs for each (¨) element a vector 1..n on a separate line

This one can't be tried on tryapl.org unfortunately, because ⎕← doesn't work there.

APL 10 9

{⎕←⍳⍵}¨⍳⎕

Creates a vector 1..n

{⎕←⍳⍵} is a function that outputs for each (¨) element a vector 1..n on a separate line

This one can't be tried on tryapl.org unfortunately, because ⎕← doesn't work there.

APL, 5

⍪⍳¨⍳⎕

creates a vector 1..n and for each element another such vector.

Then ⍪ makes a column out of all vectors. This avoids the problem with trailing blanks.

Try it on tryapl.org


Older solution:

{⎕←⍳⍵}¨⍳⎕

Creates a vector 1..n

{⎕←⍳⍵} is a function that outputs for each (¨) element a vector 1..n on a separate line

This one can't be tried on tryapl.org unfortunately, because ⎕← doesn't work there.

deleted 19 characters in body
Source Link
Moris Zucca
  • 1.6k
  • 11
  • 17

APL 710 9

↑⍕∘⍳¨⍳⎕{⎕←⍳⍵}¨⍳⎕

Creates a vector 1..n

then{⎕←⍳⍵} is a function that outputs for each (¨) element another sucha vector 1.

⍕ formats the content of the vector so it's now a string.

↑ finally createsn on a matrix.separate line

Try itThis one can't be tried on tryapl.orgtryapl.org unfortunately, because ⎕← doesn't work there.

APL 7

↑⍕∘⍳¨⍳⎕

Creates a vector 1..n

then for each element another such vector.

⍕ formats the content of the vector so it's now a string.

↑ finally creates a matrix.

Try it on tryapl.org

APL 10 9

{⎕←⍳⍵}¨⍳⎕

Creates a vector 1..n

{⎕←⍳⍵} is a function that outputs for each (¨) element a vector 1..n on a separate line

This one can't be tried on tryapl.org unfortunately, because ⎕← doesn't work there.

Source Link
Moris Zucca
  • 1.6k
  • 11
  • 17
Loading