Yet another basic question

Discussion of Scheme and Racket

Yet another basic question

Postby keval » Tue Jun 02, 2009 8:38 pm

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
keval
 
Posts: 6
Joined: Tue Apr 28, 2009 10:06 pm

Re: Yet another basic question

Postby Paul Donnelly » Wed Jun 03, 2009 12:56 am

What version of Scheme is that? Consult its documentation for an equivalent function. For example, PLT Scheme seems to provide TIME-APPLY.
Paul Donnelly
 
Posts: 148
Joined: Wed Jul 30, 2008 11:26 pm

Re: Yet another basic question

Postby keval » Wed Jun 03, 2009 9:31 am

I'm using Dr. Scheme.
keval
 
Posts: 6
Joined: Tue Apr 28, 2009 10:06 pm

Re: Yet another basic question

Postby gugamilare » Wed Jun 03, 2009 10:46 am

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.
gugamilare
 
Posts: 406
Joined: Sat Mar 07, 2009 6:17 pm
Location: Brazil

Re: Yet another basic question

Postby keval » Wed Jun 03, 2009 9:35 pm

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
keval
 
Posts: 6
Joined: Tue Apr 28, 2009 10:06 pm

Re: Yet another basic question

Postby Paul Donnelly » Thu Jun 04, 2009 1:49 pm

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.
Paul Donnelly
 
Posts: 148
Joined: Wed Jul 30, 2008 11:26 pm

Re: Yet another basic question

Postby keval » Thu Jun 04, 2009 8:20 pm

That's got it.
Thanks loads,
Kevin
keval
 
Posts: 6
Joined: Tue Apr 28, 2009 10:06 pm

Re: Yet another basic question

Postby duncan » Sat Jun 20, 2009 11:40 am

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.
duncan
 
Posts: 31
Joined: Wed May 27, 2009 9:07 pm


Return to Scheme

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests