RosettaCodeData/Task/Determine-if-a-string-is-squeezable/Icon/determine-if-a-string-is-squeezable.icon
2026-04-30 12:34:36 -04:00

27 lines
823 B
Text

procedure main()
strings := ["",
"\"If I were two-faced, would I be wearing this one?\" --- Abraham Lincoln ",
"..1111111111111111111111111111111111111111111111111111111111111117777888",
"I never give 'em hell, I just tell the truth, and they think it's hell. ",
" --- Harry S Truman "
]
collapse("i",strings[1])
collapse(" ",strings[2])
collapse("7",strings[3])
collapse(".",strings[4])
collapse(" -r",strings[5])
end
procedure collapse(c,s)
every c1 := !c do {
ns := ""
s ? {
while ns ||:= tab(upto(c1))||move(1) do tab(many(c1))
ns ||:= tab(0)
}
write("Squeezing out '",c1,"':")
write(" original: <<<",s,">>> ",*s)
write(" squeezed: <<<",ns,">>> ",*ns)
}
end