From leavens@larch.cs.iastate.edu Tue Oct 17 10:16:40 2006 Date: Tue, 17 Oct 2006 10:16:40 -0500 (CDT) From: Gary T. Leavens To: Chris Cornelison Subject: Re: Test Review Question Hi Chris, On Tue, 17 Oct 2006, Chris Cornelison wrote: > + Using for loops to define functions > > Is is possible to write DeleteSecond from HW4 using a for loop? I haven't tried that, but I imagine it would be nontrivial. Probably that is not a good candidate for use of for loops, since it's not uniform. > If your iterating on the elements of the list, how can you keep track the > number of occurences? That could be possible with an accumulator with tail recursion, but I'm not sure how to do that in the declarative model in a for loop. The main thing is to be able to use for loops for when they are appropriate, i.e., for mapping or filtering (or combinations thereof) that are uniform in how they treat elements of a list. Good questions. Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 ----------------------------------