In the latest version of my Periodic Table work, some duplication has crept in, and I’m wondering how best to get rid of it. In three different tiddlers, I have <$let...>
statements that include among other things, three identical definitions. Is there an idiomatic way in TW to remove this duplication?
-
In $:/_/my/tools/Reactor, thanks to @telumire, I have this:
<$let elements={{{ [list[!!elements]get[symbol]join[ ]] }}} element="([A-Z][a-z]?)" not-a-letter="[^A-Za-z]" split-to-symbols="[splitregexp:m<not-a-letter>splitregexp:m<element>!is[blank]]" is-missing-elements="[enlist<elements>]-[subfilter<split-to-symbols>]" contains-wrong-elements="[subfilter<split-to-symbols>]:filter[!enlist<elements>]" exact-match="[!filter<contains-wrong-elements>!filter<is-missing-elements>]" >
-
In $:/_/my/macros/constituent-elements, I have
<$let element="([A-Z][a-z]?)" not-a-letter="[^A-Za-z]" split-to-symbols="[splitregexp:m<not-a-letter>splitregexp:m<element>!is[blank]]" >
-
and in $:/_/my/macros/containing-compounds, I have
<$let element="([A-Z][a-z]?)" not-a-letter="[^A-Za-z]" split-to-symbols="[splitregexp:m<not-a-letter>splitregexp:m<element>!is[blank]]" matcher="\b$symb$\b" >
Is there a clean way to centralize the definitions of element
, not-a-letter
, and split-to-symbols
to be used by simple calls from these three tiddlers?