foreach ($list as $item)
{
if ($arList[$item["ID"]])
{
$arNums[] = $item["PHONE_NUMBER"];
$arList[$item["ID"]]["PHONE_NUMBER"] = $arNums;
continue;
}
$arList[$item["ID"]] = $item;
}
@bot.message_handler(chat_id=[], commands=['msg'])
def admin_rep(message):
if message.text == '/msg':
bot.send_message(message.chat.id, 'Введите сообщение')
bot.register_next_step_handler(message, step)
def step(message):
text = message.text
bot.send_message(message.chat.id, text)
const ul = document.querySelector("ul");
const flatAttributes = (attributes) => {
return Array.from(attributes).reduce((acc, attr) => {
acc[attr.nodeName] = attr.nodeValue;
return acc;
}, {});
};
const toJson = (element) => {
const node = {
type: element.nodeName,
props: flatAttributes(element.attributes),
children: Array.from(element.children).map(toJson),
};
return node;
};
console.log(toJson(ul));
function chunked(str, numChunks) {
const chunkSize = Math.ceil(str.length / numChunks);
return Array.from(
{ length: numChunks },
(n, i) => str.slice(i * chunkSize, (i + 1) * chunkSize)
);
}
function chunked(str, numChunks) {
return str.match(RegExp(`.{1,${Math.ceil(str.length / numChunks)}}`, 'g'));
}
function chunked(str, numChunks) {
return str.split(RegExp(`(.{${Math.ceil(str.length / numChunks)}})`)).filter(Boolean);
}
неаккуратненько как-то:
chunked('test', 3) // [ "te", "st", "" ]
const chunked = (str, numChunks) =>
numChunks <= str.length
? Array.from(
{ length: numChunks },
function(n, i) {
return str.slice(i * this, i === numChunks - 1 ? str.length : (i + 1) * this);
},
str.length / numChunks | 0
)
: 'извини, столько непустых кусков нарезать нельзя';
function chunked(str, numChunks) {
const chunkSize = str.length / numChunks | 0;
const numLooseItems = str.length % numChunks;
return Array.from(
{ length: numChunks },
function(_, i) {
return str.slice(this(i), this(i + 1));
},
i => i * chunkSize + Math.min(i, numLooseItems)
);
}
const toggleSearchParams = params => {
const newSearchParams = [...searchParams];
for (const n of params) {
const index = newSearchParams.findIndex(m => n[0] === m[0] && n[1] === m[1]);
if (index === -1) {
newSearchParams.push(n);
} else {
newSearchParams.splice(index, 1);
}
}
setSearchParams(newSearchParams);
};
const handleChangeCheckBoxValue = e => {
toggleSearchParams([ [ 'selected', e.target.value ] ]);
};
const handleDeleteParams = () => {
toggleSearchParams(checkboxParams.map(n => [ 'selected', n ]));
};
^(?: (word1) | (word2) | ... )+
(?(id/name)yes-pattern|no-pattern)
https://docs.python.org/3/library/re.html(?>...)
, которая не поддерживается в Python, но её можно имитировать с помощью позитивной опережающей проверки (?=...)
pattern = r"""
(?xm)
^
(?=
(
(?: \b (?P<a> белый | серый | красные ) \b
| \b (?P<b> бегемот[ы]? |гиппопотам[ы]? ) \b
| \b (?P<c> дикий | злой ) \b
| \w+
| [^\w\n]+
)+
)
)
(?(a)|(?!))
(?(b)|(?!))
(?(c)(?!)|)
"""
const payload = {
data: Object.fromEntries([
'раз свойство',
'два свойство',
'три свойство',
].map(n => [ n, this[n] ])),
};
bool CanExchange(int n, int have2, int have3, int have5) {
for(int take2 = 0; take2 <= min(have2, n/2); ++take2) {
int left2 = n - 2*take2;
for (int take3 = 0; take3 < min(have3, left2/3); ++take3) {
int left23 = left2 - take3*3;
if (left23 % 5 == 0 && left23 / 5 <= have5) {
return true;
}
}
}
return false;
}