Thank you Stephen. The code does not work in general. I know how to do it now.<br><br>
<div class="gmail_quote">On Thu, Jun 2, 2011 at 7:45 AM, Stephen Bloch <span dir="ltr"><<a href="mailto:sbloch@adelphi.edu">sbloch@adelphi.edu</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<div class="im"><br>On Jun 2, 2011, at 9:11 AM, Yingjian Ma wrote:<br><br>> Here is another question. In (lambda (ls), it seems ls took the value from v. How does Racket know not pass x to ls as the argument?<br><br>
</div>"helper" is defined as "(lambda (ls) ...)"<br>The only place you call "helper", you give it "(vector->list v)"; you don't pass it x, so it doesn't take x.<br>
<div class="im"><br>> Does it alway takes the right variable?<br><br></div>No, it always takes what is explicitly passed in as arguments :-)<br>
<div class="im"><br>> Also, I want code to keep all the letters that is not a. It does not work for<br>> (test 'a #(b c a b a d)). The result is '(c b). If you know how to generalize it, please let me know.<br>
<br><br></div>In fact, the program you showed us has quite a number of problems: try<br>(test 'a #(b))<br>(test 'a #(a a))<br>(test 'a #(a b a c))<br>for example.<br><br>I would fix this program by starting over from scratch: the program as it stands is not only buggy but too long and complicated. My solution, and the one I would expect my beginning students to come up with, is about 140 characters long, not including contract and test cases.<br>
<font color="#888888"><br><br>Stephen Bloch<br><a href="mailto:sbloch@adelphi.edu">sbloch@adelphi.edu</a><br><br></font></blockquote></div><br>