This commit is contained in:
2018-06-04 21:02:05 +02:00
parent 33e378fcd1
commit fd0ea53218
4 changed files with 19 additions and 7 deletions

View File

@@ -41,7 +41,7 @@ const zip = (a, b) => a.map((e, i) => [e, b[i]]);
const check_represent = function(r, v) {
if (typeof v == "number") return to_int(r) == v;
if (typeof v == "boolean") return to_bool(r) == v;
if (typeof v == "string") { console.log("checking ", to_array(r).map(to_int), " against ", v); return to_string(r) == v; }
if (typeof v == "string") return to_string(r) == v;
if (Array.isArray(v)) {
let a = to_array(r);
return a.length == v.length && zip(a, v).every(([r, v]) => check_represent(r,v));
@@ -49,5 +49,5 @@ const check_represent = function(r, v) {
throw Error(`Oops, I dont know how check this: ${v}`);
};
module.exports = {
to_string, to_array, representation_of, check_represent, to_int, to_char
representation_of, check_represent
};