Comma quibbling: Difference between revisions
Content added Content deleted
(→{{header|UNIX Shell}}: There's already an AWK solution under that language; replace the one here with a solution using only builtins) |
(→{{header|UNIX Shell}}: Add Zsh-specific version) |
||
Line 4,584: | Line 4,584: | ||
fi |
fi |
||
printf '%s\n' '}' |
printf '%s\n' '}' |
||
}</syntaxhighlight> |
|||
Going the other way, Zsh-specific code can be more compact: |
|||
{{works with|Z Shell}} |
|||
<syntaxhighlight lang="zsh">quibble() { |
|||
printf '{' |
|||
if (( $# > 1 )) printf '%s and ' ${(j:, :)@[1,-2]} |
|||
printf '%s}\n' $@[-1] |
|||
}</syntaxhighlight> |
}</syntaxhighlight> |
||