RosettaCodeData/Task/Determine-if-a-string-is-squeezable/APL/determine-if-a-string-is-squeezable-1.apl
2023-07-01 13:44:08 -04:00

32 lines
1 KiB
APL
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

task{
⍝ Squeeze a string
squeeze (/)1,1¯1
⍝ Display string and length in the manner given in the task
display {(¯2),' «««',,'»»»'}
⍝ Squeeze string and display output
show {
r 'chr: ''',,''''
rr,' in: ',display
rr,'out: ',display squeeze
r,''
}
⍝ Strings from the task
s1''
s2'"If I were two-faced, would I be wearing this one?"'
s2s2,' --- Abraham Lincoln '
s3'..1111111111111111111111111111111111111111111111111'
s3s3,'111111111111117777888'
s4'I never give ''em hell, I just tell the truth, and t'
s4s4,'hey think it''s hell. '
s5' '
s5s5,' --- Harry S Truman '
' ' show s1
'-' show s2
'7' show s3
'.' show s4
{ show s5}¨' -r' ⍝⍝ note use of 'show' here in a lambda (dfn)
}