Page 1 of 1

Yet another basic question

Posted: Tue Jun 02, 2009 8:38 pm
by keval
Greetings.
I'm working my way through "Structure and Interpretation of Computer Programs" and am working on a program that calls for the use of the primitive "runtime" as a way to measure how long it took the computer to calculate the answer. Unfortunately, my version of Scheme doesn't recognize "runtime." Any ideas on solutions or work-arounds?
Thanks,
Kevin

Re: Yet another basic question

Posted: Wed Jun 03, 2009 12:56 am
by Paul Donnelly
What version of Scheme is that? Consult its documentation for an equivalent function. For example, PLT Scheme seems to provide TIME-APPLY.

Re: Yet another basic question

Posted: Wed Jun 03, 2009 9:31 am
by keval
I'm using Dr. Scheme.

Re: Yet another basic question

Posted: Wed Jun 03, 2009 10:46 am
by gugamilare
keval wrote:I'm using Dr. Scheme.
DrScheme is an interactive, integrated, graphical programming environment that is included with PLT Scheme.
You can use time-apply.

Re: Yet another basic question

Posted: Wed Jun 03, 2009 9:35 pm
by keval
I think that's it. Can you give me a quick and dirty example of how to use time-apply? It seems to want two arguments (first a procedure, then a list). It's not following the same form as "runtime."
Many thanks

Re: Yet another basic question

Posted: Thu Jun 04, 2009 1:49 pm
by Paul Donnelly
keval wrote:I think that's it. Can you give me a quick and dirty example of how to use time-apply? It seems to want two arguments (first a procedure, then a list). It's not following the same form as "runtime."
Many thanks
It works just like regular apply.

Code: Select all

(foo 'a 'b 'c) is the same as (apply foo '(a b c))
TIME-APPLY just does timing on top of applying.

Re: Yet another basic question

Posted: Thu Jun 04, 2009 8:20 pm
by keval
That's got it.
Thanks loads,
Kevin

Re: Yet another basic question

Posted: Sat Jun 20, 2009 11:40 am
by duncan
Luckily there's not a lot of implementation specific stuff in SICP, so you can probably use any Scheme you want. But I think it was written with MIT scheme in mind. MIT scheme is free (and actually it was one of the really early pieces of free software in the FSF sense- I think Sussman is still on the FF board.)

Anyway, I doubt you'll run into a lot of issues like this in SICP, so there's no big reason to switch if you like Dr. Ed, etc. But you could also use MIT Scheme. You'd probably want to use Emacs for that, but I think it's not a bad idea to get used to emacs if you want to do Lisp. I've never been very crazy about Dr. Scheme's user interface, and I find it hard to imagine actually doing real work in it, though YMMV.

Anyway, like I said, it probably doesn't make much difference. I actually got a friend of mine going in CL by installing Lispworks on his laptop and then working through the first parts of SICP in CL with him. Part of what's nice about SICP is that it deals in the eternal verities a lot more than it deals in the specifics of the platform.