SameTest option pertaining to Union operation in Mathematica.

Discussion in 'Math Software' started by Ratch, Oct 16, 2021.

  1. Ratch

    Ratch

    Joined:
    Oct 16, 2021
    Messages:
    1
    Likes Received:
    0
    The documentation for SameTest given by Mathematica is very sketchy. I simply do no understand how it works. The example given by Mathematica for SameTest shown boils down to:

    Union[{-5, 0, 2, 3, 4}, SameTest -> (Mod[#1, 3] == Mod[#2, 3] &)]

    which gives

    {-5, 0, 2}

    Now, Mod[{-5, 0, 2, 3, 4}, 3] gives

    {1, 0, 2, 0, 1}

    which should show 4 false comparisons. I do not understand how the result in the example was obtained.

    Anyhow, could someone tell me in concise terms what SameTest does when the test result is is true and what it does when the test result is false. I would appreciate a step by step trace of the above simple example. Thanks.
     
    Ratch, Oct 16, 2021
    #1
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.
Similar Threads
There are no similar threads yet.
Loading...