Данный отчёт сгенерирован 10.02.2023 18:21:31 UTC.
HTML версия (этот сайт) сгенерирован 10.02.2023 18:21:38 UTC.
Коммит: [bfeb65b9] add automatic zip creation 10.02.2023 18:21:31
HTML версия (этот сайт) сгенерирован 10.02.2023 18:21:38 UTC.
Коммит: [bfeb65b9] add automatic zip creation 10.02.2023 18:21:31
Задача: Додавання підрахунку викликів
10.02.2023 18:21:31
Описание: Визначте функцію decor(), яка отримує довільну функцію та повертає іншу функцію,
яка відрізняється від заданої лише тим, що має властивість count, що містить поточну кількість викликів.
Наприклад,
let h = decor ((x, y) -> x + y));
h(2, 3); h(1, 1); h(4, 5);
console.log(h.count); // 3
10.02.2023 18:21:31
Решений: 22
10.02.2023 18:21:31
Додавання підрахунку викликів
10.02.2023 18:21:31
function decor(f){
function wrapper(...args){
function counter(){
this.count+=1
}
counter.call(wrapper)
return f(...args)
}
if(wrapper.count===undefined){wrapper.count=0}
return wrapper
}
function decor(f) {
function counter(...args) {
counter.count++;
return f(...args);
}
counter.count = 0;
return counter;
}
function decor(f)
{
next.count = 0;
function next(a,b,c,d,e)
{
next.count++;
return f(a,b,c,d,e);
}
return next;
}
function decor (f) {
next.count = 0;
function next (a, b, c) {
next.count++;
return f (a, b, c);
}
return next;
}
function decor(f){
function counter(...args){
counter.count++
return f(...args)
}
counter.count = 0
return counter
}
function decor(f){
function temp(...args){
temp.count++;
return f(...args);
}
temp.count = 0
return temp
}
function decor(f) {
let g = function() {
g.count += 1;
return f(...arguments);
}
g.count = 0;
return g;
}
function decor(f) {
let g = function () {
g.count++;
return f.apply(this, arguments);
}
g.count = 0;
return g;
}
function decor(f) {
let a = function() {
a.count += 1;
return f(...arguments);
}
a.count = 0;
return a;
}
function decor(f) {
function sec(...arguments){
sec.count ++
return f(...arguments)
}
sec.count = 0
return sec
}
function decor(fn) {
let decoratedFn = function() {
decoratedFn.count++;
return fn.apply(this, arguments);
}
decoratedFn.count = 0;
return decoratedFn;
}
function decor(f){
function fun(...args){
fun.count+=1
return f(...args)
}
fun.count = 0
return fun
}
function decor(f){
f2.count = 0;
function f2(...a){
f2.count += 1;
return f(...a);
}
return f2;
}
function decor(f) {
function resultFn() {
resultFn.count++;
return f(...arguments);
};
resultFn.count = 0;
return resultFn;
}
function decor(f) {
let g = function() {
g.count += 1;
return f(...arguments);
}
g.count = 0;
return g;
}
function decor(f) {
function resultFn() {
resultFn.count++;
return f(...arguments);
};
resultFn.count = 0;
return resultFn;
}
function decor(f){
function func(...args){
func.count+=1
return f(...args)
}
func.count = 0
return func
}
function decor(f){
function func(...arg){
func.count+=1
return f(...arg)
}
func.count = 0
return func
}
function decor(func) {
function wrapper() {
wrapper.count++;
return func.apply(this, arguments);
}
wrapper.count = 0;
return wrapper;
}
function decor(f)
{
h.count = 0
function h(...arg)
{
h.count ++
return f(...arg)
}
return h
}
function decor(f) {
let h = function () {
h.count++;
const org = f.apply(f, arguments);
return org;
};
h.count = 0;
return h;
}
function decor(f) {
let g = function() {
g.count += 1;
return f(...arguments);
}
g.count = 0;
return g;
}
function wrapper(...args){
function counter(){
this.count+=1
}
counter.call(wrapper)
return f(...args)
}
if(wrapper.count===undefined){wrapper.count=0}
return wrapper
}
function counter(...args) {
counter.count++;
return f(...args);
}
counter.count = 0;
return counter;
}
{
next.count = 0;
function next(a,b,c,d,e)
{
next.count++;
return f(a,b,c,d,e);
}
return next;
}
next.count = 0;
function next (a, b, c) {
next.count++;
return f (a, b, c);
}
return next;
}
function counter(...args){
counter.count++
return f(...args)
}
counter.count = 0
return counter
}
function temp(...args){
temp.count++;
return f(...args);
}
temp.count = 0
return temp
}
let g = function() {
g.count += 1;
return f(...arguments);
}
g.count = 0;
return g;
}
let g = function () {
g.count++;
return f.apply(this, arguments);
}
g.count = 0;
return g;
}
let a = function() {
a.count += 1;
return f(...arguments);
}
a.count = 0;
return a;
}
function sec(...arguments){
sec.count ++
return f(...arguments)
}
sec.count = 0
return sec
}
let decoratedFn = function() {
decoratedFn.count++;
return fn.apply(this, arguments);
}
decoratedFn.count = 0;
return decoratedFn;
}
function fun(...args){
fun.count+=1
return f(...args)
}
fun.count = 0
return fun
}
f2.count = 0;
function f2(...a){
f2.count += 1;
return f(...a);
}
return f2;
}
function resultFn() {
resultFn.count++;
return f(...arguments);
};
resultFn.count = 0;
return resultFn;
}
let g = function() {
g.count += 1;
return f(...arguments);
}
g.count = 0;
return g;
}
function resultFn() {
resultFn.count++;
return f(...arguments);
};
resultFn.count = 0;
return resultFn;
}
function func(...args){
func.count+=1
return f(...args)
}
func.count = 0
return func
}
function func(...arg){
func.count+=1
return f(...arg)
}
func.count = 0
return func
}
function wrapper() {
wrapper.count++;
return func.apply(this, arguments);
}
wrapper.count = 0;
return wrapper;
}
{
h.count = 0
function h(...arg)
{
h.count ++
return f(...arg)
}
return h
}
let h = function () {
h.count++;
const org = f.apply(f, arguments);
return org;
};
h.count = 0;
return h;
}
let g = function() {
g.count += 1;
return f(...arguments);
}
g.count = 0;
return g;
}