use chez scheme to execute current s-expression

96 views Asked by At

I want to pass the current line of s-expression to scheme interpreter and execute it , how should I do ?

I use Chez Scheme Petite as the interpreter , however , if I pass a file to it , it just sets up the environment , I just want to pass the code to it and run the code and get the results printed .

For example , I have such code

(define fact    
  (lambda (n)    
    (cond ((= n 1) 1)    
      (else (* n (fact (- n 1)))))))    

(fact 5)

and save it as fact.ss ;

If I run it in cmd , petite fact.ss , I can only set up the environment , I need to reenter (fact 5) after ">" , then get the result print .

1

There are 1 answers

0
C. K. Young On BEST ANSWER

You are executing it. However, since you're doing nothing with the return value of (fact 5), it just gets thrown away.

Perhaps you should try (display (fact 5)) instead.