From: rodrigo vanegas
Subject: sequence iteration
Date: 
Message-ID: <RV.93Jun22150732@vegas.cs.brown.edu>
Is there any generic iteration contruct for sequences?  Ideally it
would work just like DOLIST. 

Example:

  > (do-sequence (e "ab c")
      (print e))
  #\a
  #\b
  #\Space
  #\c
  nil


rodrigo vanegas
··@cs.brown.edu

From: Don Geddis
Subject: Re: sequence iteration
Date: 
Message-ID: <1993Jun22.210732.13597@CSD-NewsHost.Stanford.EDU>
In article <················@vegas.cs.brown.edu>, ··@cs.brown.edu (rodrigo vanegas) writes:
> Is there any generic iteration contruct for sequences?  Ideally it
> would work just like DOLIST. 
>   > (do-sequence (e "ab c")
>       (print e))
>   #\a
>   #\b
>   #\Space
>   #\c
>   nil

Well, I don't know if you consider the LOOP macro to be Common Lisp, but
the following works in Allegro CL 4.2:

	USER(20): (loop for x across "ab c" do (print x))
	
	#\a 
	#\b 
	#\space 
	#\c 
	NIL

CLtL2 says that the "across" keyword works for iteration over arrays (vectors),
so it looks to be not quite as generic as over sequences.  But it's close.

	-- Don
-- 
Don Geddis (······@CS.Stanford.Edu)
My aunt gave me a walkie-talkie for my birthday.  She says if I'm good, she'll
give me the other one next year.  -- [Imitation] Steven Wright
From: Josh Fisher
Subject: Re: sequence iteration
Date: 
Message-ID: <1993Jun22.223313.12507@hplabsz.hpl.hp.com>
(Don Geddis) writes:
>Well, I don't know if you consider the LOOP macro to be Common Lisp, but
>the following works in Allegro CL 4.2:
>
>   . . .
>
>CLtL2 says that the "across" keyword works for iteration over arrays (vectors)
>so it looks to be not quite as generic as over sequences.  But it's close.

Not to be a broken record, but the "iterate" macro (see my message from a 
few days ago) includes:

	(for var in-sequence sequence)

-- Josh Fisher
From: Bruno Haible
Subject: Re: sequence iteration
Date: 
Message-ID: <209cqr$1ah@nz12.rz.uni-karlsruhe.de>
rodrigo vanegas writes:
> Is there any generic iteration contruct for sequences?  Ideally it
> would work just like DOLIST. 
>
> Example: (do-sequence (e "ab c") (print e))

You can write it yourself, roughly like this:

(defmacro dosequence ((var seqform &optional resultform) &body body)
  (multiple-value-bind (body-rest declarations)
      (parse-body body) ; splits off the declarations from the body
    (setq declarations (if declarations `((DECLARE ,@declarations)) '()))
    (let ((seqvar (gensym)))
      `(BLOCK NIL
         (LET ((,seqvar ,seqform))
           (LET ((,var NIL))
             ,@declarations
             ; (DECLARE (IGNORABLE ,var))
             (MAP NIL
                  #'(LAMBDA (,var) ,@declarations (TAGBODY ,@body-rest))
                  ,seqvar
             )
             ,resultform
       ) ) )
) ) )

                    Bruno Haible
                    ······@ma2s2.mathematik.uni-karlsruhe.de
From: Tim Larkin
Subject: Re: sequence iteration
Date: 
Message-ID: <209pc8INNfd8@newsstand.cit.cornell.edu>
In article <················@vegas.cs.brown.edu> rodrigo vanegas,
··@cs.brown.edu writes:
>Is there any generic iteration contruct for sequences?  Ideally it
>would work just like DOLIST. 

Yes, it's called MAP. Try this:

(map nil #'print "ab c")

Tim Larkin
····@cornell.edu
607-255-7008
From: Meliani Suwandi
Subject: Re: sequence iteration
Date: 
Message-ID: <20a6gqINN7t7@uwm.edu>
Is there anyone out there knows about a lisp - linear programming 
package ?
Any information would be appreciated.

Thank you.

Meliani Suwandi
·······@sprecher.cs.uwm.edu
From: Mike Eggleston
Subject: Re: sequence iteration
Date: 
Message-ID: <MIKEE.93Jun23152036@rambo.aadt.com>
I'd be interested in any references to this also!
--
--
Mike Eggleston       American Airlines Decision Technologies     
(817)931-2287        P. O. Box 619616, MD 4462                            
(817)967-9763 (FAX)  Dallas/Fort Worth Airport, Texas 75261-9616, USA