11.5.3

5 views
Skip to first unread message

mike

unread,
Nov 9, 2009, 12:54:14 AM11/9/09
to Study-HTDP
After a long hiatus i'm back; problem12.4 really discouraged me so i
started fresh
on section 9.
ok, here is my question; exponent: nat number => number
computes the exponent of number raised to the nat power.
; still working with nat number we that will be the basis of the
recursion.
; (exponent 0 3.3) => 1
; (exponent 2 3) => 9
; (define (exp n x)
; (cond
; ((zero? n) 1)
; (else (exp (sub1 n) x) ....)
; here is my question: the problem states that you can't use scheme's
* function.The
; definitions of add and multiply we based on natural numbers. So,
how can functions we
; used for natural numbers be used for inexact number (or rational
numbers?)
; any suggestions?
thanks mike

Grant Rettke

unread,
Nov 10, 2009, 10:08:55 PM11/10/09
to Study-HTDP
Hi Mike,

Nice to hear from you!

I am on an extended hiatus, too.

You might try posting to the PLT Discussion List since there doesn't
seem to be people around here anymore.

Best wishes,

Grant

Dave

unread,
Nov 13, 2009, 12:46:14 AM11/13/09
to Study-HTDP
Hi Mike --

When I first started HtDP and came across this problem, I had the same
question. But unlike you, I ignored it. I'm nearing the end of
Section 37, and given the long-view, I can say with reasonable
certainty that you should just treat the second argument of 'exponent'
as a natural number.

Hope that helps.

Good luck!

Dave Yrueta

mike

unread,
Nov 15, 2009, 10:55:02 AM11/15/09
to Study-HTDP
Thanks Dave,
Since you are completing sec 37 and i have just completed 14.2 , What
advice would you
give? Any sections worth skipping?
mike

Dave

unread,
Nov 15, 2009, 3:02:09 PM11/15/09
to Study-HTDP
Hi Mike --

What advice would you give? Any sections worth skipping?

Probably the best advice I can give you is to always follow the steps
outlined in the design recipe before attempting to solve an exercise.
I've made the mistake of skipping the contract/purpose/template/test
case sequence on difficult problems and paid for it dearly. This is
especially true on the chapter-concluding extended exercises.

You shouldn't skip any exercises, but there are some that I found
frustrating because, in my opinion, it wasn't clear exactly what
problem was. So if you come across any like that, just holler and I'd
be glad to help spare all the hand-wringing I suffered through :).

If, like me, prior to HtDP you had no programming experience, you
might find some of the stuff on local expressions beginning in section
18 weird and/or confusing (I did). Again, if you need clarification,
I'd be happy to help.

If you've solved 12.4.2 correctly (there are incorrect solutions which
yield the correct answer) then you've solved the most difficult
problem I've encountered so far in the book. So keep on truckin'!
Reply all
Reply to author
Forward
0 new messages