Skip to main content
4 events
when toggle format what by license comment
Oct 13, 2022 at 21:18 comment added userrandrand Nice, thank you.
Oct 13, 2022 at 13:53 comment added Sjoerd Smit @userrandrand It is if you want to make sure it does what you want. The pattern {x1_, y1_} also matches a matrix with 2 rows MatchQ[{{a1, a2}, {b1, b2}}, {x1_, y1_}]. You should always be careful with overlapping patterns like that. If you know exactly what kinds of input you can expect, you can usually do without these tests, but otherwise its best to be defensive.
Oct 13, 2022 at 11:42 comment added userrandrand Is the VectorQ and MatrixQ required in that case ? Would the structure fun[{x1_, y1_}] := x1; fun[{{x1_, y1_}, {x2_, y2_}}] := x2 have the same behavior?
Oct 13, 2022 at 8:25 history answered Sjoerd Smit CC BY-SA 4.0