1 Commits
hw5 ... lab6

Author SHA1 Message Date
4cc6b7e9d8 lab 6 done 2025-12-29 00:03:52 +10:00
2 changed files with 36 additions and 0 deletions

19
labs/lab6/lab6.js Normal file
View File

@@ -0,0 +1,19 @@
function areNumbersEqual(num1,num2,percision){
return Math.abs(num1 - num2) < percision;
}
func=(...args) => {
const percision=0.1E-2;
args.sort();
let out = "";
let lastElem = null;
for (let i = 0; i < args.length-1; i++){
if (areNumbersEqual(args[i],args[i+1],percision) && (!areNumbersEqual(args[i],lastElem,percision) || lastElem === null)){
lastElem = args[i];
out += lastElem+" ";
}
}
return out;
}
console.log(func(-0.0009111,0,-0.0009111,-0.009111,-0,1.1,1.101,2.0001,2))

17
lectures/temp.js Normal file
View File

@@ -0,0 +1,17 @@
function updateDict(dict, update) {
let key, value = update.entries()[0];
dict[key] = value + (key in dict) ? dict[key] : 0;
}
aboba={"asd":123}
upd={"asd":123}
upd1={"asd":123}
updateDict(aboba,upd1)
console.log(aboba)
updateDict(aboba,upd1)
console.log(aboba)