Comma quibbling: Difference between revisions
Content deleted Content added
Fixed to most recent version |
|||
Line 1,870: | Line 1,870: | ||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
{{works with|Julia|0.6}} |
|||
<lang Julia>quibble( |
<lang Julia>function quibble(arr::Array) |
||
"{"* (isempty(words) ? "" : |
|||
if isempty(arr) rst = "" else rst = "$(arr[end])" end |
|||
length(words)==1? words[1] : |
|||
join( |
if length(arr) > 1 rst = join(arr[1:end-1], ", ") * " and " * rst end |
||
return "{" * rst * "}" |
|||
⚫ | |||
end |
|||
⚫ | |||
"{}" |
|||
@show quibble([]) |
|||
" |
@show quibble(["ABC"]) |
||
⚫ | |||
@show quibble(["ABC", "DEF", "G", "H"])</lang> |
|||
⚫ | |||
⚫ | |||
⚫ | |||
"{ABC and DEF}" |
|||
quibble(["ABC"]) = "{ABC}" |
|||
quibble(["ABC", "DEF"]) = "{ABC and DEF}" |
|||
"{ABC, DEF, G and H}"</pre> |
quibble(["ABC", "DEF", "G", "H"]) = "{ABC, DEF, G and H}"</pre> |
||
=={{header|Kotlin}}== |
=={{header|Kotlin}}== |