Help with error :value Nil is not of expected type structure
Posted: Tue Mar 30, 2010 11:24 am
Hi,
I am new to Common lisp and I am developing a model for ACT-UP. It involves making chunks that can be learned and then they are retrieved to solve a problem. Anyways my problem lies with this lisp error I keep on getting; my code goes something like this -
when i execute (add-digit2 4 5 6 7) - i get an error stating that value Nil is not of expected type structure.
Can anyone please help ?
I am new to Common lisp and I am developing a model for ACT-UP. It involves making chunks that can be learned and then they are retrieved to solve a problem. Anyways my problem lies with this lisp error I keep on getting; my code goes something like this -
Code: Select all
(load "act-up.lisp")
(require "act-up" "act-up.lisp")
(use-package :act-up)
;;;; chunk-types
(define-chunk-type additionfact addend1 addend2 sum)
(define-chunk-type carryfact total rem carry)
;;;; defining chunks here
;;;; committing chunks to memory
(loop for a from 0 to 9 do
(loop for b from 0 to 9 do
(learn-chunk (make-additionfact
:addend1 a
:addend2 b
:sum (+ a b)))))
(loop for s from 10 to 18 do
(learn-chunk (make-carryfact
:total s
:rem (- s 10)
:carry (mod s 10))))
Code: Select all
(defrule add-digit2 (ten1 one1 ten2 one2)
(setq sumones (additionfact-sum (retrieve-chunk (list :chunk-type 'additionfact :addend1 one1 :addend2 one2))))
(setq sumtens (additionfact-sum (retrieve-chunk (list :chunk-type 'additionfact :addend1 ten1 :addend2 ten2))))
(cond ((> sumones 9)
(setq sumones (carryfact-rem (retrieve-chunk (list :chunk-type 'carryfact :total sumones))))
(setq carr (carryfact-carry (retrieve-chunk (list :chunk-type 'carryfact :total sumones))))
(setf sumtens (+ sumtens carr))))
(list sumtens sumones))
Can anyone please help ?