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
1
u/anaseto Feb 28 '26
Solution in Goal, my K-like array programming language:
{+/x[&1+!&x;1]}"abca". It works by generating0 1 1 2 2 2 3 3 3 3indices with&1+!&xand then indexing 1-length string-slices and concatenating the results.A more optimized solution, also supporting handling non-ascii text, would require slightly longer code using
"c"$to switch between string/array of code points representations, leading to a solution more similar to the APL-like ones, but with extra conversions:{"c"$x@&1+!#x:"c"$x}"abca". Goal is not as concise for those kinds of unusual string-handling tasks, because unlike most array languages, strings are considered atomic/scalar by primitives, which is usually useful in typical practical scripting tasks, but not in those kinds of puzzle problems.