From jacobson@math-cs.cns.uni.edu Fri Jan 30 10:35:05 2004 Date: Fri, 30 Jan 2004 10:34:22 -0600 (CST) From: Mark Jacobson To: 810-151-04@uni.edu Subject: [810-151-04] Group Exercise, last January Scheme class... Chap 6 - February Here is one possible solution to the group exercise we did today in class: ; returns TRUE if the integer n has digits such that d1 <= d2 <= d3 ... ; returns FALSE if the digits are not in ascending order from ; most sigificant digit to ones digit. ; (Group exercise - January 30th) (define ascendingDigits? (lambda (n) (if (< n 10) #t (and (>= (modulo n 10) (modulo (quotient n 10) 10)) (ascendingDigits? (quotient n 10)))))) Welcome to DrScheme, version 205. Language: Textual (MzScheme, includes R5RS). > (ascendingDigits? 1246) #t > (ascendingDigits? 4446) #t > (ascendingDigits? 1352) #f > (ascendingDigits? 22) #t > (ascendingDigits? 13579) #t We will look at several other solutions on Monday, including coercing n into a list of single digit integers, i.e. 1234 becomes (1 2 3 4). Look at the material on coercions. Pages 36, 143, 144 and 243 cover the coerce topic, according to the index of our textbook. You can begin reading chapter six of the textbook, as we will cover that next week. Have a soup or sundae this weekend! :-) Mark