This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

Yet another basic question

8 posts · 11088 views

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

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

I'm using Dr. Scheme.

Re: Yet another basic question

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

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

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.
(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

That's got it.
Thanks loads,
Kevin

Re: Yet another basic question

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.