One thing I've always liked about this list is it's kindness to students of all sorts, even ones with homework ;-) Keep it up folks, you do good work!<br><br>--hsm<br><br><div class="gmail_quote">On Fri, Apr 23, 2010 at 8:41 PM, Marco Morazan <span dir="ltr"><<a href="mailto:morazanm@gmail.com">morazanm@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Sure, no problem.<br><br>You see, it is quite simple. Apply the design recipe for abstraction to your functions. Define an abstract function and then use your abstract function to implement your original functions. Voila! There you go.<br>
<br>If you are not clear about what the design recipe for abstraction is, take a look at Part IV of <a href="http://www.htdp.org" target="_blank">www.htdp.org</a>.<br><br>Alternatively, you can use an appropriate built-in higher-order function for filtering the elements of a list to implement your 3 functions.<br>
<br>I hope that helps.<br><br><br><div class="gmail_quote"><div><div></div><div class="h5">On Thu, Apr 22, 2010 at 12:19 PM, Joe Burk <span dir="ltr"><<a href="mailto:joshwbfantasy@yahoo.com" target="_blank">joshwbfantasy@yahoo.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div></div><div class="h5">
<table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font: inherit;" valign="top">Hey everyone, I'm a bit new to scheme and I'm looking for some help. Hopefully you guys can assist me. I was given these few questions and I have no clue where to start. So if anyone could answer them they would be of much help. Thanks.<br>
<br>Consider the following functions:<br><br>(define get-evens<br> (lambda (lst)<br> (cond ((null? lst) '())<br> ((even? (car lst)) (cons (car lst) (get-evens (cdr lst))))<br> (else (get-evens (cdr lst))))))<br>
<br>(define get-odds<br>
(lambda (lst)<br>
(cond ((null? lst) '())<br>
((odd? (car lst)) (cons (car lst) (get-odds (cdr lst))))<br>
(else (get-odds (cdr lst))))))<br><br>(define get>2<br> (lambda (lst)<br>
(cond ((null? lst) '())<br> ((> (car lst) 2) (cons (car lst) (get>2 (cdr lst))))<br> (else (get>2 (cdr lst))))))<br><br>1. Write another function that accepts a test as one of its arguments, and which can then behave like each of the above functions. Starting with:<br>
<br> (define extract<br> (lambda (test? lst)<br><br><br>2. Use extract to define get-evens, get-odds, and get>2<br><br></td></tr></tbody></table><br>
<br></div></div><div class="im">_________________________________________________<br>
For list-related administrative tasks:<br>
<a href="http://list.cs.brown.edu/mailman/listinfo/plt-scheme" target="_blank">http://list.cs.brown.edu/mailman/listinfo/plt-scheme</a><br>
<br></div></blockquote></div><br><br clear="all"><br>-- <br><br>Cheers,<br><font color="#888888"><br>Marco<br>
</font><br>_________________________________________________<br>
For list-related administrative tasks:<br>
<a href="http://list.cs.brown.edu/mailman/listinfo/plt-scheme" target="_blank">http://list.cs.brown.edu/mailman/listinfo/plt-scheme</a><br>
<br></blockquote></div><br>