Quiz 3, CS 257

name or user id on aix.unm.edu ______________
  1. What values are printed when you type each of the following to Scheme? (2 points each)
    expressionresult
    (every - '(3 -5 -8 13)) 
    (keep (lambda (x) (< x 10))
          '(1 12 3 14 5 16))
     
    (define (foo x y)
       (+ (last x) (last y)))

    (accumulate foo '(321 432 543))
     
    (count (keep even? '(11 12 13 14 15))) 
    (+ 10 ((if (equal? 'a 'b) + *) 2 3)) 

  2. Define a function sum-big-ones that takes a sentence of numbers as its sole argument, and returns the sum of all the elements of the sentence greater than 14. (Use higher order functions, not recursion.) (10 points)

    For example (sum-big-ones '(1 20 5 30)) evaluates to 20+30=50.

    
    
    
    
    
    
    
    
    
    
    
    
    

  3. Extra credit: explain briefly in English what foo does and how it works. (5 points)
    (define (foo sen)
      (accumulate (lambda (x y)
    		(if (> (count x) (count y)) x y))
    	      sen))