This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var demand_cost = [ | |
{ peak_demand: 500, off_peak_demand: 800 }, | |
{ peak_demand: 1500, off_peak_demand: 1800 }, | |
]; | |
var energy_cost = [ | |
{ peak_energy: 600, off_peak_energy: 900 }, | |
{ peak_energy: 1600, off_peak_energy: 1900 }, | |
]; | |
function concat_obj(...arrays_obj) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Baseado em: https://www.alura.com.br/artigos/vamos-implementar-funcao-comparacao-profunda-js | |
//Foi adicionada a verificação da linha 8 para os casos em que os valores forem null. | |
export function deepStrictEqual(obj_1, obj_2) { | |
const isPrimitive = (element) => !(Object(element) === element) | |
if (isPrimitive(obj_1) && isPrimitive(obj_2)) { | |
return Object.is(obj_1, obj_2) | |
} else if(isPrimitive(obj_1) || isPrimitive(obj_2)){ | |
return false | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import deque | |
cache_values = deque(maxlen=3) | |
def cache(func): | |
def inner(*args): | |
cache_values.append(args) | |
return func(*args) | |
return inner |