Timeline for Confusion over blank sequence in pattern matching
Current License: CC BY-SA 3.0
8 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jul 29, 2015 at 13:55 | vote | accept | Jack LaVigne | ||
| Jul 29, 2015 at 13:39 | comment | added | Jack LaVigne | @march graphicsList /. {Longest[x__?NumericQ], z__} -> {z} works perfectly. Thank you | |
| Jul 29, 2015 at 13:28 | vote | accept | Jack LaVigne | ||
| Jul 29, 2015 at 13:50 | |||||
| Jul 29, 2015 at 4:38 | answer | added | Mr.Wizard | timeline score: 6 | |
| Jul 29, 2015 at 2:34 | comment | added | march | I think pattern matching is greedy from the end of the list, so z__ matches as much as it can first, leaving x__ to match the 1. (That might not be quite right, but it has been my working principle up to now.) That's why the recommendation for using Longest[x__?NumericQ] in a previous comment. | |
| Jul 29, 2015 at 0:31 | comment | added | Bob Hanlon | graphicsList = DeleteCases[Union[Flatten[rp3D //. f_[x__] /; UnsameQ[f, List] -> {f, x}]], _?NumericQ] or graphicsList = Union[Flatten[rp3D //. f_[x__] /; UnsameQ[f, List] -> {f, x}]] /. _?NumericQ :> Sequence[] | |
| Jul 29, 2015 at 0:24 | comment | added | ilian | See Longest | |
| Jul 29, 2015 at 0:13 | history | asked | Jack LaVigne | CC BY-SA 3.0 |