Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion new to lisp, need help.
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Kaz Kylheku  
View profile  
 More options Sep 17 2012, 2:27 pm
Newsgroups: comp.lang.lisp
From: Kaz Kylheku <k...@kylheku.com>
Date: Mon, 17 Sep 2012 18:27:17 +0000 (UTC)
Local: Mon, Sep 17 2012 2:27 pm
Subject: Re: new to lisp, need help.
On 2012-09-17, mchukh...@gmail.com <mchukh...@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))))


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.