Re: JESS: multislot pattern matching using "accumulate"

"Wolfgang Laun" <[email protected]>
Newsgroups gmane.comp.java.jess
Message-ID <15456_1290438934_oAMF6Gn4016172_AANLkTikP0iyPcME3UyAhM16CJ=33zDvW8pOmx-vGhnPM@mail.gmail.com>
What about storing the list in another slot of variables?

Also, the accumulate could be replaced by a Lisp function (filter)
called in the consequence, the likes of which you might have seed in
your lisping days. If you feel reckless, the actual filter can be
passed in as a lambda.

-W


On 21 November 2010 20:07, Donald Winston <[email protected]> wrote:
>
> (defrule VALIDATE:dataset-variables
>     (page "edit-dataset.xslt")
>     ?dataset <- (dataset (variables $?) (has-errors FALSE))
>     ?errors <- (accumulate (bind ?list (new java.util.ArrayList))
>                (?list add ?var)
>  ?list
> (dataset (variables $? ?var&:
>         (not (regexp "^[a-zA-Z_][a-zA-Z0-9_\\.]*$" ?var)) $?)))
> =>
>     (printout t "errors = " (?errors toString) crlf)
>     (modify ?dataset
>         ; TODO: set variablesErrors for each variable in ?errors"
>         (has-errors TRUE)))
> It looks like this works and is very cool but if I have more then one
> dataset how do I get the ?dataset and ?errors to correlate?
> test-facts.clp
> ...
> (page "edit-dataset.xslt")
> (dataset
>     (name "testdata")
>     (nobs "120")
>     (nvars "10")
>     (variables "X1" "X-2" "X3")
>     (submitEditDatasetForm "Submit"))
> ...
> This copy of Jess will expire in 106 day(s).
> executing...
> errors = [X-2]
> f-0   (MAIN::initial-fact)
> f-1   (MAIN::nextPage "edit-dataset.xslt")
> f-2   (MAIN::R nil)
> f-3   (MAIN::subscription-prices (maxDataElements 500) (monthlyPrice 25)
> (yearlyPrice 100))
> f-4   (MAIN::upload-info (uploadDirectory "/tmp/Rserv") (filename
> "test.csv") (contentType "text/plain") (contentTypeError "") (length 53)
> (format "fwf") (separationChar ",") (columnWidths "2 8 10 5 15")
> (hasColumnNames "TRUE") (submitUploadForm nil) (submitDatasetForm nil)
> (submitShowDatasetForm nil) (has-errors FALSE))
> f-5   (MAIN::page "edit-dataset.xslt")
> f-6   (MAIN::dataset (name "testdata") (nameError "") (nobs "120") (nvars
> "10") (variables "X1" "X-2" "X3") (variableErrors ) (variableTypes )
> (submitEditDatasetForm "Submit") (has-errors TRUE) (isFree TRUE))
> f-7   (MAIN::purchase-info (creditCardNumber "1408 0412 3456 7893")
> (creditCardNumberError "") (creditCardType "") (securityCode "143")
> (securityCodeError "") (expirationDate "05-2010") (expirationDateError "")
> (nameOnCard "Donald P Winston") (nameOnCardError "") (subscription nil)
> (subscriptionError "") (submitPurchaseSubscriptionForm nil) (has-errors
> FALSE))
> For a total of 8 facts in all modules.
> Donald Paul Winston
> [email protected]
>
>
>




--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [email protected]'
in the BODY of a message to [email protected], NOT to the list
(use your own address!) List problems? Notify [email protected].
--------------------------------------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.