Comma quibbling: Difference between revisions
Content deleted Content added
m →{{header|C++}}: whitespace |
Adding clojure code |
||
Line 77:
{ABC, DEF, G and H}
</pre>
=={{header|Clojure}}==
<lang clojure>
(defn quibbling [sequence]
(let [sep (if (> (count sequence) 1) " and " "")]
(apply str (concat
(interpose ", " (butlast sequence))
[sep (last sequence)]))))
(map quibbling [[]
["ABC"]
["ABC", "DEF"]
["ABC", "DEF", "G", "H"]])
</lang>
{{out}}
<pre>("" "ABC" "ABC and DEF" "ABC, DEF, G and H")</pre>
=={{header|D}}==
|