@fraczak/k 1.1.2 → 1.1.3
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 +3 -0
- package/codes.js +5 -1
- package/error.k +8 -0
- package/package.json +1 -1
- package/run.coffee +2 -1
- package/run.js +2 -1
- package/typed-fib.k +6 -6
package/codes.coffee
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
are_different = (classes, representatives, name1, name2, codes) ->
|
|
3
|
+
# console.log {classes, representatives, name1, name2, codes}
|
|
3
4
|
return false if name1 is name2
|
|
4
5
|
code1 = codes[name1]
|
|
5
6
|
code2 = codes[name2]
|
|
@@ -11,9 +12,11 @@ are_different = (classes, representatives, name1, name2, codes) ->
|
|
|
11
12
|
do (arg = code[code.code]) ->
|
|
12
13
|
Object.keys(arg).reduce (fields, label) ->
|
|
13
14
|
fields[label] = representatives[arg[label]] ? arg[label]
|
|
15
|
+
fields
|
|
14
16
|
, {}
|
|
15
17
|
return true unless Object.keys(fields1).length is Object.keys(fields2).length
|
|
16
18
|
for field,rep of fields1
|
|
19
|
+
# console.log {field,rep1:rep,rep2:fields2[field]}
|
|
17
20
|
return true unless fields2[field] is rep
|
|
18
21
|
when "vector"
|
|
19
22
|
[arg1,arg2] = [code1, code2]. map ({vector}) ->
|
package/codes.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
are_different = function(classes, representatives, name1, name2, codes) {
|
|
6
6
|
var arg1, arg2, code1, code2, field, fields1, fields2, rep;
|
|
7
7
|
if (name1 === name2) {
|
|
8
|
+
// console.log {classes, representatives, name1, name2, codes}
|
|
8
9
|
return false;
|
|
9
10
|
}
|
|
10
11
|
code1 = codes[name1];
|
|
@@ -20,7 +21,8 @@
|
|
|
20
21
|
return (function(arg) {
|
|
21
22
|
return Object.keys(arg).reduce(function(fields, label) {
|
|
22
23
|
var ref;
|
|
23
|
-
|
|
24
|
+
fields[label] = (ref = representatives[arg[label]]) != null ? ref : arg[label];
|
|
25
|
+
return fields;
|
|
24
26
|
}, {});
|
|
25
27
|
})(code[code.code]);
|
|
26
28
|
});
|
|
@@ -30,6 +32,8 @@
|
|
|
30
32
|
for (field in fields1) {
|
|
31
33
|
rep = fields1[field];
|
|
32
34
|
if (fields2[field] !== rep) {
|
|
35
|
+
|
|
36
|
+
// console.log {field,rep1:rep,rep2:fields2[field]}
|
|
33
37
|
return true;
|
|
34
38
|
}
|
|
35
39
|
}
|
package/error.k
ADDED
package/package.json
CHANGED
package/run.coffee
CHANGED
package/run.js
CHANGED
|
@@ -111,7 +111,8 @@
|
|
|
111
111
|
};
|
|
112
112
|
|
|
113
113
|
verify = function(code, value) {
|
|
114
|
-
//
|
|
114
|
+
// representatives = run.defs.representatives
|
|
115
|
+
// console.log {code,value,representatives}
|
|
115
116
|
switch (code.code) {
|
|
116
117
|
case "vector":
|
|
117
118
|
return value.every(function(x) {
|
package/typed-fib.k
CHANGED
|
@@ -3,14 +3,14 @@ fib2 =
|
|
|
3
3
|
$ { int target, int x, int "fib(x)", int "fib(x-1)" }
|
|
4
4
|
_log!
|
|
5
5
|
<
|
|
6
|
-
{[.target,.x]
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
.x inc x,
|
|
10
|
-
[."fib(x)", ."fib(x-1)"] PLUS "fib(x)",
|
|
6
|
+
{[.target,.x]GT.0 target ,
|
|
7
|
+
.x inc x ,
|
|
8
|
+
[."fib(x)",."fib(x-1)"]PLUS "fib(x)" ,
|
|
11
9
|
."fib(x)" "fib(x-1)" }
|
|
12
10
|
fib2,
|
|
13
|
-
|
|
11
|
+
|
|
12
|
+
{[.target,.x] EQ, ."fib(x)" result}
|
|
13
|
+
.result
|
|
14
14
|
>
|
|
15
15
|
$ int;
|
|
16
16
|
|