On 2012-09-17, mchukhlib@gmail.com <mchukhlib@gmail.com> wrote:
Assumptions:
You can assume the following:
1. AND is the only word that can create compound sentences.
2. Any time that AND is used it is a compound sentence.
3. A compound sentence can only have 1 AND in it.
Sample Output:
Here is sample output for the function.
Break 10 [14]> (BREAK_COMP '(I like you))
((I LIKE YOU))
Break 10 [14]> (BREAK_COMP '(I like you and you like me))
((I LIKE YOU) (YOU LIKE ME))
(defun break-comp (list)
(let* ((and-clause (member 'and list))
(main-clause (ldiff list and-clause)))
`(,main-clause ,@(if and-clause `(,(cdr and-clause))))))
Uncool version, without backquote notation:
(defun break-comp (list)
(let* ((and-clause (member 'and list))
(main-clause (ldiff list and-clause)))
(if and-clause
(list main-clause and-clause)
(list main-clause))))
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 403 |
Nodes: | 16 (2 / 14) |
Uptime: | 43:26:04 |
Calls: | 8,407 |
Calls today: | 2 |
Files: | 13,171 |
Messages: | 5,905,019 |