Hi, everyone:
     I referred to archives below and successfully established one triangular:
   
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".)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5



  However, when I tried to add one (make) in the body of map, the ahead one 
wouldn't be produced.
  e.g.
   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))))
           (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))))))
 
the first block wouldn't show up  in the  result but only the last block.
  can anyone give me any hint to improve this and tell me how to use map to 
establish more than two objects, which shapes are arbitrary?

 Thank you so 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