Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Gerwitz <mike.gerwitz@rtspecialty.com>2018-01-09 13:30:49 -0500
committerMike Gerwitz <mike.gerwitz@rtspecialty.com>2018-09-11 09:30:51 -0400
commitadbf67abf3b6d076502060e3f4c96e960ae86452 (patch)
treea64a333001294078f1e8aeacf7d3f07ad95780ec
parentf4b42136d05581b16255f89235f363dc728f6376 (diff)
downloadtame-adbf67abf3b6d076502060e3f4c96e960ae86452.tar.gz
tame-adbf67abf3b6d076502060e3f4c96e960ae86452.tar.bz2
tame-adbf67abf3b6d076502060e3f4c96e960ae86452.zip
state: Add _for-each-state_ and state-all
* states.xml (_for-each-state_): Add template. (NVEC_STATE_ALL): Add vector. (state-all): Add class.
-rw-r--r--core/states.xml106
1 files changed, 105 insertions, 1 deletions
diff --git a/core/states.xml b/core/states.xml
index 1d1e7f0..1ee1f24 100644
--- a/core/states.xml
+++ b/core/states.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
- Copyright (C) 2017 R-T Specialty, LLC.
+ Copyright (C) 2017, 2018 R-T Specialty, LLC.
This file is part of tame-core.
@@ -19,9 +19,13 @@
-->
<package xmlns="http://www.lovullo.com/rater"
xmlns:c="http://www.lovullo.com/calc"
+ xmlns:t="http://www.lovullo.com/rater/apply-template"
core="true"
desc="United States">
+ <import package="base" />
+ <import package="vector/stub" />
+
<section title="States">
The type \ref{State} contains each of the States in the United~States,
@@ -87,4 +91,104 @@
</enum>
</typedef>
</section>
+
+
+
+ <section title="State Operations">
+ For operations that involve taking values of all states where order
+ matters (e.g. for index alignment),
+ querying the symbol table isn't appropriate,
+ as it does not guarantee order.
+ \ref{_for-each-state_} can be used for that purpose;
+ it exposes the following template values to its body:
+
+ \begin{enumerate}
+ \item \tt{@state_const@} contains the State constant;
+ \item \tt{@state_upper@} contains the uppercase two-letter State
+ abbreviation;
+ \item \tt{@state_lower@} contains the lowercase two-letter State
+ abbreviation; and
+ \item \tt{@state_name@} contains the full state name.
+ \end{enumerate}
+
+ This can be used to generate a ^[State vector] by mapping an iteration
+ index to the State constant~\tt{@state_const@}.
+ Note that \ref{STATE_NONE} is not in the list.
+
+ <template name="_for-each-state_"
+ desc="Apply body for each State">
+ <param name="@values@" desc="Body to apply per State" />
+
+
+ <inline-template>
+ <for-each>
+ <set state_const="STATE_AK" state_upper="AK" state_lower="ak" state_name="Alaska" />
+ <set state_const="STATE_AL" state_upper="AL" state_lower="al" state_name="Alabama" />
+ <set state_const="STATE_AR" state_upper="AR" state_lower="ar" state_name="Arkansas" />
+ <set state_const="STATE_AZ" state_upper="AZ" state_lower="az" state_name="Arizona" />
+ <set state_const="STATE_CA" state_upper="CA" state_lower="ca" state_name="California" />
+ <set state_const="STATE_CO" state_upper="CO" state_lower="co" state_name="Colorado" />
+ <set state_const="STATE_CT" state_upper="CT" state_lower="ct" state_name="Connecticut" />
+ <set state_const="STATE_DC" state_upper="DC" state_lower="dc" state_name="Washington DC" />
+ <set state_const="STATE_DE" state_upper="DE" state_lower="de" state_name="Delaware" />
+ <set state_const="STATE_FL" state_upper="FL" state_lower="fl" state_name="Florida" />
+ <set state_const="STATE_GA" state_upper="GA" state_lower="ga" state_name="Georgia" />
+ <set state_const="STATE_HI" state_upper="HI" state_lower="hi" state_name="Hawaii" />
+ <set state_const="STATE_IA" state_upper="IA" state_lower="ia" state_name="Iowa" />
+ <set state_const="STATE_ID" state_upper="ID" state_lower="id" state_name="Idaho" />
+ <set state_const="STATE_IL" state_upper="IL" state_lower="il" state_name="Illinois" />
+ <set state_const="STATE_IN" state_upper="IN" state_lower="in" state_name="Indiana" />
+ <set state_const="STATE_KS" state_upper="KS" state_lower="ks" state_name="Kansas" />
+ <set state_const="STATE_KY" state_upper="KY" state_lower="ky" state_name="Kentucky" />
+ <set state_const="STATE_LA" state_upper="LA" state_lower="la" state_name="Louisiana" />
+ <set state_const="STATE_MA" state_upper="MA" state_lower="ma" state_name="Massachusetts" />
+ <set state_const="STATE_MD" state_upper="MD" state_lower="md" state_name="Maryland" />
+ <set state_const="STATE_ME" state_upper="ME" state_lower="me" state_name="Maine" />
+ <set state_const="STATE_MI" state_upper="MI" state_lower="mi" state_name="Michigan" />
+ <set state_const="STATE_MN" state_upper="MN" state_lower="mn" state_name="Minnesota" />
+ <set state_const="STATE_MO" state_upper="MO" state_lower="mo" state_name="Missouri" />
+ <set state_const="STATE_MS" state_upper="MS" state_lower="ms" state_name="Mississippi" />
+ <set state_const="STATE_MT" state_upper="MT" state_lower="mt" state_name="Montana" />
+ <set state_const="STATE_NC" state_upper="NC" state_lower="nc" state_name="North Carolina" />
+ <set state_const="STATE_ND" state_upper="ND" state_lower="nd" state_name="North Dakota" />
+ <set state_const="STATE_NE" state_upper="NE" state_lower="ne" state_name="Nebraska" />
+ <set state_const="STATE_NH" state_upper="NH" state_lower="nh" state_name="New Hampshire" />
+ <set state_const="STATE_NJ" state_upper="NJ" state_lower="nj" state_name="New Jersey" />
+ <set state_const="STATE_NM" state_upper="NM" state_lower="nm" state_name="New Mexico" />
+ <set state_const="STATE_NV" state_upper="NV" state_lower="nv" state_name="Nevada" />
+ <set state_const="STATE_NY" state_upper="NY" state_lower="ny" state_name="New York" />
+ <set state_const="STATE_OH" state_upper="OH" state_lower="oh" state_name="Ohio" />
+ <set state_const="STATE_OK" state_upper="OK" state_lower="ok" state_name="Oklahoma" />
+ <set state_const="STATE_OR" state_upper="OR" state_lower="or" state_name="Oregon" />
+ <set state_const="STATE_PA" state_upper="PA" state_lower="pa" state_name="Pennsylvania" />
+ <set state_const="STATE_RI" state_upper="RI" state_lower="ri" state_name="Rhode Island" />
+ <set state_const="STATE_SC" state_upper="SC" state_lower="sc" state_name="South Carolina" />
+ <set state_const="STATE_SD" state_upper="SD" state_lower="sd" state_name="South Dakota" />
+ <set state_const="STATE_TN" state_upper="TN" state_lower="tn" state_name="Tennessee" />
+ <set state_const="STATE_TX" state_upper="TX" state_lower="tx" state_name="Texas" />
+ <set state_const="STATE_UT" state_upper="UT" state_lower="ut" state_name="Utah" />
+ <set state_const="STATE_VA" state_upper="VA" state_lower="va" state_name="Virginia" />
+ <set state_const="STATE_VT" state_upper="VT" state_lower="vt" state_name="Vermont" />
+ <set state_const="STATE_WA" state_upper="WA" state_lower="wa" state_name="Washington" />
+ <set state_const="STATE_WI" state_upper="WI" state_lower="wi" state_name="Wisconsin" />
+ <set state_const="STATE_WV" state_upper="WV" state_lower="wv" state_name="West Virginia" />
+ <set state_const="STATE_WY" state_upper="WY" state_lower="wy" state_name="Wyoming" />
+ </for-each>
+
+ <param-copy name="@values@" />
+ </inline-template>
+ </template>
+
+
+ To ease iteration though ^[State vector]s generated with
+ \ref{_for-each-state_},
+ a 52~vector \ref{NVEC_STATE_ALL} and classification \ref{state-all}
+ are provided.
+
+ <t:n-vector n="52" name="NVEC_STATE_ALL" value="1" />
+
+ <classify as="state-all" desc="Every State in a State vector">
+ <match on="NVEC_STATE_ALL" />
+ </classify>
+ </section>
</package>