- Code:
`(define (enequa n)`

(if (< n 1)

1

(* (if (odd? n) n 1)

(enequa (- n 1)))))

Statistics: Posted by Goheeca — Fri Oct 17, 2014 1:55 pm

]]>

(enequa 5) = 1x3x5x7x9 = 945

(enequa 1) = 1

(enequa -2) = 1

should start

(define (enequa n)

i need help because i have o know answer to this problem after my mondy test

Statistics: Posted by PORCOREAL — Thu Oct 16, 2014 7:46 am

]]>

Statistics: Posted by saulgoode — Fri Apr 25, 2014 1:25 pm

]]>

]]>

add is not included so you get an error.

You can tell by just type inn identifiers in the interactions window before you define them and like sqrt you'll see #<procedure:sqrt> with sqrt replaced by something else.

The reason for this is unknown but I imagine it has to do with sqrt being a standard procedure in RNRS Scheme and Racket. If the package is based on one R5RS (the closest language to R3RS which were used in SICP) you will have all of the R5RS procedure and syntax that are not in direct violation of R3RS.

Statistics: Posted by sylwester — Mon Apr 21, 2014 1:44 pm

]]>

The following codes are from the book and I use the procedure "sqrt" at beginning:

- Code:
`(sqrt (+ 100 37))`

(define (sqrt-iter guess x)

(if (good-enougth? guess x)

guess

(sqrt-iter (improve guess x)

x)))

(define (improve guess x)

(average guess (/ x guess)))

(define (average x y)

(/ (+ x y) 2))

(define (good-enougth? guess x)

(< (abs (- (square guess) x)) 0.001))

(define (square x)

(* x x))

(define (sqrt x)

(sqrt-iter 1.0 x))

It worked perfactly well. But as for my understanding, you have to define a procedure before use it, right? So I don't understand how this can work?

And I do an experiment:

- Code:
`(add 2 2)`

(define (add x y)

(test x y))

(define (test x y)

(+ x y))

But this time the interpreter gave me "add: undefined; cannot reference undefined identifier", so I am totally confused about these results, can somebody explain what's going to me?

Thank you

Statistics: Posted by blackdiz — Wed Apr 16, 2014 5:50 pm

]]>

* Follow general netiquette. (e.g. other forum guidelines and stuff like http://www.catb.org/~esr/faqs/smart-questions.html)

* Demonstrate either knowledge of or interest in learning Lisp. (i.e. not "I like X. Oh, and Lisp!")

* Try to establish credibility. Show some effort. Don't make a trivial post ("me too" or "you are so helpful"), or plagiarize, or do other spammy things.

* Don't revive long-dead threads. (thread necromancy)

* Start a new thread instead of hijacking an old one.

* Don't include links to unrelated sites.

* Don't link to executable files. Link to projects hosting them instead. (malware concern)

Statistics: Posted by nuntius — Sun Mar 02, 2014 8:44 pm

]]>

Is this a homework problem?

Statistics: Posted by nuntius — Thu Oct 03, 2013 9:18 am

]]>

]]>

Exercise 2.58 in SICP takes a slightly different approach.

Statistics: Posted by nuntius — Wed May 08, 2013 9:55 pm

]]>