Deleting iteration strings

16 views
Skip to first unread message

Alireza

unread,
May 3, 2011, 2:51:30 AM5/3/11
to CLIPSESG
Hi

I have a fact which contains multifield value(strings), as you see in
the following fact (A B C B D A) there are two repeated strings (A ,
B), i wanna remove them. I mean my fact becomes like this: (A B C D).
There isn't any function to do it! I wanna write a rule which do this
work by a multislot variable. Is there any way to do it?
Any help is appreciated.

Thanks

(deffacts init-facts
(string (in A B C B D A ))
)

CLIPS Support

unread,
May 3, 2011, 9:02:55 PM5/3/11
to CLIPSESG
CLIPS>
(deffunction remove-duplicates (?v)
(bind ?rv (create$))
(progn$ (?s ?v)
(if (not (member$ ?s ?rv))
then
(bind ?rv (create$ ?rv ?s))))
?rv)
CLIPS> (remove-duplicates (create$ A B C B D A))
(A B C D)
CLIPS>

Alireza

unread,
May 13, 2011, 3:32:53 PM5/13/11
to CLIPSESG
Thanks a lot clips support
Reply all
Reply to author
Forward
0 new messages