# Generate this string table [duplicate]

For the given string s, generate generate a table like below.

Input:abcd
Output:
abcd
bbcd
cccd
dddd

Input:Hello, world!
Output:
Hello, world!
eello, world!
llllo, world!
llllo, world!
ooooo, world!
,,,,,, world!
world!
wwwwwwwworld!
ooooooooorld!
rrrrrrrrrrld!
llllllllllld!
dddddddddddd!
!!!!!!!!!!!!!


Trailing whitespace allowed.
This is a code-golf challenge so the shortest solution wins.

• Mar 10 at 15:10
• I'd lean towards it being too close a duplicate of the linked challenges... was there a discussion on the Sandbox determining otherwise? Mar 10 at 15:13
• It kind of combines the two related challenges.
Mar 10 at 15:17
• @UnrelatedString it lived in the sandbox for 1 hour, so, no. Mar 10 at 16:05

# APL (Dyalog Unicode), 12 bytes

Anonymous prefix lambda.

{⍵[∘.⌈⍨⍳≢⍵]}


Try it online!

{} "dfn"; argument is ⍵

⍵[] index into characters using the array:

≢⍵ tally of characters

⍳ indices of array of that length

∘.⌈⍨ maximum-table using that both going down and across

• I came up with the same in J, which beats APL by 1 byte this time: {~>./~@i.@# Mar 10 at 15:50
• @Jonah Yeah, APL is missing { from. I am lobbying for its addition as ⊇ so we can write ∘.⌈⍨⍤⍳⍤≢⊇⊢ Try it online!
Mar 10 at 16:49

# BQN, 9 bytesSBCS

Tacit prefix port of my APL answer

⌈⌜˜∘↕∘≠⊸⊏


⌈ maximum-

⌜ table

˜ of self

∘ of

↕ the indices

∘

≠ the string length

⊸⊏ selects characters from that tring

Run online!

# K (ngn/k), 12 bytes

{x@i|\i:!#x}


Try it online!

A port of @Adám's APL answer, using a trick with a seeded scan instead of an each-right or each-left.

• i:!#x generate list of indices of the input x, storing in i
• i|\i set up a scan, seeded with i, run over each value in i. this is equivalent to, but one byte shorter, than i|/:i or i|\:i
• x@ index back into the input, implicitly returning

# Python 3, 45 bytes

lambda s:[s[l]*l+s[l:]for l in range(len(s))]


Try it online!

Inputs a string.
Returns a list of strings.

# Ruby, 42 bytes

->s{r=0;s.chars.map{|c|s[0,r+=1]=c*r;s.b}}


Try it online!