Comma quibbling: Difference between revisions

Fixed to most recent version
(Fixed to most recent version)
Line 1,870:
 
=={{header|Julia}}==
{{works with|Julia|0.6}}
<lang Julia>function quibble(wordsarr::Array) =
"{"* (isempty(words) ? "" :
if isempty(arr) rst = "" else rst = "$(arr[end])" end
length(words)==1? words[1] :
if length(arr) > 1 rst = join(wordsarr[1:end-1], ", ") * " and "*words[end]) *"}"</lang> rst end
return "{" * rst * "}"
{{Out}}
end
<pre>julia> quibble([])
"{}"
 
julia>@show quibble(["ABC"])
@show quibble(["{ABC}"])
julia>@show quibble(["ABC", "DEF"])
@show quibble(["ABC", "DEF", "G", "H"])</lang>
 
{{Out}}
julia> quibble(["ABC","DEF"])
<pre>julia> quibble([]) = "{}"
"{ABC and DEF}"
quibble(["ABC"]) = "{ABC}"
 
julia> quibble(["ABC", "DEF","G","H"]) = "{ABC and DEF}"
quibble(["ABC", "DEF", "G", "H"]) = "{ABC, DEF, G and H}"</pre>
 
=={{header|Kotlin}}==
Anonymous user