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 How to destructure list to places?

Received: by 10.68.138.199 with SMTP id qs7mr449853pbb.1.1336708442765;
        Thu, 10 May 2012 20:54:02 -0700 (PDT)
Path: pr3ni12268pbb.0!nntp.google.com!news2.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!spln!extra.newsguy.com!newsp.newsguy.com!enews4
From: "WJ" <w_a_x_...@yahoo.com>
Newsgroups: comp.lang.lisp
Subject: Re: How to destructure list to places?
Date: 11 May 2012 03:53:12 GMT
Organization: NewsGuy - Unlimited Usenet $19.95
Lines: 24
Message-ID: <joi2f801shf@enews4.newsguy.com>
References: <jk8jvo01aok@enews2.newsguy.com>
NNTP-Posting-Host: p58a6b20b5a0d14c2149b2fe7baa5e6086c8a36ef4e2888afd90f450c0a4c90da.newsdawg.com
Mime-Version: 1.0
User-Agent: XanaNews/1.18.1.6
X-Antivirus: avast! (VPS 120510-0, 05/10/2012), Outbound message
X-Antivirus-Status: Clean
X-Received-Bytes: 1205
Content-Type: text/plain; charset=iso-8859-1

WJ wrote:

> Matthew Danish wrote:
> 
> > (destructuring-bind (a b (c d)) (list 1 2 (list 3 4)) 
> >   (list b c d a))
> 
> Clojure:
> 
> (let [[a b [c d]] (list 1 2 (list 3 4))]
>   (list b c d a))
> 
>   ==> (2 3 4 1)

Racket:

(match-let ([`(,a ,b (,c ,d)) '(1 2 (3 4))]) (list b c d a))
 => '(2 3 4 1)
(match-let ([(list a b (list c d)) '(1 2 (3 4))]) (list b c d a))
 => '(2 3 4 1)

(match-let ([(list (? odd? odds) ... more ...) '(3 5 7 8 9)])
  (list odds more))
 => '((3 5 7) (8 9))