Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMike Gerwitz <mike.gerwitz@rtspecialty.com>2019-10-17 09:16:45 -0400
committerMike Gerwitz <mike.gerwitz@rtspecialty.com>2019-10-17 09:16:45 -0400
commit39c7161cca85a58c872c569f636c89a0e09a5735 (patch)
tree7f1f1becd3f7e44c9bd79f07c0ed263cef26ebab /core
parentce0e31032b0a0c4d6fc2cb5c837beb9d03afc69b (diff)
downloadtame-39c7161cca85a58c872c569f636c89a0e09a5735.tar.gz
tame-39c7161cca85a58c872c569f636c89a0e09a5735.tar.bz2
tame-39c7161cca85a58c872c569f636c89a0e09a5735.zip
vector/define: New package introducing _define-vector_
This is intended to work around the issue of defining arbitrary vectors outside of a c:let.
Diffstat (limited to 'core')
-rw-r--r--core/test/core/suite.xml1
-rw-r--r--core/test/core/vector/define.xml49
-rw-r--r--core/vector/define.xml65
3 files changed, 115 insertions, 0 deletions
diff --git a/core/test/core/suite.xml b/core/test/core/suite.xml
index c99bfe5..aa62b6d 100644
--- a/core/test/core/suite.xml
+++ b/core/test/core/suite.xml
@@ -30,6 +30,7 @@
<import package="numeric/percent" />
<import package="numeric/round" />
+ <import package="vector/define" />
<import package="vector/filter" />
<import package="vector/fold" />
<import package="vector/interpolate" />
diff --git a/core/test/core/vector/define.xml b/core/test/core/vector/define.xml
new file mode 100644
index 0000000..50129f6
--- /dev/null
+++ b/core/test/core/vector/define.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<!--
+ Copyright (C) 2014-2019 Ryan Specialty Group, LLC.
+
+ This file is part of tame-core.
+
+ tame-core is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+-->
+<package xmlns="http://www.lovullo.com/rater"
+ xmlns:c="http://www.lovullo.com/calc"
+ xmlns:t="http://www.lovullo.com/rater/apply-template"
+ desc="Vector definition specs">
+
+ <import package="../../spec" />
+
+ <import package="../../../base" />
+ <import package="../../../vector/define" />
+
+
+ <t:describe name="_define-vector_">
+ <t:it desc="defines a global vector">
+ <t:define-vector generates="testVector">
+ <c:vector>
+ <c:value-of name="#1" />
+ <c:value-of name="#2" />
+ </c:vector>
+ </t:define-vector>
+
+ <t:given>
+ <c:sum of="testVector" />
+ </t:given>
+
+ <t:expect>
+ <t:match-result eq="3" />
+ </t:expect>
+ </t:it>
+ </t:describe>
+</package>
diff --git a/core/vector/define.xml b/core/vector/define.xml
new file mode 100644
index 0000000..03f1652
--- /dev/null
+++ b/core/vector/define.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ Copyright (C) 2014-2019 Ryan Specialty Group, LLC.
+
+ This file is part of tame-core.
+
+ tame-core is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+-->
+<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="Vector definition">
+
+ This package provides a type of global~\tt{let}.
+ The term ``define'' is consistent with the influence of the language
+ Scheme on this system.
+ One a primitive is provided,
+ this abstraction can be modified to make use of it.
+
+ This addresses the challenge with defining arbitrary values.
+ TAME was designed for a map-reduce style of computation that
+ maintains index assocaitions.
+ This makes it easy to reason about data flow.
+
+ Consequently,
+ arbitrary definitions should be used sparingly until they become a core
+ feature of TAME.
+
+
+ <template name="_define-vector_"
+ desc="Define a vector with an arbitrary value">
+ <param name="@values@" desc="Definition" />
+ <param name="@generates@" desc="Vector name" />
+
+
+ <rate yields="_{@generates@}">
+ <c:let>
+ <c:values>
+ <c:value name="value" type="float" set="vector"
+ desc="Value to produce">
+ <param-copy name="@values@" />
+ </c:value>
+ </c:values>
+
+ <!-- effectively means @generates@ = value -->
+ <c:sum of="value" generates="@generates@" index="k"
+ desc="Return value">
+ <c:value-of name="value" index="k" />
+ </c:sum>
+ </c:let>
+ </rate>
+ </template>
+</package>