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
lisp tree to clim tree
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
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
 
hans  
View profile  
 More options Nov 10 2012, 4:43 am
Newsgroups: comp.lang.lisp
From: hans <schatzer.joh...@gmail.com>
Date: Sat, 10 Nov 2012 01:43:11 -0800 (PST)
Local: Sat, Nov 10 2012 4:43 am
Subject: lisp tree to clim tree
How can I transform a "lisp tree" like

(("Class: Osteichthyes")
 ("Class: Chondrichthyes"
  (("Order: Squaliformes")
   ("Order: Rajiformes")))
 ("Class: Mammalia"
  (("Order: Rodentia"
    (("Family: Sciuridae")
     ("Family: Muridae")
     ("Family: Cricetidae")))
   ("Order: Carnivora"
    (("Family: Felidae")
     ("Family: Canidae")
     ("Family: Ursidae"))))))

into a "clim (or mcclim) tree" like

(("Class: Osteichthyes")
 ("Class: Chondrichthyes"
  :items (("Order: Squaliformes")
          ("Order: Rajiformes")))
 ("Class: Mammalia"
  :items (("Order: Rodentia"
           :items (("Family: Sciuridae")
                   ("Family: Muridae")
                   ("Family: Cricetidae")))
          ("Order: Carnivora"
           :items (("Family: Felidae")
                   ("Family: Canidae")
                   ("Family: Ursidae"))))))

thank you


 
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.
WJ  
View profile  
 More options Nov 10 2012, 10:06 am
Newsgroups: comp.lang.lisp
From: "WJ" <w_a_x_...@yahoo.com>
Date: 10 Nov 2012 15:06:11 GMT
Local: Sat, Nov 10 2012 10:06 am
Subject: Re: lisp tree to clim tree

Using pattern-matching in Racket:

(define tree
  '(("Class: Osteichthyes")
    ("Class: Chondrichthyes"
      (("Order: Squaliformes")
       ("Order: Rajiformes")))
     ("Class: Mammalia"
      (("Order: Rodentia"
        (("Family: Sciuridae")
         ("Family: Muridae")
         ("Family: Cricetidae")))
       ("Order: Carnivora"
        (("Family: Felidae")
         ("Family: Canidae")
         ("Family: Ursidae")))))))

(define (climate tree)
  (map (match-lambda
         [(list (? string? x)) (list x)]
         [(list (? string? x) more ...)
          (list* x ':items (climate more))]
         [x (climate x)])
       tree))

(climate tree)
'(("Class: Osteichthyes")
  ("Class: Chondrichthyes"
   :items
   (("Order: Squaliformes") ("Order: Rajiformes")))
  ("Class: Mammalia"
   :items
   (("Order: Rodentia"
     :items
     (("Family: Sciuridae") ("Family: Muridae") ("Family: Cricetidae")))
    ("Order: Carnivora"
     :items
     (("Family: Felidae") ("Family: Canidae") ("Family: Ursidae"))))))


 
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.
Pascal J. Bourguignon  
View profile  
 More options Nov 10 2012, 10:56 am
Newsgroups: comp.lang.lisp
From: "Pascal J. Bourguignon" <p...@informatimago.com>
Date: Sat, 10 Nov 2012 16:56:18 +0100
Local: Sat, Nov 10 2012 10:56 am
Subject: Re: lisp tree to clim tree

Read:

https://groups.google.com/forum/?fromgroups=#!msg/comp.lang.lisp/Nno1...

(defun tree-to-clim (tree)
  (if (second tree)
      (list (first tree)
            :items (mapcar (function tree-to-clim)
                           (second tree)))
      tree))

(caddr (tree-to-clim (list "Thing: IamTooLazyToUseGoogle"
                           '(("Class: Osteichthyes")
                             ("Class: Chondrichthyes"
                              (("Order: Squaliformes")
                               ("Order: Rajiformes")))
                             ("Class: Mammalia"
                              (("Order: Rodentia"
                                (("Family: Sciuridae")
                                 ("Family: Muridae")
                                 ("Family: Cricetidae")))
                               ("Order: Carnivora"
                                (("Family: Felidae")
                                 ("Family: Canidae")
                                 ("Family: Ursidae")))))))))
-->
(("Class: Osteichthyes")
 ("Class: Chondrichthyes"
  :items (("Order: Squaliformes")
          ("Order: Rajiformes")))
 ("Class: Mammalia"
  :items (("Order: Rodentia"
           :items (("Family: Sciuridae")
                   ("Family: Muridae")
                   ("Family: Cricetidae")))
          ("Order: Carnivora"
           :items (("Family: Felidae")
                   ("Family: Canidae")
                   ("Family: Ursidae"))))))

--
__Pascal Bourguignon__
http://www.informatimago.com


 
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.
hans  
View profile  
 More options Nov 11 2012, 3:46 am
Newsgroups: comp.lang.lisp
From: hans <schatzer.joh...@gmail.com>
Date: Sun, 11 Nov 2012 00:46:53 -0800 (PST)
Local: Sun, Nov 11 2012 3:46 am
Subject: Re: lisp tree to clim tree

Is such pattern matching possible in CL too?

 
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.
Marco Antoniotti  
View profile  
 More options Nov 11 2012, 10:22 am
Newsgroups: comp.lang.lisp
From: Marco Antoniotti <marc...@gmail.com>
Date: Sun, 11 Nov 2012 07:22:18 -0800 (PST)
Local: Sun, Nov 11 2012 10:22 am
Subject: Re: lisp tree to clim tree

Yes.  CL-UNIFICATION is there for you in Quicklisp (shameless plug).  Alongside CL-ENUMERATION (another shameless plug) :)

Cheers
--
MA


 
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.
Pascal J. Bourguignon  
View profile  
 More options Nov 11 2012, 11:38 am
Newsgroups: comp.lang.lisp
From: "Pascal J. Bourguignon" <p...@informatimago.com>
Date: Sun, 11 Nov 2012 17:38:36 +0100
Local: Sun, Nov 11 2012 11:38 am
Subject: Re: lisp tree to clim tree

hans <schatzer.joh...@gmail.com> writes:
> Is such pattern matching possible in CL too?

Yes, but totally overkill for this problem.

--
__Pascal Bourguignon__
http://www.informatimago.com


 
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.
End of messages
« Back to Discussions « Newer topic     Older topic »