const combinations = (arr, num) => {
const result = [];
const comb = (arr, n, idx, cur) => {
for (let i = idx; i <= arr.length - n; i += 1) {
cur.push(arr[i]);
if (n === 1) {
result.push([...cur]);
} else {
comb(arr, n - 1, i + 1, cur);
}
cur.pop();
}
};
comb(arr, num, 0, []);
return result;
}
console.log(combinations([1, 2, 3, 4], 3));
// Array(4) [ (3) […], (3) […], (3) […], (3) […] ]
// 0: Array(3) [ 1, 2, 3 ]
// 1: Array(3) [ 1, 2, 4 ]
// 2: Array(3) [ 1, 3, 4 ]
// 3: Array(3) [ 2, 3, 4 ]
// length: 4 x OR y OR z AND q будет выполняться как x OR y OR (z AND q), так как приоритет у AND выше, чем у OR.SELECT `time`, `ticker`, `price`, `volume`,
`icon`, `tf`, `figure`, `figure_text`
FROM `figure`
WHERE `figure` IN ('vklin', 'nklin', 'doublev', 'doubled', 'mflag', 'bflag', 'flag')
AND `tf` IN ('1h', '4h', '1d')
UNION SELECT `time`, `ticker`, `price`, `volume`,
`icon`, `tf`, `situation`, `situation_text`
FROM `levels`
WHERE `situation` = 'resistance'
AND `tf` IN ('1h', '4h', '1d') А при чем тут версия интерпретатора?Что-то из статуса deprecated перешло в removed. Какие-то ошибки вместо warning начали выдавать error.
$a = '1d 35m';
if (preg_match('/^(?:(?<days>\d+)d)?\s*(?:(?<hours>\d+)h)?\s*(?:(?<minutes>\d+)m)?\s*(?:(?<seconds>\d+)s)?$/', $a, $matches)) {
$resultSec = intval($matches['days'] ?? '') * 86400 + intval($matches['hours'] ?? '') * 3600
+ intval($matches['minutes'] ?? '') * 60 + intval($matches['seconds'] ?? '');
echo $resultSec;
} else {
echo 'error';
}
// 88500const makeTimes = (interval, elapsedTimeMin) => {
const deltaTimeMin = Math.ceil(elapsedTimeMin / 30) * 30;
const startTime = new Date(interval.start);
const endTime = new Date(interval.end);
if (startTime.getSeconds() > 0) {
startTime.setSeconds(60);
}
startTime.setMinutes(Math.ceil(startTime.getMinutes() / 30) * 30);
const result = [];
while (startTime <= endTime) {
result.push(startTime.toLocaleTimeString('ru-RU', { hour: '2-digit', minute: '2-digit' }));
startTime.setMinutes(startTime.getMinutes() + deltaTimeMin);
}
return result;
}
makeTimes({start: 'Tue Aug 30 2022 09:00:00', end: 'Tue Aug 30 2022 16:30:00'}, 20);
// Array(16) [ "09:00", "09:30", "10:00", "10:30", "11:00", "11:30", "12:00", "12:30", "13:00", "13:30", … ]
makeTimes({start: 'Tue Aug 30 2022 09:00:00', end: 'Tue Aug 30 2022 16:30:00'}, 40);
// Array(8) [ "09:00", "10:00", "11:00", "12:00", "13:00", "14:00", "15:00", "16:00" ] C D | X
0 0 | 1
0 1 | 0
1 0 | 0
1 1 | 1Получаем, X = !C!D + CDX A | Y
0 0 | 0
0 1 | 1
1 0 | 1
1 1 | 1Получаем Y = !XA + X!A + XA = !XA + X!A + XA + XA = (!XA + XA) + (X!A + XA) = A + X