Hi everyone:
   I refer to one of archives as below to build up the
object:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
On Tue, 14 Nov 2006, Pascual Munoz Munoz wrote:
> I've been looking to the 'loop' howto on the wiki,
but I cannot manage
> how to make a loop that makes a list of objects in
different positions
> and with different widths, depending on the loop
variable.
>
> I've tried several things, the one making more sense
to me (but not
> working) is (not changing the width of the slices):
> (set! geometry
>        (list
>                (make block (center 0 0) (size W L)
>                        (material (make dielectric
(index nde))))
>                (do ((x (* -1 Gp) (+ x 1))) ((> x
Gp))
>                        (make block (center 0 (* x
0.12)) (size W 0.12)
>                                (material (make
dielectric (index
> 1.0)))) ) ) )

A "do" loop does not return a list of objects, which
is what you want to 
do here.

   To create a list, the easiest thing is to use
"map".  For example,

(set! geometry
       (cons
        (make block (center 0 0) (size W L)
              (material (make dielectric (index
nde))))
        (map
         (lambda (x)
           (make block (center 0 (* x 0.12)) (size W
0.12)
                                 (material (make
dielectric (index 1.0)))))
         (arith-sequence (- Gp) 1 (round (+ (* 2 Gp)
1))))))

Of course, this does not change the width of the
slices (they are all W), 
but neither does your example.  You can easily
substitute some arbitrary 
function of x here.

(Note that (cons a B) prepends an element "a" to the
list "B".)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   It works pretty well. But I found out within map,
it can only make one object. If I want to make another
object,i.e. different epsilon and shape but related to
x, the previous one won't be executed but only the
later. 
  e.g.:
   ( map
    (lambda (x)
      (make block )
      (make cylinder)
     ...
   the block won't be produced.
   can anyone give me any hint to build up more than
two objects with any shape using map?
   Thank you very much!

Adrian

   



      
____________________________________________________________________________________
想及時通知通訊錄裡的所有親朋好友好消息,就來 Yahoo!奇摩電子信箱發簡訊!
http://tw.mobile.yahoo.com/texts/mail.php

_______________________________________________
meep-discuss mailing list
meep-discuss@ab-initio.mit.edu
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss

Reply via email to