I am looking for a pattern that matches a (possibly empty) list consisting of identical (in the sense of Equal[]) atomic objects, but I can’t figure it out. Any help would be greatly appreciated.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
All of the responses so far seem to have missed the requirement that the objects being matched need to be atomic. The following does this:
If you don’t define identical in the sense of
Equalyou could have used:With a slightly modified test list you’ll see other methods fail the requirement
they all incorrectly match the 3rd element too.