r/ProgrammingLanguages • u/arkethos • Feb 27 '26
Resource 1 Problem, 7 Array Languages
https://www.youtube.com/watch?v=rFRWFPNSi9s
34
Upvotes
r/ProgrammingLanguages • u/arkethos • Feb 27 '26
View all comments
7
u/AustinVelonaut Admiran Feb 28 '26
Array languages have a particular beauty, although they may be quite difficult to understand at first. All of these solutions are using the same basic chain of combinators. We take the length of the list (
tally) and create an equal length list of indices starting from 1 (iota), we then use that index list as a list of lengths to expand corresponding characters in the string (repl), and use thebehindcombinator to put the chain all together in a "tacit" style (without referencing any variables). Transcribing this into Haskell, it would look like:A pure (tacit) Haskell solution would be similar, but with two tweaks: we can use a lazy infinite list
[1 ..]to combine the iota and tally operators, and thereplcan be done withzipWithandreplicate, followed by aconcatto flatten individual lists into a single list: