0

I have two stacks, a goal and a stack I'm altering. As I accomplish each step of the goal-stack, I remove a field from it. I know I've finished a particular goal when that stack is now empty. I'm trying to write a rule to test when the variable is empty, but I keep getting an error: [EXPRNPSR1] A function name must be a symbol. Here is my rule.

(defrule done
   (declare (salience 30))
   ?stack <- (curr-stack $?thusfar)
   ?goal <- (goal-stack ?H)
   (test (= ?H ()))
=>
   (retract ?stack ?goal))

Any help is appreciated! Thanks!

AmberWolfe
  • 55
  • 3
  • 8

1 Answers1

0

$?foo is a multi-field variable (0 or more things in it). ?foo is a single field variable (1 thing only).

So, testing ?foo for "emptiness" won't do you much good as far as you've indicated for your stacks.

Does my multi-field variable have at least one thing in it?

(test (> (length $?foo) 0))

Is my multi-field variable empty of things?

(test (= (length $?foo) 0))
genio
  • 874
  • 6
  • 7