>>> def f1(x):
... return 2 * x
...
>>> def f2(x):
... return x * x
...
>>> def g(func, start, end, step):
... while start <= end:
... yield start, func(start)
... start += step
...
>>> list(g(f1, -3, 3, 1))
[(-3, -6), (-2, -4), (-1, -2), (0, 0), (1, 2), (2, 4), (3, 6)]
>>>
>>> list(g(f2, 0, 10, 1))
[(0, 0), (1, 1), (2, 4), (3, 9), (4, 16), (5, 25), (6, 36), (7, 49), (8, 64), (9, 81), (10, 100)]
>>>
Так вот, стоит ли мне зацикливаться сейчас на этом и правда ли то, что если я не пойму этого сейчас, то никогда не пойму?
>>> import re
>>>
>>> text = """
... abc
... first:
... 10, 20, 30, 40, 50
...
... def
... second:
... 600, 700, 800, 900, 1000
...
... ghi
... """
>>>
>>> list(map(re.compile(r'\d+').findall,
... re.findall(r'(?:\d+(?:, )?)+', text)))
[['10', '20', '30', '40', '50'], ['600', '700', '800', '900', '1000']]
>>>
1) Ведь не достаточно знать один язык?
Многие советуют начать с SICP. Так ли это?
3) Обязательно ли при изучении программирования нужно чётко представлять про интерпретатор и системы счисления, как внутри всё работает и т.д.?
Не понимаю, что именно генерирует функция rand()
не понимаю зачем использовать остаток от деления
Кратко о программе которую я хочу написать. Это база данных собственных ошибок (в разных областях)
while (cond) {
f1();
f2(); f3();
}
Что за команда "`"(гравис) в командной оболочке bash?
man bash
Command Substitution
Command substitution allows the output of a command to replace the com‐
mand name. There are two forms:
$(command)
or
`command`
Bash performs the expansion by executing command and replacing the com‐
mand substitution with the standard output of the command, with any
trailing newlines deleted.
blockport_except_localhost()
{
iptables -A INPUT ! -s localhost -p tcp --dport "$1" -j DROP
iptables -A INPUT ! -s localhost -p udp --dport "$1" -j DROP
iptables -A OUTPUT ! -d localhost -p tcp --sport "$1" -j DROP
iptables -A OUTPUT ! -d localhost -p udp --sport "$1" -j DROP
}
blockport_except_localhost 80