Menu

list pattern member$ bug

Help
2024-04-30
2024-05-01
  • Chaubert Jérôme

    Hi,

    I think there's a bug with the ‘member$’ function when it's used on a list that comes from a fact. Th following code :

    (defrule start
    =>
    (assert (recoupeNomFamille noms_recoupes x mere "CROCI")))
    
    (defrule test
    ?f <- (recoupeNomFamille noms_recoupes ?x ?parent $?noms_recoupes)
    =>
    (printout t "----- length$ of ?noms_recoupes=" ?noms_recoupes " : " (length$ ?noms_recoupes) crlf)
    (printout t "----- START of progn$ on ?noms_recoupes=" ?noms_recoupes " (with varaible ?n)" crlf)
    (progn$ (?n ?noms_recoupes)
    (printout t "----- n-index=" ?n-index " n=" ?n crlf))
    (printout t "----- END of progn$" crlf)
    (printout t "----- this length$ and this progn$ show that ?nom_recoupes has exactly one element" crlf)
    (printout t "----- call of member$ : (member$ \"CROCI\" ?noms_recoupes)=(member$ \"CROCI\" " ?noms_recoupes ")=" (member$ "CROCI" ?noms_recoupes) crlf))
    

    prints

    FIRE 1 start: *
    ==> f-1 (recoupeNomFamille noms_recoupes x mere "CROCI")
    ==> Activation 0 test: f-1
    FIRE 2 test: f-1
    ----- length$ of ?noms_recoupes=("CROCI") : 1
    ----- START of progn$ on ?noms_recoupes=("CROCI") (with varaible ?n)
    ----- n-index=1 n=CROCI
    ----- END of progn$
    ----- this length$ and this progn$ show that ?nom_recoupes has exactly one element
    ----- call of member$ : (member$ "CROCI" ?noms_recoupes)=(member$ "CROCI" ("CROCI"))=4
    <== Focus MAIN

    I was expecting 1 and not 4

     
    • Gary Riley

      Gary Riley - 2024-04-30

      I checked in a fix for this bug.

       
  • Chaubert Jérôme

    Thank you for the fix. It works fine.

     

Log in to post a comment.