2017-11-11 3 views
1

私は許容された整数を多値変数でスロットに入れたい。変数でスロットに許される整数を設定することはできますか?

だから代わりに:

CLIPS> (bind ?multifieldvariable (create$ 1 3 4 7)) 
(1 3 4 7) 
CLIPS> (deftemplate bar (slot constr-integers (allowed-integers ?multifieldvariable))) 

[PRNTUTIL2] Syntax Error: Check appropriate syntax for allowed-integers attribute. 

ERROR: 
(deftemplate MAIN::bar 
    (slot constr-integers (allowed-integers ?multifieldvariable 

が、私はこの問題を回避する方法を知っているが、多分にそれを行うための方法があります:

CLIPS> (deftemplate foo (slot constr-integers (allowed-integers 1 3 4 7))) 

私はこのような何かを行うたかりましたよりエレガントな方法。

敬具、 セバスチャン

答えて

0

あなたが動的に構築関数呼び出しでdeftemplateを作成することによって、それをのみ行うことができます。

CLIPS> (bind ?multifieldvariable (create$ 1 3 4 7)) 
(1 3 4 7) 
CLIPS> 
(build (str-cat "(deftemplate bar (slot constr-integers (allowed-integers " 
       (implode$ ?multifieldvariable) 
       ")))")) 
TRUE 
CLIPS> (ppdeftemplate bar) 
(deftemplate MAIN::bar 
    (slot constr-integers (allowed-integers 1 3 4 7))) 
CLIPS> 
関連する問題