compare two lists

Discussion in 'AutoCAD' started by jayasree, Oct 12, 2005.

  1. jayasree

    jayasree Guest

    i got two lists which has the insertion point and the end point

    ex ins_pt (-3.5432 4.5678)
    end_pt (-3.5432 4.5678)

    When i use (equal ins_pt end_pt) it returns nil.

    Is there any other way to compare both lists and return T.

    Thanks,
    Jayasree
     
    jayasree, Oct 12, 2005
    #1
  2. jayasree

    mguzik Guest

    If my memory is correct equal is used for comparing list and eq for
    variables.

    So using the two points above in the following will yield true:

    (setq ins_pt '(-3.5432 4.5678)
    end_pt '(-3.5432 4.5678))
    (if (equal ins_pt end_pt)
    (princ "\nThey are equal ")
    (princ "\nThey are not equal")
    )
    (princ)

    Also try with two lists that are not exactly the same with the optional
    fuzz input variable of equal:

    (setq ins_pt '(-3.5432 4.567)
    end_pt '(-3.5432 4.566))
    (if (equal ins_pt end_pt 0.005)
    (princ "\nThey are equal ")
    (princ "\nThey are not equal")
    )

    Hope this helps comparing lists
     
    mguzik, Oct 14, 2005
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.