Comma quibbling: Difference between revisions

Content added Content deleted
imported>Rowsety Moid
No edit summary
Line 223: Line 223:
{ABC and DEF}
{ABC and DEF}
{ABC, DEF, G and H}</pre>
{ABC, DEF, G and H}</pre>

=={{header|Acornsoft Lisp}}==

There's no string data type; symbols are used instead. The <code>implode</code> function is used to concatenate a list of symbols. When writing a symbol in source code, exclamation mark is an escape character that allows characters such as spaces and exclamation marks to be treated as part of the symbol's name.

<syntaxhighlight lang="lisp">
(defun examples ()
(map '(lambda (words) (printc (quibble words)))
'(() (ABC) (ABC DEF) (ABC DEF G H))))

(defun quibble (words)
(implode (list '{ (quibbles words) '})))

(defun quibbles (words)
(implode (conjunction words)))

(defun conjunction (words)
(cond ((null words)
'())
((null (cdr words))
words)
((null (cddr words))
(list (car words) '! and! (cadr words)))
(t
(cons (car words)
(cons ',! (conjunction (cdr words)))))))
</syntaxhighlight>

{{out}}

Calling <code>(examples)</code> will output:

<pre>
{}
{ABC}
{ABC and DEF}
{ABC, DEF, G and H}
</pre>


=={{header|Action!}}==
=={{header|Action!}}==