How to make if run one time each?

Started by dexter, December 29, 2013, 05:12:40 AM

Previous topic - Next topic

dexter

just say

(setq test 0)
(if (= test 0) (begin (println test) (++ test)) (= test 1) (begin (println test)))


and this output as :



> (if (= test 0) (begin (println test) (++ test)) (= test 1) (begin (println test)))
0
1


Is it different to C ?

Cause I thought (if ) only run once, so the output should be  one line , a 0



new lisp can not do it ?

HPW

#1

(silent(setq test 0))
(silent(if (= test 0) (begin (println test) (++ test)) (= test 1) (begin (println test))))


The 1 you see is the return value.
Hans-Peter

dexter

#2
Thanks



I never noticed (silent)