Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

chaos_168 Group Title

Some English words can be played on the keys of a piano, such as “face” or “baggage”. A piano has keys named a, b, c, d, e, f, g. Write a Scheme function can-play-word? that consumes a word (a non-empty string) and produces true or false depending on whether the word can be played on a piano or not. The only characters that can be played on a piano are lower case letters. Some English words can be played on the keys of a piano, such as “face” or “baggage”. A piano has keys named a, b, c, d, e, f, g. Write a Scheme function can-play-word? that consumes a word (a non-empty string) and produces true or false depending on whether the word can be played on a piano or not. The only characters that can be played on a piano are lower case letters. @Computer Science

  • 2 years ago
  • 2 years ago

  • This Question is Closed
  1. note-phobia Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    o sweet.... we are askin the same question... feel like we should use remove-all definition but i have no clue how to operate it..

    • 2 years ago
  2. chaos_168 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    yeah... I have no idea how to do this... not that great in cs.. lol :/

    • 2 years ago
  3. note-phobia Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    ...it's only about an hour till the deadline of this assignment.... i'm dying..

    • 2 years ago
  4. chaos_168 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    Yeah... I only got the first question. LOL. I'm screwed..

    • 2 years ago
  5. note-phobia Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    ........i cant even say i got the first question cuz i didn't pass the test..... are u in cs 115..?

    • 2 years ago
  6. note-phobia Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    do i know u....?

    • 2 years ago
  7. chaos_168 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    yeah.. CS 115. In Lori Case class.... I don't think you know me.. I don't know that many people. LOL

    • 2 years ago
  8. note-phobia Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    i mean d i know u in person? nm we have different profs.... omg what to do...

    • 2 years ago
  9. chaos_168 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    No, I don't think you know me in person.. haha.. I just wrote all the design recipe stuff down hoping to get part marks.. I didn't get any of the actual functions itself...

    • 2 years ago
  10. note-phobia Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    o brilliant idea...... i'll do that immediately.... yeah muz get a 25%+ or it's too bad..

    • 2 years ago
  11. note-phobia Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    what program r u in?

    • 2 years ago
  12. chaos_168 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    haha.. yeah.. I just hope to get over 25% in the assignments to get that extra mark. LOL... and I'm in honours math.. hbu?

    • 2 years ago
  13. note-phobia Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    i already chose my program to be actsci....... and i now regret it a lot.... but i want to stay tho..

    • 2 years ago
  14. chaos_168 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    ooo actsci... a lot of people are taking that actually.. I'm actually taking MTHEL 131(intro to actuarial practice?) as my elective.. and I don't find it that interesting.. LOL

    • 2 years ago
  15. note-phobia Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    o i dont even know what that is...... my cousin 's in actsci 3rd yr and i juz wanted to get help from her so i chose the same program.. how i realize how tough it is.....><

    • 2 years ago
  16. note-phobia Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    now==

    • 2 years ago
  17. chaos_168 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    haha.. that's why you choose a program that you like and enjoy.. I have to go drop off my algebra assignment due in 30 minutes.. LOL i'll be back soon. xD work on those design recipes! xD

    • 2 years ago
  18. note-phobia Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    o m g... i didn't even do my algebra assignment......

    • 2 years ago
  19. note-phobia Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    i was workin on cs all the time..

    • 2 years ago
  20. chaos_168 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    .... are you serious? ... wow.. Dx I did algebra first cause I find it easier and much more useful than CS... I hate CS ... don't even know why I have to take it...

    • 2 years ago
  21. note-phobia Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    ...more useful....i much better in algebra than in cs so it doesn't matter if i miss one assignment.... thats why i gave it up..

    • 2 years ago
  22. note-phobia Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    yeah i don't see the point of taking cs.........i'm terrible at it...........

    • 2 years ago
  23. chaos_168 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    haha.. me too... I don't understand a thing in CS.. everything the prof says is just alien language to me.. LOL.. gonna go drop off algebra now.. i'll be back soon xD

    • 2 years ago
  24. note-phobia Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    oo~~ see u soon...... btw i cannot log in to my markus no matter which browser i use now...

    • 2 years ago
  25. chaos_168 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    o.O ur right... some authorization thing... :s

    • 2 years ago
  26. note-phobia Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    。。。 what should we do..........

    • 2 years ago
  27. chaos_168 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    I have no idea... I submitted some of mine already... It's probably cause a lot of people are using it or something.. Just keep trying I guess? :S

    • 2 years ago
  28. note-phobia Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    。。。 i emailed the ta.

    • 2 years ago
  29. Narsat Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    I'm rusty at Scheme, but you should do something like this. (define (can-play-word? word) (cond ((empty? word) #t) ((char= (car word) 'a) (can-play-word (cdr word))) ((char= (car word) 'b) (can-play-word (cdr word))) ((char= (car word) 'c) (can-play-word (cdr word))) ((char= (car word) 'd) (can-play-word (cdr word))) ((char= (car word) 'e) (can-play-word (cdr word))) ((char= (car word) 'f) (can-play-word (cdr word))) ((char= (car word) 'g) (can-play-word (cdr word))) (else #f))) As I said, it might not be exactly like this. I have no way to test it at the moment, but it should follow this general structure: Make a cond, ask if the word still has elements, if its empty, it's automatically true. If the letter you recieve is a, b, c, d, e, f or g, you call the function again and keep trying. If you recieve anything else, it's automatically false.

    • 2 years ago
  30. chaos_168 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    Hey... thanks for the reply... an error message appeared when I ran the program.. char=: this function is not defined

    • 2 years ago
  31. note-phobia Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    yeah i have no clue what does char means.... i know car is first and cdr is rest...

    • 2 years ago
  32. Narsat Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    hmm, there should be a function that does what char= is supposed to do, anything you remember that is used to compare two values? Lemme look up online char means a single character like a, b or c

    • 2 years ago
  33. Narsat Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    Oh my bad, it's supposed to be char=? not char=

    • 2 years ago
  34. dmancine Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    I wrote a helper function can-play-letter? that determines if a single letter is playable. Then for can-play-word? I said it's either that the string is empty (base case), or the first letter is playable (do a little work) and the rest of the word is playable (recursively reduce it to a smaller problem).

    • 2 years ago
  35. note-phobia Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    ;;wordlist: string -> list-of-symbols ;;Purpose: transform a string to a list ;;Examples:(define (wordlist maryh) => (cons #\m (cons #\a (cons #\r (cons #\y (cons #\h empty))))) (define (wordlist word) (string->list word)) ;;data analysis: ;; if the word contains only a,b,c,d,e,f,g then produces boolean value true ;; if the word contains letters other than a,b,c,d,e,f,g then produces boolean value false ;;wordtest: string->boolean ;;Purpose: produce boolean value of a word whether it contains only a,b,c,d,e,f,g ;;or it contains letters that are not on the piano keyboard by consuming a string ;;Examples: ;;(check-word "dad") => true ;;(check-word "play") => false (define (check-word word) (cond [(equal? (list->string(cons (first (wordlist word)) empty))"a") true] [(equal? (list->string(cons (first (wordlist word)) empty))"b") true] [(equal? (list->string(cons (first (wordlist word)) empty))"c") true] [(equal? (list->string(cons (first (wordlist word)) empty))"d") true] [(equal? (list->string(cons (first (wordlist word)) empty))"e") true] [(equal? (list->string(cons (first (wordlist word)) empty))"f") true] [(equal? (list->string(cons (first (wordlist word)) empty))"g") true] [else false])) ;;tests (check-expect (check-word "face") true) (check-expect (check-word "False") false) ;;data analysis: ;;a wordlist is a helper function that ;;help to convert a sting into a list of word ;;can-play-word?: string -> boolean ;;Purpose: produce boolean value depending on whether or not a word can be played on a piano ;;by consuming a string ;;Examples: ;;(can-play-word? "face") => true ;;(can-play-word? "Dad") => false ;;(can-play-word? "apple") => false ;; (can-play-word? "lee-chin") => false (define (can-play-word? word) (cond [(empty? (wordlist word)) true] [(check-word word) (can-play-word? (list->string (rest (wordlist word))))] [else false]))

    • 2 years ago
  36. dmancine Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    Sorry, my Scheme is ancient (R5RS, circa 1997). (define (can-play-letter? letter) (and (char>=? letter #\a) (char<=? letter #\g))) (define (can-play-word? word) (or (= (string-length word) 0) (and (can-play-letter? (string-ref word 0)) (can-play-word? (substring word 1 (string-length word))))))

    • 2 years ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.