RosettaCodeData/Task/Comma-quibbling/NetRexx/comma-quibbling.netrexx
2023-07-01 13:44:08 -04:00

25 lines
801 B
Text

/* NetRexx */
options replace format comments java crossref symbols nobinary
runSample(arg)
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method quibble(arg) public static
parse arg '[' lst ']'
lst = lst.changestr('"', '').space(1)
lc = lst.lastpos(',')
if lc > 0 then
lst = lst.insert('and', lc).overlay(' ', lc)
return '{'lst'}'
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method runSample(arg) private static
lists = ['[]', - -- {}
'["ABC"]', - -- {ABC}
'["ABC", "DEF"]', - -- {ABC and DEF}
'["ABC", "DEF", "G", "H"]'] -- {ABC, DEF, G and H}
loop lst over lists
say lst.right(30) ':' quibble(lst)
end lst
return