@fraczak/k 1.1.3 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/codes.coffee +1 -1
- package/codes.js +2 -1
- package/package.json +1 -1
- package/run.coffee +2 -1
- package/run.js +2 -1
- package/test.coffee +14 -0
- package/test.js +30 -0
package/codes.coffee
CHANGED
|
@@ -102,7 +102,7 @@ normalizeAll = (codes,representatives) ->
|
|
|
102
102
|
normalized[name] = { code: code.code }
|
|
103
103
|
normalized[name][code.code] = normalize code[code.code], representatives
|
|
104
104
|
when "vector"
|
|
105
|
-
normalized[name] = {code:"vector", vector: representatives[code.vector]}
|
|
105
|
+
normalized[name] = {code:"vector", vector: representatives[code.vector] ? code.vector}
|
|
106
106
|
|
|
107
107
|
normalized
|
|
108
108
|
, {}
|
package/codes.js
CHANGED
|
@@ -156,6 +156,7 @@
|
|
|
156
156
|
return normalized = names.reduce(function(normalized, name) {
|
|
157
157
|
if (name === representatives[name]) {
|
|
158
158
|
(function(code) {
|
|
159
|
+
var ref;
|
|
159
160
|
switch (code.code) {
|
|
160
161
|
case "union":
|
|
161
162
|
case "product":
|
|
@@ -166,7 +167,7 @@
|
|
|
166
167
|
case "vector":
|
|
167
168
|
return normalized[name] = {
|
|
168
169
|
code: "vector",
|
|
169
|
-
vector: representatives[code.vector]
|
|
170
|
+
vector: (ref = representatives[code.vector]) != null ? ref : code.vector
|
|
170
171
|
};
|
|
171
172
|
}
|
|
172
173
|
})(codes[name]);
|
package/package.json
CHANGED
package/run.coffee
CHANGED
|
@@ -49,7 +49,8 @@ codes =
|
|
|
49
49
|
|
|
50
50
|
verify = (code, value) ->
|
|
51
51
|
# representatives = run.defs.representatives
|
|
52
|
-
#
|
|
52
|
+
# defCodes = JSON.stringify run.defs.codes
|
|
53
|
+
# console.log {code,value, representatives, defCodes}
|
|
53
54
|
switch code.code
|
|
54
55
|
when "vector"
|
|
55
56
|
value.every (x) ->
|
package/run.js
CHANGED
|
@@ -112,7 +112,8 @@
|
|
|
112
112
|
|
|
113
113
|
verify = function(code, value) {
|
|
114
114
|
// representatives = run.defs.representatives
|
|
115
|
-
//
|
|
115
|
+
// defCodes = JSON.stringify run.defs.codes
|
|
116
|
+
// console.log {code,value, representatives, defCodes}
|
|
116
117
|
switch (code.code) {
|
|
117
118
|
case "vector":
|
|
118
119
|
return value.every(function(x) {
|
package/test.coffee
CHANGED
|
@@ -48,3 +48,17 @@ console.log ""
|
|
|
48
48
|
console.log "k_fn(#{JSON.stringify(data)});"
|
|
49
49
|
console.log "// RETURNS: #{JSON.stringify k_fn data}"
|
|
50
50
|
console.log ""
|
|
51
|
+
|
|
52
|
+
k_expression = "$ < < [ int ] ints, [ bool ] bools > list, string None>"
|
|
53
|
+
k_fn = k.compile k_expression
|
|
54
|
+
console.log "var k_fn = k.compile('#{k_expression}');"
|
|
55
|
+
console.log ""
|
|
56
|
+
|
|
57
|
+
[
|
|
58
|
+
{None: "None"}
|
|
59
|
+
{list: {ints: []}}
|
|
60
|
+
{list: {ints: [1,2,3]}}
|
|
61
|
+
].map (data) ->
|
|
62
|
+
console.log "k_fn(#{JSON.stringify(data)});"
|
|
63
|
+
console.log "// RETURNS: #{JSON.stringify k_fn data}"
|
|
64
|
+
console.log ""
|
package/test.js
CHANGED
|
@@ -116,4 +116,34 @@
|
|
|
116
116
|
return console.log("");
|
|
117
117
|
});
|
|
118
118
|
|
|
119
|
+
k_expression = "$ < < [ int ] ints, [ bool ] bools > list, string None>";
|
|
120
|
+
|
|
121
|
+
k_fn = k.compile(k_expression);
|
|
122
|
+
|
|
123
|
+
console.log(`var k_fn = k.compile('${k_expression}');`);
|
|
124
|
+
|
|
125
|
+
console.log("");
|
|
126
|
+
|
|
127
|
+
[
|
|
128
|
+
{
|
|
129
|
+
None: "None"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
list: {
|
|
133
|
+
ints: []
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
list: {
|
|
138
|
+
ints: [1,
|
|
139
|
+
2,
|
|
140
|
+
3]
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
].map(function(data) {
|
|
144
|
+
console.log(`k_fn(${JSON.stringify(data)});`);
|
|
145
|
+
console.log(`// RETURNS: ${JSON.stringify(k_fn(data))}`);
|
|
146
|
+
return console.log("");
|
|
147
|
+
});
|
|
148
|
+
|
|
119
149
|
}).call(this);
|