Re: Implment Do Loop for Objects

"Steven G. Johnson" <[email protected]>
Newsgroups gmane.comp.science.photonic-bands
Message-ID <[email protected]>
On Jul 13, 2008, at 3:47 AM, Ian D. Hosein wrote:
>   I'm trying to simulate the photonic band structure of an FCC  
> lattice with
> random sphere sizes.  I'm working with a supercell of size n (where  
> n is a
> variable) and then I want to fill the cell with spheres on the  
> lattice sites
> with random sizes.  To this end, I have written a do loop to fill in  
> the
> lattice points. However I'm not sure how to append the lists created  
> on my
> loop to return a full list of objects back.  Below is my code: nx ny  
> nx
> denote the 1x1x1 box I'm in, where each box is just the cubic non- 
> primitive
> unit cell of the FCC lattice. In each box I fill in the objects at  
> the four
> basis points: one corner and three faces. I do this for each box in  
> my super
> cell. I'm just not sure how to append the lists I make in my loop to  
> return
> it back to set! geometry.
>    Any help would be appreciated.


Well, one way to do it would be for each iteration of your do loop to  
set! the geometry list to append one more item.  This is the  
imperative style of programming, similar to C/C++, and goes well with  
the imperative-style "do" construct.

A more Schemish, functional approach would be to use the "map"  
construct to generate a list of objects and attach it to the geometry  
list.

Steven
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.