Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!think!bloom-beacon!ZOHAR.AI.MIT.EDU!gjs From: gjs@ZOHAR.AI.MIT.EDU (Gerald Jay Sussman) Newsgroups: comp.lang.scheme Subject: Limitation with lambda Message-ID: <8810181343.AA00956@zohar> Date: 18 Oct 88 13:43:26 GMT References: <15590@agate.BERKELEY.EDU> Sender: daemon@bloom-beacon.MIT.EDU Organization: The Internet Lines: 30 You ask: For example, how would someone write a function generator that generates the sum of all squares or cubes or fourths, etc., based on an exponent? How 'bout: (define sum-of-powers (lambda (power) (lambda (n) (sum-of (lambda (i) (expt i power)) n)))) (define sum-of (lambda (termfun nterms) (if (= nterms 0) 0 (+ (termfun nterms) (sum-of termfun (- nterms 1)))))) ;;; e.g. ((sum-of-powers 3) 5) ;Value: 225 Does this solve your problem? If not, call me on the phone and I will try to debug you. My phone is (617) 253-5874.