I'm trying to build a head that recognizes molecules. Here's the code
Mol::arg = "Invalid molecule.";
Mol[Except[Subscript[_String, _Integer] ..]] := Message[Mol::arg]
I'd expect that this code should recognize molecules of the form
Mol[Subscript["C", 4], Subscript["N", 5]]
but it should issue the message if something like
Mol[Subscript["C", 4], 7]
is entered. However, when I enter this last one, no message is issued. I don't understand what I'm doing wrong.
molecule=Sequence@@Table[Subscript[RandomChoice[{"C","N","S","H"}],RandomInteger[{1,500}]],{i,1,1000}]– a06e May 20 '12 at 16:47{Timing[Mol1[molecule];], Timing[Mol2[molecule];]}– a06e May 20 '12 at 16:47{{0., Null}, {0.015, Null}}. – a06e May 20 '12 at 16:48