A definition for 'foreach' 
Author Message
 A definition for 'foreach'

Item Type:  Note

  I've just implemented a 'foreach' function in the lisp
interpreter I'm writing.  It is a function in AutoLISP that
I used to use a lot ( I once taught AutoCAD to design
subdivisions ) But there is no reference to a 'foreach'
function in the XLISP manual.  Is this a common lisp
function?

        ( foreach <name> <list> <expr> ... )

  i.e. given the following expressions....
        ( setq y 0.0 )
        ( foreach x ( list 1 2 3 ) ( + y x ) ( / y x ) )

        I've implemented it so that it evaluates expressions
  left to right for all members of the list...
        ( setq x 1 ) ( + y x )
        ( setq x 2 ) ( + y x )
        ( setq x 3 ) ( + y x )
        ( setq x 1 ) ( / y x )
        ( setq x 2 ) ( / y x )
        ( setq x 3 ) ( / y x )

  however it could also be iterated thusly...
        ( setq x 1 ) ( + y x )
        ( setq x 1 ) ( / y x )
        ( setq x 2 ) ( + y x )
        ( setq x 2 ) ( / y x )
        ( setq x 3 ) ( + y x )
        ( setq x 3 ) ( / y x )

  I think this is unlikely, but it's possible...
        ( setq x 1 ) ( + y x ) ( / y x )
        ( setq x 2 ) ( + y x ) ( / y x )
        ( setq x 3 ) ( + y x ) ( / y x )

  either way ( / y x ) is the last evaluation, but the order
is different.

  Can anyone help me here?  I'd like to know if there is
a definition for this somewhere, but I'm also like to hear
any logical arguments for one way of the other.  It seems
to me that consistency is the only criteria, but I'd hate
to discover later on that I've overlooked something.

                                Rick
Rick Graham                                the Binary Workshop



Tue, 14 Jan 1997 09:55:51 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. two definitions of 'cyclic'?

2. Technical: Definition of ``alyasing''

3. Definition of 'apply' of MDI GUI

4. Definition of 'pickle'

5. 'manpage'-like CL-Definitions availiable ?

6. 'multiple definitions' with MacOS X

7. Technical: Definitions of ``Poynter'', ``Shyfting''

8. stream('file','c','seek ='x) problem

9. Wanted: Hints'n'Tips'n'Bits'n'Bobs

10. Can't import Foxpro file definition into Dictionary Editor

11. Second draft of PKL (Palaste's Keywordless Language) definition

12. Dynamic re-definition: what they're saying on the Dylan list

 

 
Powered by phpBB® Forum Software