List manipulation in CLIPS (expert system) -


i want function print on item per line. trying:

(deffunction myprint (?first $?rest) (if (neq ?rest nil)     (printout t ?first crlf)     (myprint ?rest))) 

what wrong?

use length function determine if list empty (a return value of 0). comparing list symbol nil fail.

you want print ?first if ?rest empty. otherwise last element never printed.

it not necessary use recursion.

clips>  (deffunction myprint ($?rest)    (foreach ?r $?rest       (printout t ?r crlf))) clips> (myprint b c) b c clips> (myprint (create$ b) (create$ c d)) b c d clips> 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -