Comma quibbling: Difference between revisions
Content deleted Content added
sed |
added Ol |
||
Line 2,451: | Line 2,451: | ||
[ [], ["ABC"], ["ABC", "DEF"], ["ABC", "DEF", "G", "H"] ] map(#quibbing) . |
[ [], ["ABC"], ["ABC", "DEF"], ["ABC", "DEF", "G", "H"] ] map(#quibbing) . |
||
[{}, {ABC}, {ABC and DEF}, {ABC, DEF, G and H}] |
[{}, {ABC}, {ABC and DEF}, {ABC, DEF, G and H}] |
||
</pre> |
|||
=={{header|Ol}}== |
|||
<lang scheme> |
|||
(define (quibble . args) |
|||
(display "{") |
|||
(let loop ((args args)) |
|||
(unless (null? args) (begin |
|||
(display (car args)) |
|||
(cond |
|||
((= 1 (length args)) #t) |
|||
((= 2 (length args)) |
|||
(display " and ")) |
|||
(else |
|||
(display ", "))) |
|||
(loop (cdr args))))) |
|||
(print "}")) |
|||
; testing => |
|||
(quibble) |
|||
(quibble "ABC") |
|||
(quibble "ABC" "DEF") |
|||
(quibble "ABC" "DEF" "G" "H") |
|||
</lang> |
|||
{{out}} |
|||
<pre> |
|||
{} |
|||
{ABC} |
|||
{ABC and DEF} |
|||
{ABC, DEF, G and H} |
|||
</pre> |
</pre> |
||
Line 2,471: | Line 2,502: | ||
%3 = "{ABC and DEF}" |
%3 = "{ABC and DEF}" |
||
%4 = "{ABC, DEF, G and H}"</pre> |
%4 = "{ABC, DEF, G and H}"</pre> |
||
=={{header|Pascal}}== |
=={{header|Pascal}}== |
||