Jump to content
  • Advertisement
Sign in to follow this  
takeachance

dieing in drscheme

This topic is 3254 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

these are the two questions, and honestly i've stared at them for a while and i still don't know how or where to start. I'm hoping someone here will help me out, greatly appreciated 1. Create a function largest-even that consumes a list of integers. If the list has no even integers, your function should produce false. Otherwise, it should produce the largest even integer in the list. Note: negative integers can be even. 2. Create a function omit-vowels that consumes a string and produces the string formed by removing all vowels (a, e, i, o, u, A, E, I, O, U).

Share this post


Link to post
Share on other sites
Advertisement
Sounds a little like a school/uni question.

Are you going to be using scheme for this, don't think you will find many schemers here though.

I could help with common lisp but I have no experience of scheme.

They are both dialects of lisp so if you post some code here I'll check back and give you my thoughts, you need to make some attempt first though, as I think it would be against the rules for me to help yet.

Share this post


Link to post
Share on other sites
A hint for number 2.

(define (isOne? numb) (= numb 1))

(filter isOne? (list 1 2 3 4 5 6 7 1 1))

returns the value (1 1 1)

Actually it is pretty useful for number one as well especially when you know about the even? predicate.

Share this post


Link to post
Share on other sites
stonemetals approach could also work for question 1.

1. Create a function to test if an integer is even and positive.
2. Filter the list.
3. If the resulting list is empty, return false. Otherwise find the highest integer in it.

Share this post


Link to post
Share on other sites
Recursion, you know?

Quote:
Original post by takeachance
1. Create a function largest-even that consumes a list of integers. If the list has no even integers,
your function should produce false. Otherwise, it should produce the largest even integer in
the list. Note: negative integers can be even.


This is the largest even number in the cdr of the list, unless the car of the list is both even and greater than any even number in the cdr of the list. And #f for an empty list.

Quote:
2. Create a function omit-vowels that consumes a string and produces the string formed by
removing all vowels (a, e, i, o, u, A, E, I, O, U).


This is the first character of the string (unless it's a vowel, in which case we put nothing) followed by the result of omitting vowels from the rest of the string.

Share this post


Link to post
Share on other sites
Those questions are from University of Waterloo cs115 assignment 4. If you can't understand those easy questions then you'll fail the midterm next monday. :p

Share this post


Link to post
Share on other sites
Quote:
Original post by BoundaryValue
Those questions are from University of Waterloo cs115 assignment 4. If you can't understand those easy questions then you'll fail the midterm next monday. :p


Yeah, we already figured out it was a homework question - thus the nature of the responses. Nice detective work, but ultimately not useful.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!