IS IT A BUG??? 
Author Message
 IS IT A BUG???

hi,
I should display the time taken by the execution of teh procedure "rec-expt" in the format h:m:s:ms
So here the code
-----------------------------------
(define (clock x)
  (define (find-hours)
    (quotient x 3600000))
  (define (rest-from-hours)
    (remainder x 3600000))
  (define (find-minutes)
    (quotient (rest-from-hours) 60000))
  (define (rest-from-minutes)
    (remainder x 60000))
  (define (find-seconds)
    (quotient (rest-from-minutes) 1000))
  (define (rest-from-seconds)
    (remainder (rest-from-minutes) 1000))
  (define (find-ms)
    (rest-from-seconds) )

  (display (find-hours))
  (display ":")
  (display (find-minutes))
  (display ":")
  (display (find-seconds))
  (display ":")
  (display (find-ms))
  (newline))

(define (rec-expt x y)
  (define (expt y)
    (if (= y 0)
        1
        (* x (expt (- y 1)))))
  (if (>= y 0)
      (expt y)
      (/ 1 (expt (abs y)))))

(clock (time (rec-expt 1 3000)))
---------------------------------------------------
So why the execution of (clock (time (rec-expt 1 3000))) returns 0:0:0:1 and not  0:0:0:50 since the execution time is equal to 50 ms.?
It seems that  the function "clock is applied to the result of "(rec-expt 1 3000)" which is actually equal to 1 and not applied to the execution time " (time (rec-expt 1 3000))" What is wrong???



Tue, 07 May 2002 03:00:00 GMT  
 IS IT A BUG???

Quote:

>So why the execution of (clock (time (rec-expt 1 3000))) returns 0:0:0:1
>and not  0:0:0:50 since the execution time is equal to 50 ms.?
>It seems that  the function "clock is applied to the result of
>"(rec-expt 1 3000)" which is actually equal to 1 and not applied to the
>execution time " (time (rec-expt 1 3000))" What is wrong???

I can't find a "time" macro in R5RS.  I suggest you read the documentation
of your implementation carefully to find out how this macro works.

If it's like Common Lisp's TIME macro, (time <expression>) is supposed to
return what <expression> returns, as well as printing out information about
how long it took.  This allows you to wrap (time ...) around existing
expressions in a program, e.g. if you have

(* (func1 ...) (func2 ...))

you can change it to

(* (time (func1 ...)) (time (func2 ...)))

and the multiplication will receive the same parameters that it would have
without the time diagnostics.

--

GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.



Thu, 09 May 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. System Bug, Or Am I Really Dense?

2. A major bug or am i Crazy (or BOTH)

3. I am clinically stupid. (fastcgi.rb bug)

4. re bug, or am I missing something?

5. BUGS, BUGS, BUGS, BUGS, C4 BUGS

6. I am not deaf, but am I mute?

7. PopupMenu bug, menu bug, apple bug (worm)?

8. BUG: Numeric Keypad Accelerator bug...

9. XP Manifest Bug or CW Bug

10. linux has bugs - all software has bug i think

11. Bugs and known bugs

12. MSWLGO32 bug is really bugging me!

 

 
Powered by phpBB® Forum Software