Skip to main content
added 20 characters in body
Source Link
TwiN
  • 4.8k
  • 18
  • 28

APL, 37 37 32 (2828 23)

Upright triangle (3737 32-char)

({(x,⍵(-1⌷⍴⍵)⌽⍵,x←' '⍴⍨2⍴1⌷⍴⍵∊⍵)⍪⍵,⍵}⍣⎕)1 2⍴'/\' 
  • 1 2⍴'/\': Create a 1×2 character matrix /\
  • {(x,⍵(-1⌷⍴⍵)⌽⍵,x←' '⍴⍨2⍴1⌷⍴⍵∊⍵)⍪⍵,⍵}: A function that pad the right argument on both sides with blanks to create a matrix double as wide, then laminates the right argument itself doubled onto the bottom.
    E.g. /\ would become

Skewed Triangle (2828 23-char)

({(⍵,' '⍴⍨⍴⍵∊⍵)⍪⍵,⍵}⍣⎕)1 1⍴'○' 
  • 1 1⍴'○': Create a 1×1 character matrix
  • {(⍵,' '⍴⍨⍴⍵∊⍵)⍪⍵,⍵}: A function that pad the right argument on the right with blanks to create a matrix double as wide, then laminates the right argument itself doubled onto the bottom.
    E.g. would become

APL, 37 (28)

Upright triangle (37-char)

({(x,⍵,x←' '⍴⍨2⍴1⌷⍴⍵)⍪⍵,⍵}⍣⎕)1 2⍴'/\' 
  • 1 2⍴'/\': Create a 1×2 character matrix /\
  • {(x,⍵,x←' '⍴⍨2⍴1⌷⍴⍵)⍪⍵,⍵}: A function that pad the right argument on both sides with blanks to create a matrix double as wide, then laminates the right argument itself doubled onto the bottom.
    E.g. /\ would become

Skewed Triangle (28-char)

({(⍵,' '⍴⍨⍴⍵)⍪⍵,⍵}⍣⎕)1 1⍴'○' 
  • 1 1⍴'○': Create a 1×1 character matrix
  • {(⍵,' '⍴⍨⍴⍵)⍪⍵,⍵}: A function that pad the right argument on the right with blanks to create a matrix double as wide, then laminates the right argument itself doubled onto the bottom.
    E.g. would become

APL, 37 32 (28 23)

Upright triangle (37 32-char)

({((-1⌷⍴⍵)⌽⍵,∊⍵)⍪⍵,⍵}⍣⎕)1 2⍴'/\' 
  • 1 2⍴'/\': Create a 1×2 character matrix /\
  • {((-1⌷⍴⍵)⌽⍵,∊⍵)⍪⍵,⍵}: A function that pad the right argument on both sides with blanks to create a matrix double as wide, then laminates the right argument itself doubled onto the bottom.
    E.g. /\ would become

Skewed Triangle (28 23-char)

({(⍵,∊⍵)⍪⍵,⍵}⍣⎕)1 1⍴'○' 
  • 1 1⍴'○': Create a 1×1 character matrix
  • {(⍵,∊⍵)⍪⍵,⍵}: A function that pad the right argument on the right with blanks to create a matrix double as wide, then laminates the right argument itself doubled onto the bottom.
    E.g. would become
added 4 characters in body
Source Link
TwiN
  • 4.8k
  • 18
  • 28
  • 1 2⍴'/\': Create a 1×2 character matrix /\
  • {(x,⍵,x←' '⍴⍨2⍴1⌷⍴⍵)⍪⍵,⍵}: A function that pad the leftright argument on both sides with blanks to create a matrix double as wide, then laminates the leftright argument itself doubled onto the bottom.
    E.g. /\ would become
  • 1 1⍴'○': Create a 1×1 character matrix
  • {(⍵,' '⍴⍨⍴⍵)⍪⍵,⍵}: A function that pad the leftright argument on the right with blanks to create a matrix double as wide, then laminates the leftright argument itself doubled onto the bottom.
    E.g. would become
  • 1 2⍴'/\': Create a 1×2 character matrix /\
  • {(x,⍵,x←' '⍴⍨2⍴1⌷⍴⍵)⍪⍵,⍵}: A function that pad the left argument on both sides with blanks to create a matrix double as wide, then laminates the left argument itself doubled onto the bottom.
    E.g. /\ would become
  • 1 1⍴'○': Create a 1×1 character matrix
  • {(⍵,' '⍴⍨⍴⍵)⍪⍵,⍵}: A function that pad the left argument on the right with blanks to create a matrix double as wide, then laminates the left argument itself doubled onto the bottom.
    E.g. would become
  • 1 2⍴'/\': Create a 1×2 character matrix /\
  • {(x,⍵,x←' '⍴⍨2⍴1⌷⍴⍵)⍪⍵,⍵}: A function that pad the right argument on both sides with blanks to create a matrix double as wide, then laminates the right argument itself doubled onto the bottom.
    E.g. /\ would become
  • 1 1⍴'○': Create a 1×1 character matrix
  • {(⍵,' '⍴⍨⍴⍵)⍪⍵,⍵}: A function that pad the right argument on the right with blanks to create a matrix double as wide, then laminates the right argument itself doubled onto the bottom.
    E.g. would become
Source Link
TwiN
  • 4.8k
  • 18
  • 28

APL, 37 (28)

Upright triangle (37-char)

({(x,⍵,x←' '⍴⍨2⍴1⌷⍴⍵)⍪⍵,⍵}⍣⎕)1 2⍴'/\' 

Explanation

  • 1 2⍴'/\': Create a 1×2 character matrix /\
  • {(x,⍵,x←' '⍴⍨2⍴1⌷⍴⍵)⍪⍵,⍵}: A function that pad the left argument on both sides with blanks to create a matrix double as wide, then laminates the left argument itself doubled onto the bottom.
    E.g. /\ would become
 /\ /\/\
  • ⍣⎕: Recur the function (user input) times.

Example output

 /\ /\/\ /\ /\ /\/\/\/\ /\ /\ /\/\ /\/\ /\ /\ /\ /\ /\/\/\/\/\/\/\/\ /\ /\ /\/\ /\/\ /\ /\ /\ /\ /\/\/\/\ /\/\/\/\ /\ /\ /\ /\ /\/\ /\/\ /\/\ /\/\ /\ /\ /\ /\ /\ /\ /\ /\ /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ 

Skewed Triangle (28-char)

({(⍵,' '⍴⍨⍴⍵)⍪⍵,⍵}⍣⎕)1 1⍴'○' 

Explaination

  • 1 1⍴'○': Create a 1×1 character matrix
  • {(⍵,' '⍴⍨⍴⍵)⍪⍵,⍵}: A function that pad the left argument on the right with blanks to create a matrix double as wide, then laminates the left argument itself doubled onto the bottom.
    E.g. would become
○ ○○
  • ⍣⎕: Recur the function (user input) times.

Example output

○ ○○ ○ ○ ○○○○ ○ ○ ○○ ○○ ○ ○ ○ ○ ○○○○○○○○ ○ ○ ○○ ○○ ○ ○ ○ ○ ○○○○ ○○○○ ○ ○ ○ ○ ○○ ○○ ○○ ○○ ○ ○ ○ ○ ○ ○ ○ ○ ○○○○○○○○○○○○○○○○