This preview shows page 1. Sign up to view the full content.
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
This note was uploaded on 02/17/2010 for the course COMPUTER S 26275 taught by Professor Harvey,b during the Spring '10 term at Berkeley.
- Spring '10