Unformatted text preview: version: ;;;;; In file cs61a/lectures/2.1/total.scm (define (total hand) (if (empty? hand) (+ (rank (one-card hand)) (total (remaining-cards hand)) ))) (define rank butlast) (define suit last) (define one-card last) (define remaining-cards butlast) This is more work to type in, but the result is much more readable. IF For some reason we wanted to modiFy the program to add up the cards leFt to right instead oF right to leFt, we’d have trouble editing the original version because we wouldn’t know which butlast to change. In the new version it’s easy to keep track oF which Function does what. The auxiliary Functions like rank are called selectors because they select one component oF a multi-part datum. 284...
View Full Document
- Spring '10
- Object-Oriented Programming, Abstraction, Playing card, method overloading