newLISP Fan Club

Forum => newLISP in the real world => Topic started by: dexter on December 29, 2013, 05:12:40 AM

Title: How to make if run one time each?
Post by: dexter on December 29, 2013, 05:12:40 AM
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 ?
Title: Re: How to make if run one time each?
Post by: HPW on December 29, 2013, 07:29:44 AM

(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.
Title: Re: How to make if run one time each?
Post by: dexter on December 30, 2013, 09:29:55 PM
Thanks



I never noticed (silent)