[plt-scheme] Question about how to get the value of function

From: Hsiu-Hao Tsao (s_h_tsao at hotmail.com)
Date: Mon May 31 09:19:47 EDT 2010

Hello plt-scheme users ,

I am new to scheme and sorry to ask a newbie question.

I want to let function return the value , for example , in Drscheme :

>(define add2 (lambda (i) (+ i i)))
>(add2 2)
4

I type (add2 2) in command line and it will return a value 4.

But when I type my function foo in the command line

>(define y '(1 2 3 4))
>(define dt 1)
>(define foo
      (lambda (t) (do ((i 0 (+ i 1))) ((> i 3)) (if (and (>= t 0) (and (>= t (* i dt)) (< t (* (+ i 1) dt)))) (list-ref y i) #f))))

>(foo 0)  ---->this should return 1 , but there is no value to come out.

>(foo 1)  ---->this should return 2
.
.
.
and so on.

Can anyone tell me how to solve this problem ? I really appreciate your knowledge and hope I won't cause your inconvenience.

Best Regards ,

Hsiu-Hao Tsao

Master Student

Ultrafast Photonics Laboratory , 
Institute Photonics of Technologies ,
National Tsing Hua University , Taiwan

Lab : +8863-5715131-34178 
Office : +8863-5715131-34007
Cell Phone : +886920158033
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20100531/ed1c32b7/attachment.html>

Posted on the users mailing list.