1
0
forked from kalmar/DALGLI0

02 JSON parser for parameters

This commit is contained in:
Kacper Kruczek 2018-07-01 15:17:38 +02:00
parent 68c43bfeb3
commit 8a28a2cfb1

View File

@ -1,18 +1,10 @@
let Polynomial = require('./polynomial.js'); let Polynomial = require('./polynomial.js');
let mul, div, gcd; let mul, div, gcd;
function parseArray(x) {
let stringResult = "";
result = Array.from(x).filter(x => {
if (x == ' ' || x == '[' || x == ']') return false;
else return true;
}).join('').split(',').map(x => parseInt(x));
return result;
}
let n = parseInt(process.argv[2]); let n = parseInt(process.argv[2]);
let p1 = parseArray(process.argv[3]); let p1 = JSON.parse(process.argv[3].replace(/'/g, '"'));
let p2 = parseArray(process.argv[4]); let p2 = JSON.parse(process.argv[4].replace(/'/g, '"'));
let f = new Polynomial.Class(n, p1); let f = new Polynomial.Class(n, p1);
let g = new Polynomial.Class(n, p2); let g = new Polynomial.Class(n, p2);