From: ·····@inter.net.il
Subject: map command
Date: 
Message-ID: <34772A25.4CCE@inter.net.il>
1. What does the 'map' command do ?
2. How can I make a procedure in lisp that rotates a list (left or
right) ?

Please send your answer to : ·····@inter.net.il

From: Barry Margolin
Subject: Re: map command
Date: 
Message-ID: <657v74$7kq@pasilla.bbnplanet.com>
In article <·············@inter.net.il>,  <·····@inter.net.il> wrote:
>1. What does the 'map' command do ?

It applies a function to all the elements of a set of sequences, and
returns a new sequence containing the results.

>2. How can I make a procedure in lisp that rotates a list (left or
>right) ?

(defun rotate-list (n list)
  (if (minusp n)
      (let ((tail (last list (- n)))
            (head (butlast list (- n))))
        (append tail head))
      (let ((tail (nthcdr n list))
            (head (list-difference list tail)))
        (append tail head))))

-- 
Barry Margolin, ······@bbnplanet.com
GTE Internetworking, Powered by BBN, Cambridge, MA
Support the anti-spam movement; see <http://www.cauce.org/>
Please don't send technical questions directly to me, post them to newsgroups.
From: John Arley Burns
Subject: Re: map command
Date: 
Message-ID: <wzafef8o6o.fsf@urquan-kohr-ah.mesas.com>
·····@inter.net.il writes:

> 1. What does the 'map' command do ?
> 2. How can I make a procedure in lisp that rotates a list (left or
> right) ?
> 
> Please send your answer to : ·····@inter.net.il

Why don't you read a tutorial or a reference?
From: Karl M. Hegbloom
Subject: Re: map command
Date: 
Message-ID: <87ra7r5hsr.fsf@bittersweet.inetarena.com>
>>>>> "tompr" == tompr  <·····@inter.net.il> writes:

    tompr> 1. What does the 'map' command do ?

 It maps a function across a sequence data structure, I would guess.

    tompr> 2. How can I make a procedure in lisp that rotates a list
    tompr>    (left or right) ?

 `rotatef'

    tompr> Please send your answer to : ·····@inter.net.il

 You should grep your favorite search engine for the `Common Lisp
 HyperSpec'.  I think you can find it at Harlequin.  `Common Lisp the
 Language' is also available online.  You can download both for local
 installation too, if you wish.  They're required reading.
From: Kent M Pitman
Subject: Re: map command
Date: 
Message-ID: <sfwlnxjg32r.fsf@world.std.com>
·······@bittersweet.inetarena.com (Karl M. Hegbloom) writes:

>     tompr> 2. How can I make a procedure in lisp that rotates a list
>     tompr>    (left or right) ?
> 
>  `rotatef'

Actually, ROTATEF does not do this.  It's unfortunate that the name
suggests it does.  This is a kind of "obvious pitfall" that comes from
relying too much on names, but we CL designers need to try harder to
avoid such confusions at design time.

SHIFTF and ROTATEF are for moving values among a finite and explicitly
enumerated set of places.

SHIFTF - To move the value of A to B, B to C, and C to D all "in one
step", one does: (SHIFTF D C B A).  This is simple shorthand for:
 (PSETQ D C  C B  B A)

ROTATEF - To move the value of A to B, B to C, C to D, and D back to A
"in one step", one does: (ROTATEF D C B A).  Shorthand for:
 (PSETQ D C  C B  B A  A D)

While it's certainly true that if you make a 3-list you can rotate it
by making assumptions about its length, as in:
  (LET ((L (LIST 1 2 3)))
    (ROTATEF (FIRST L) (SECOND L) (THIRD L))
    L) => (2 3 1)
this will make a mess if you miss-judge the length since it will just 
rotate the explicitly enumerated elements:
  (LET ((L (LIST 1 2 3 4)))
    (ROTATEF (FIRST L) (SECOND L) (THIRD L))
    L) => (2 3 1 4)

And although it's Christmas vacation, the presence of Deja News causes
me to be leary of offering the one-line solution to this problem.  Sigh.
Well, fortunately, I doubt it's really holding up anyone's "real work".