[plt-scheme] Help with programming
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!
--hsm
On Fri, Apr 23, 2010 at 8:41 PM, Marco Morazan <morazanm at gmail.com> wrote:
> Sure, no problem.
>
> 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.
>
> If you are not clear about what the design recipe for abstraction is, take
> a look at Part IV of www.htdp.org.
>
> Alternatively, you can use an appropriate built-in higher-order function
> for filtering the elements of a list to implement your 3 functions.
>
> I hope that helps.
>
>
> On Thu, Apr 22, 2010 at 12:19 PM, Joe Burk <joshwbfantasy at yahoo.com>wrote:
>
>> 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.
>>
>> Consider the following functions:
>>
>> (define get-evens
>> (lambda (lst)
>> (cond ((null? lst) '())
>> ((even? (car lst)) (cons (car lst) (get-evens (cdr lst))))
>> (else (get-evens (cdr lst))))))
>>
>> (define get-odds
>> (lambda (lst)
>> (cond ((null? lst) '())
>> ((odd? (car lst)) (cons (car lst) (get-odds (cdr lst))))
>> (else (get-odds (cdr lst))))))
>>
>> (define get>2
>> (lambda (lst)
>> (cond ((null? lst) '())
>> ((> (car lst) 2) (cons (car lst) (get>2 (cdr lst))))
>> (else (get>2 (cdr lst))))))
>>
>> 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:
>>
>> (define extract
>> (lambda (test? lst)
>>
>>
>> 2. Use extract to define get-evens, get-odds, and get>2
>>
>>
>>
>> _________________________________________________
>> For list-related administrative tasks:
>> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>>
>>
>
>
> --
>
> Cheers,
>
> Marco
>
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20100423/f622e569/attachment.html>