Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

[SICP] Ex 1.30 / 1.31

Name: Anonymous 2008-02-10 7:46

Here's what I have

; Ex 1.30
(define (sum term a next b)
  (define (iter a result)
    (if (> a b)
        result
        (iter (next a) (+ result (term a)))))
  (iter a 0))
; Ex 1.31
(define (product term a next b)
  (define (iter a result)
    (if (> a b)
        result
        (iter (next a) (* result (term a)))))
  (iter a 1))

(define (fac n)
  (product (lambda (x) x) 1 (lambda (x) (+ x 1)) n))


Am i rite?

Name: Anonymous 2008-02-10 9:58

>>1
What is all that load of inefficientn junk, what the fuck dude?
Did you seriously had to count all that ))))) to write a sum function?


long sum(int iArray[]) {
    int iSize = strlen(iArray);
    int iCount;
    long lSum;

    for(iCount = 0; iCount < iSize; iCount++)
        lSum += iArray[iCount];

    return (lSum);
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List