{"id":193920,"date":"2013-09-16T17:03:03","date_gmt":"2013-09-16T13:03:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=193920"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=193920","title":{"rendered":"<span class=\"post_title\">\u041d\u0435\u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 python<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t<img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/e6a\/b6b\/275\/e6ab6b2751326e14cce18b1ece778198.png\" align=\"right\"\/><br \/>  \u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u043a\u0443\u0440\u0441\u0430 <a href=\"https:\/\/www.coursera.org\/course\/proglang\">Programming Languages<\/a> \u0438 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u044f <a href=\"http:\/\/shop.oreilly.com\/product\/0636920028857.do\">Functional JavaScript<\/a> \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c \u0432\u0441\u0435 \u044d\u0442\u0438 \u043a\u0440\u0443\u0442\u044b\u0435 \u0448\u0442\u0443\u043a\u0438 \u0432 python. \u0427\u0430\u0441\u0442\u044c \u0432\u0435\u0449\u0435\u0439 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u0438 \u043b\u0435\u0433\u043a\u043e, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u044b\u0448\u043b\u043e \u0441\u0442\u0440\u0430\u0448\u043d\u044b\u043c \u0438 \u043d\u0435\u043f\u0440\u0438\u0433\u043e\u0434\u043d\u044b\u043c \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>  \u0421\u0442\u0430\u0442\u044c\u044f \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f:  <\/p>\n<ul>\n<li>\u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0445 \u0441\u043b\u043e\u0432;<\/li>\n<li>\u043a\u0430\u0440\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435;<\/li>\n<li>pattern matching;<\/li>\n<li>\u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044f (\u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0445\u0432\u043e\u0441\u0442\u043e\u0432\u0443\u044e).<\/li>\n<\/ul>\n<p>  \u0421\u0442\u0430\u0442\u044c\u044f \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d\u0430 \u043d\u0430 python 3.3+.<a name=\"habracut\"><\/a><\/p>\n<h3>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0445 \u0441\u043b\u043e\u0432<\/h3>\n<p>  \u041d\u0430 python \u043c\u043e\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0442\u0438\u043b\u0435, \u0432\u0435\u0434\u044c \u0432 \u043d\u0435\u043c \u0435\u0441\u0442\u044c \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:  <\/p>\n<pre><code class=\"python\">sum_x_y = lambda x, y: x + y print(sum_x_y(1, 2))  # 3 <\/code><\/pre>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u044b\u0441\u0448\u0435\u0433\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0430 (\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0438\u0435 \u0438\u043b\u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438):  <\/p>\n<pre><code class=\"python\">def call_and_twice(fnc, x, y):     return fnc(x, y) * 2  print(call_and_twice(sum_x_y, 3, 4))  # 14 <\/code><\/pre>\n<p>  \u0417\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f:  <\/p>\n<pre><code class=\"python\">def closure_sum(x):     fnc = lambda y: x + y     return fnc  sum_with_3 = closure_sum(3) print(sum_with_3(12))  # 15 <\/code><\/pre>\n<p>  Tuple unpacking(\u043f\u043e\u0447\u0442\u0438 pattern matching):  <\/p>\n<pre><code class=\"python\">a, b, c = [1, 2, 3] print(a, b, c)  # 1 2 3 hd, *tl = range(5) print(hd, 'tl:', *tl)  # 0 tl: 1 2 3 4 <\/code><\/pre>\n<p>  \u0418 \u043a\u0440\u0443\u0442\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438 <a href=\"http:\/\/docs.python.org\/3.3\/library\/functools.html\">functools<\/a> \u0438 <a href=\"http:\/\/docs.python.org\/3.3\/library\/itertools.html\">itertools<\/a>.<\/p>\n<h2>\u041a\u0430\u0440\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h2>\n<p>  <\/p>\n<blockquote><p>\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0442 \u043c\u043d\u043e\u0433\u0438\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0431\u0435\u0440\u0443\u0449\u0443\u044e \u0441\u0432\u043e\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443.<\/p><\/blockquote>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043b\u0443\u0447\u0430\u0439, \u043a\u0430\u0440\u0440\u0438\u0440\u0443\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>sum_x_y<\/code>:  <\/p>\n<pre><code class=\"python\">sum_x_y_carry = lambda x: lambda y: sum_x_y(x, y) print(sum_x_y_carry(5)(12))  # 17 <\/code><\/pre>\n<p>  \u0427\u0442\u043e-\u0442\u043e \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u043a\u0440\u0443\u0442\u043e, \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"python\">sum_with_12 = sum_x_y_carry(12) print(sum_with_12(1), sum_with_12(12))  # 13 24 sum_with_5 = sum_x_y_carry(5) print(sum_with_12(10), sum_with_12(17))  # 22 29 <\/code><\/pre>\n<p>  \u0423\u0436\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0439, \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043a\u0430\u0440\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0441 \u0434\u0432\u0443\u043c\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438, \u0432\u0435\u0434\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043f\u0438\u0441\u0430\u0442\u044c <code>lambda x: lambda y: zzzz<\/code> \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u043a\u0440\u0443\u0442\u043e:  <\/p>\n<pre><code class=\"python\">curry_2 = lambda fn: lambda x: lambda y: fn(x, y) <\/code><\/pre>\n<p>  \u0418 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0435\u0435 \u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0439 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>map<\/code>:  <\/p>\n<pre><code class=\"python\">curry_map_2 = curry_2(map)  @curry_map_2 def twice_or_increase(n):     if n % 2 == 0:         n += 1     if n % 3:         n *= 2     return n  print(*twice_or_increase(range(10)))  # 2 2 3 3 10 10 14 14 9 9 print(*twice_or_increase(range(30)))  # 2 2 3 3 10 10 14 14 9 9 22 22 26 26 15 15 34 34 38... <\/code><\/pre>\n<p>  \u0414\u0430-\u0434\u0430, \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u043a\u0430\u0440\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b\u0439 <code>map<\/code> \u043a\u0430\u043a \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0438 \u043d\u0438\u0432\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043b \u044d\u0442\u0438\u043c \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043c\u043d\u043e\u0433\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u044b\u0445 \u043b\u044f\u043c\u0431\u0434.<\/p>\n<p>  \u041d\u043e \u043d\u0435 \u0432\u0441\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 2 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>curry_n<\/code>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <a href=\"http:\/\/docs.python.org\/3.3\/library\/functools.html#functools.partial\">partial<\/a>, \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f \u0438 \u043d\u0435\u043c\u043d\u043e\u0436\u043a\u043e \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438:  <\/p>\n<pre><code class=\"python\">from functools import partial  def curry_n(fn, n):     def aux(x, n=None, args=None):  # \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f         args = args + [x]  # \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432         return partial(aux, n=n - 1, args=args) if n &gt; 1 else fn(*args) # \u0432\u0435\u0440\u043d\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441 \u043e\u0434\u043d\u0438\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u0443\u044e \u0438\u0437 aux \u043b\u0438\u0431\u043e \u0432\u044b\u0437\u043e\u0432\u0435\u043c \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0443\u044e \u0441 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u043c\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438     return partial(aux, n=n, args=[]) <\/code><\/pre>\n<p>  \u0418 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0440\u0430\u0437 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u043a <code>map<\/code>, \u043d\u043e \u0443\u0436\u0435 \u0441 3 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438:  <\/p>\n<pre><code class=\"python\">curry_3_map = curry_n(map, 3) <\/code><\/pre>\n<p>  \u0418 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0441\u043f\u0438\u0441\u043a\u0430 \u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0441\u043f\u0438\u0441\u043a\u0430 1..10:  <\/p>\n<pre><code class=\"python\">sum_arrays = curry_3_map(lambda x, y: x + y) sum_with_range_10 = sum_arrays(range(10)) print(*sum_with_range_10(range(100, 0, -10)))  # 100 91 82 73 64 55 46 37 28 19 print(*sum_with_range_10(range(10)))  # 0 2 4 6 8 10 12 14 16 18 <\/code><\/pre>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a <code>curry_2<\/code> \u2014 \u044d\u0442\u043e \u0447\u0430\u0441\u0442\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 <code>curry_n<\/code>, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c:  <\/p>\n<pre><code class=\"python\">curry_2 = partial(curry_n, n=2) <\/code><\/pre>\n<p>  \u0418 \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0435\u0433\u043e \u043a <code>filter<\/code>:  <\/p>\n<pre><code class=\"python\">curry_filter = curry_2(filter) only_odd = curry_filter(lambda n: n % 2) print(*only_odd(range(10)))  # 1 3 5 7 9 print(*only_odd(range(-10, 0, 1)))  # -9 -7 -5 -3 -1 <\/code><\/pre>\n<p>  <\/p>\n<h2>Pattern matching<\/h2>\n<p>  <\/p>\n<blockquote><p>\u041c\u0435\u0442\u043e\u0434 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0441\u043f\u0438\u0441\u043a\u043e\u0432 \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0432 \u043d\u0438\u0445 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0431\u0440\u0430\u0437\u0446\u043e\u0432.<\/p><\/blockquote>\n<p>  Pattern matching \u2014 \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u043c\u043d\u0435 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u043e\u0441\u044c \u0432 sml \u0438 \u0445\u0443\u0436\u0435 \u0432\u0441\u0435\u0433\u043e \u0432\u044b\u0448\u043b\u043e \u0432 python.<br \/>  \u041f\u0440\u0438\u0434\u0443\u043c\u0430\u0435\u043c \u0441\u0435\u0431\u0435 \u0446\u0435\u043b\u044c \u2014 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f:  <\/p>\n<ul>\n<li>\u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0447\u0438\u0441\u0435\u043b, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u0445 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435;<\/li>\n<li>\u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0442\u0440\u043e\u043a, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0434\u043d\u0443 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443.<\/li>\n<\/ul>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 exception \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u0435\u0433\u043e \u00ab\u0431\u0440\u043e\u0441\u0430\u043d\u0438\u044f\u00bb, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0435 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442:  <\/p>\n<pre><code class=\"python\">class NotMatch(Exception):     &quot;&quot;&quot;Not match&quot;&quot;&quot;   def not_match(x):     raise NotMatch(x) <\/code><\/pre>\n<p>  \u0418 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u0435\u043b\u0430\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442, \u043b\u0438\u0431\u043e \u0431\u0440\u043e\u0441\u0430\u0435\u0442 exception:  <\/p>\n<pre><code class=\"python\">match = lambda check, obj: obj if check(obj) else not_match(obj) match_curry = curry_n(match, 2) <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0442\u0438\u043f\u0430:  <\/p>\n<pre><code class=\"python\">instance_of = lambda type_: match_curry(lambda obj: isinstance(obj, type_)) <\/code><\/pre>\n<p>  \u0422\u043e\u0433\u0434\u0430 \u0434\u043b\u044f <code>int<\/code>:  <\/p>\n<pre><code class=\"python\">is_int = instance_of(int) print(is_int(2))  # 2 try:     is_int('str') except NotMatch:     print('not int')  # not int <\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0442\u0438\u043f\u0430 \u0434\u043b\u044f \u0441\u043f\u0438\u0441\u043a\u0430, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044f \u0435\u0433\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442:  <\/p>\n<pre><code class=\"python\">is_array_of = lambda matcher: match_curry(lambda obj: all(map(matcher, obj))) <\/code><\/pre>\n<p>  \u0418 \u0442\u043e\u0433\u0434\u0430 \u0434\u043b\u044f <code>int<\/code>:  <\/p>\n<pre><code class=\"python\">is_array_of_int = is_array_of(is_int) print(is_array_of_int([1, 2, 3]))  # 1 2 3 try:     is_array_of_int('str') except NotMatch:     print('not int')  # not int <\/code><\/pre>\n<p>  \u0418 \u0442\u0435\u043f\u0435\u0440\u044c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0434\u043b\u044f <code>str<\/code>:  <\/p>\n<pre><code class=\"python\">is_str = instance_of(str) is_array_of_str = is_array_of(is_str) <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0443\u044e \u0441\u0432\u043e\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442, \u0438\u0434\u0435\u043c\u043f\u043e\u0442\u0435\u043d\u0442\u043d\u0443\u044e =)  <\/p>\n<pre><code class=\"python\">identity = lambda x: x print(identity(10))  # 10 print(identity(20))  # 20 <\/code><\/pre>\n<p>  \u0418 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043d\u0430 \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a:  <\/p>\n<pre><code class=\"python\">is_blank = match_curry(lambda xs: len(xs) == 0) print(is_blank([]))  # [] try:     is_blank([1, 2, 3]) except NotMatch:     print('not blank')  # not blank <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u0441 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u043a \u043d\u0438\u043c \u00ab\u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a\u00bb:  <\/p>\n<pre><code class=\"python\">def hd_tl(match_x, match_xs, arr):     x, *xs = arr     return match_x(x), match_xs(xs)  hd_tl_partial = lambda match_x, match_xs: partial(hd_tl, match_x, match_xs) <\/code><\/pre>\n<p>  \u0418 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 <code>identity<\/code>:  <\/p>\n<pre><code class=\"python\">hd_tl_identity = hd_tl_partial(identity, identity) print(hd_tl_identity(range(5)))  # 0 [1, 2, 3, 4] <\/code><\/pre>\n<p>  \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0441 \u0447\u0438\u0441\u043b\u0430\u043c\u0438:  <\/p>\n<pre><code class=\"python\">hd_tl_ints = hd_tl_partial(is_int, is_array_of_int) print(hd_tl_ints(range(2, 6)))  # 2 [3, 4, 5] try:     hd_tl_ints(['str', 1, 2]) except NotMatch:     print('not ints')  # not ints <\/code><\/pre>\n<p>  \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u0430\u043c\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438. \u041e\u043d\u0430 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u0430\u044f:  <\/p>\n<pre><code class=\"python\">def pattern_match(patterns, args):     for pattern, fnc in patterns:         try:             return fnc(pattern(args))         except NotMatch:             continue     raise NotMatch(args)  pattern_match_curry = curry_n(pattern_match, 2) <\/code><\/pre>\n<p>  <a href=\"http:\/\/xkcd.com\/297\/\"><img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/1b1\/ade\/0cb\/1b1ade0cbebf09ac91c81921b0fe4728.png\"\/><\/a><\/p>\n<p>  \u041d\u043e \u0437\u0430\u0442\u043e \u043e\u043d\u0430 \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u0430 \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0446\u0435\u043b\u044b\u0439 \u043c\u0438\u0440 \u0441\u043a\u043e\u0431\u043e\u043a, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0443\u0436\u043d\u0430\u044f \u043d\u0430\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"python\">sum_or_multiply = pattern_match_curry((     (hd_tl_partial(identity, is_blank), lambda arr: arr[0]),  # x::[] -&gt; x     (hd_tl_ints, lambda arr: arr[0] * sum_or_multiply(arr[1])),  # x::xs -&gt; x * sum_or_multiply (xs) \u0433\u0434\u0435 type(x) == int     (hd_tl_partial(is_str, is_array_of_str), lambda arr: arr[0] + sum_or_multiply(arr[1])),  # x::xs -&gt; x + sum_or_multiply (xs) \u0433\u0434\u0435 type(x) == str )) <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0435\u0435 \u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438:  <\/p>\n<pre><code class=\"python\">print(sum_or_multiply(range(1, 10)))  # 362880 print(sum_or_multiply(['a', 'b', 'c']))  # abc <\/code><\/pre>\n<p>  \u0423\u0440\u0430! \u041e\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 =)<\/p>\n<h2>\u0420\u0435\u043a\u0443\u0440\u0441\u0438\u044f<\/h2>\n<p>  \u0412\u043e \u0432\u0441\u0435\u0445 \u043a\u043b\u0430\u0441\u0441\u043d\u044b\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0440\u0443\u0442\u044b\u0435 \u0440\u0435\u0431\u044f\u0442\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 <code>map<\/code> \u0447\u0435\u0440\u0435\u0437 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044e, \u0447\u0435\u043c \u043c\u044b \u0445\u0443\u0436\u0435? \u0422\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u043c\u044b \u0443\u0436\u0435 \u0443\u043c\u0435\u0435\u043c pattern matching:  <\/p>\n<pre><code class=\"python\">r_map = lambda fn, arg: pattern_match((     (hd_tl_partial(identity, is_blank), lambda arr: [fn(arr[0])]),  # x::[] -&gt; fn(x)     (         hd_tl_partial(identity, identity),         lambda arr: [fn(arr[0])] + r_map(fn, arr[1])  # x::xs -&gt; fn(x)::r_map(fn, xs)     ), ), arg)  print(r_map(lambda x: x**2, range(10)))  # [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043a\u0430\u0440\u0440\u0438\u0440\u0443\u0435\u043c:  <\/p>\n<pre><code class=\"python\">r_map_curry = curry_n(r_map, 2) twice = r_map_curry(lambda x: x * 2) print(twice(range(10))) try:     print(twice(range(1000)))  # [0, 2, 4, 6, 8, 10, 12, 14, 16, 18] except RuntimeError as e:     print(e)  # maximum recursion depth exceeded in comparison <\/code><\/pre>\n<p>  \u0427\u0442\u043e-\u0442\u043e \u043f\u043e\u0448\u043b\u043e \u043d\u0435 \u0442\u0430\u043a, \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0445\u0432\u043e\u0441\u0442\u043e\u0432\u0443\u044e \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044e.<br \/>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u00ab\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443\u00bb \u043d\u0430 <code>None<\/code>:  <\/p>\n<pre><code class=\"python\">is_none = match_curry(lambda obj: obj is None) <\/code><\/pre>\n<p>  \u0418 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043f\u0430\u0440\u044b:  <\/p>\n<pre><code class=\"python\">pair = lambda match_x, match_y: lambda arr: (match_x(arr[0]), match_y(arr[1])) <\/code><\/pre>\n<p>  \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0438 \u0441\u0430\u043c <code>map<\/code>:  <\/p>\n<pre><code class=\"python\">def r_map_tail(fn, arg):     aux = lambda arg: pattern_match((         (pair(identity, is_none), lambda arr: aux([arr[0], []])),  # \u0435\u0441\u043b\u0438 \u0430\u043a\u043a\u0443\u043c\u0443\u043b\u044f\u0442\u043e\u0440 None, \u0434\u0435\u043b\u0430\u0435\u043c \u0435\u0433\u043e []         (             pair(hd_tl_partial(identity, is_blank), identity),             lambda arr: arr[1] + [fn(arr[0][0])]  # \u0435\u0441\u043b\u0438 (x::[], acc), \u0442\u043e \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a \u0430\u043a\u043a\u0443\u043c\u0443\u043b\u044f\u0442\u043e\u0440\u0443 fn(x) \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0435\u0433\u043e         ),         (             pair(hd_tl_partial(identity, identity), identity),             lambda arr: aux([arr[0][1], arr[1] + [fn(arr[0][0])]])  # \u0435\u0441\u043b\u0438 (x::xs, acc), \u0442\u043e \u0434\u0435\u043b\u0430\u0435\u043c \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u0441 xs \u0438 \u0430\u043a\u043a\u0443\u043c\u0443\u043b\u044f\u0442\u043e\u0440\u043e\u043c + fn(x)         ),     ), arg)     return aux([arg, None]) <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043d\u0430\u0448\u0435 \u0447\u0443\u0434\u043e:  <\/p>\n<pre><code class=\"python\">r_map_tail_curry = curry_n(r_map_tail, 2) twice_tail = r_map_tail_curry(lambda x: x * 2) print(twice_tail(range(10)))  # [0, 2, 4, 6, 8, 10, 12, 14, 16, 18] try:     print(twice_tail(range(10000))) except RuntimeError as e:     print(e)  # maximum recursion depth exceeded <\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u0432\u0435\u0434\u044c \u043d\u0435\u0437\u0430\u0434\u0430\u0447\u0430 \u2014 python \u043d\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u0445\u0432\u043e\u0441\u0442\u043e\u0432\u0443\u044e \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044e. \u041d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0443\u0442 \u043a\u043e\u0441\u0442\u044b\u043b\u0438:  <\/p>\n<pre><code class=\"python\">def tail_fnc(fn):     called = False     calls = []      def run():         while len(calls):  # \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430             res = fn(*calls.pop())         return res      def call(*args):         nonlocal called         calls.append(args)  # \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0432 \u0441\u043f\u0438\u0441\u043e\u043a         if not called:  # \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0432\u044b\u0437\u0432\u0430\u043b\u0430\u0441\u044c \u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 - \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0446\u0438\u043a\u043b             called = True             return run()     return call <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0441 \u044d\u0442\u0438\u043c <code>map<\/code>:  <\/p>\n<pre><code class=\"python\">def r_map_really_tail(fn, arg):     aux = tail_fnc(lambda arg: pattern_match((  # \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u0443\u0435\u043c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e         (pair(identity, is_none), lambda arr: aux([arr[0], []])),  # \u0435\u0441\u043b\u0438 \u0430\u043a\u043a\u0443\u043c\u0443\u043b\u044f\u0442\u043e\u0440 None, \u0434\u0435\u043b\u0430\u0435\u043c \u0435\u0433\u043e []         (             pair(hd_tl_partial(identity, is_blank), identity),             lambda arr: arr[1] + [fn(arr[0][0])]  # \u0435\u0441\u043b\u0438 (x::[], acc), \u0442\u043e \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a \u0430\u043a\u043a\u0443\u043c\u0443\u043b\u044f\u0442\u043e\u0440\u0443 fn(x) \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0435\u0433\u043e         ),         (             pair(hd_tl_partial(identity, identity), identity),             lambda arr: aux([arr[0][1], arr[1] + [fn(arr[0][0])]])  # \u0435\u0441\u043b\u0438 (x::xs, acc), \u0442\u043e \u0434\u0435\u043b\u0430\u0435\u043c \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u0441 xs \u0438 \u0430\u043a\u043a\u0443\u043c\u0443\u043b\u044f\u0442\u043e\u0440\u043e\u043c + fn(x)         ),     ), arg))     return aux([arg, None])  r_map_really_tail_curry = curry_n(r_map_really_tail, 2) twice_really_tail = r_map_really_tail_curry(lambda x: x * 2) print(twice_really_tail(range(1000)))  # [0, 2, 4, 6, 8, 10, 12, 14, 16, 18... <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0438 \u044d\u0442\u043e \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e =)<\/p>\n<h2>\u041d\u0435 \u0432\u0441\u0435 \u0442\u0430\u043a \u0441\u0442\u0440\u0430\u0448\u043d\u043e<\/h2>\n<p>  <a href=\"http:\/\/xkcd.com\/244\/\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/386\/2df\/949\/3862df94980d7c02f31243ae8b3b93fa.png\" align=\"left\"\/><\/a>\u0415\u0441\u043b\u0438 \u0437\u0430\u0431\u044b\u0442\u044c \u043f\u0440\u043e \u043d\u0430\u0448 \u0443\u0436\u0430\u0441\u043d\u044b\u0439 pattern matching, \u0442\u043e \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u044b\u0439 <code>map<\/code> \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043f\u043e\u043b\u043d\u0435 \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e:  <\/p>\n<pre><code class=\"python\">def tail_r_map(fn, arr_):     @tail_fnc     def aux(arr, acc=None):         x, *xs = arr         if xs:             return aux(xs, acc + [fn(x)])         else:             return acc + [fn(x)]     return aux(arr_, [])  curry_tail_r_map = curry_2(tail_r_map) <\/code><\/pre>\n<p>  \u0418 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043d\u0430 \u043d\u0435\u043c \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043d\u0435\u0447\u0435\u0442\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u043d\u0430 2:  <\/p>\n<pre><code class=\"python\">@curry_tail_r_map def twice_if_odd(x):     if x % 2 == 0:         return x * 2     else:         return x  print(twice_if_odd(range(10000)))  # [0, 1, 4, 3, 8, 5, 12, 7, 16, 9, 20, 11, 24, 13, 28, 15, 32, 17, 36, 19... <\/code><\/pre>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0432\u043f\u043e\u043b\u043d\u0435 \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e, \u0445\u043e\u0442\u044c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e \u0438 \u043d\u0435\u043d\u0443\u0436\u043d\u043e. \u041a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0438\u0437-\u0437\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438. \u0421\u0440\u0430\u0432\u043d\u0438\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 <code>map<\/code>:  <\/p>\n<pre><code class=\"python\">from time import time  checker = lambda x: x ** 2 + x limit = 100000  start = time() xs = [checker(x) for x in range(limit)][::-1] print('inline for:', time() - start)  start = time() xs = list(map(checker, xs))[::-1] print('map:', time() - start)  calculate = curry_tail_r_map(checker) start = time() xs = calculate(xs)[::-1] print('r_map without pattern matching:', time() - start)  calculate = r_map_really_tail_curry(checker) start = time() xs = calculate(xs)[::-1] print('r_map with pattern matching:', time() - start) <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043c:<br \/>  <strong>inline for:<\/strong> 0.010764837265014648<br \/>  <strong>map:<\/strong> 0.010544061660766602<br \/>  <strong>r_map without pattern matching:<\/strong> 4.720803737640381<br \/>  <strong>r_map with pattern matching:<\/strong> 8.376755237579346<br \/>  \u0412\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 pattern matching&#8217;\u043e\u043c \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u0441\u0430\u043c\u044b\u043c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u043c, \u0430 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 map \u0438 for \u043e\u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c \u0441\u0430\u043c\u044b\u043c\u0438 \u0431\u044b\u0441\u0442\u0440\u044b\u043c\u0438.<\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>  \u0418\u0437 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043f\u043e\u0436\u0430\u043b\u0443\u0439, \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u0430\u0440\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043b\u0438\u0431\u043e \u043d\u0435\u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0439, \u043b\u0438\u0431\u043e \u0442\u043e\u0440\u043c\u043e\u0437\u043d\u043e\u0439 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434 =)<br \/>  <a href=\"https:\/\/github.com\/nvbn\/pyfunc\">\u0412\u0441\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043d\u0430 github.<\/a>    \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/193920\/\"> http:\/\/habrahabr.ru\/post\/193920\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t<img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage3\/e6a\/b6b\/275\/e6ab6b2751326e14cce18b1ece778198.png\" align=\"right\"\/><br \/>  \u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u043a\u0443\u0440\u0441\u0430 <a href=\"https:\/\/www.coursera.org\/course\/proglang\">Programming Languages<\/a> \u0438 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u044f <a href=\"http:\/\/shop.oreilly.com\/product\/0636920028857.do\">Functional JavaScript<\/a> \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c \u0432\u0441\u0435 \u044d\u0442\u0438 \u043a\u0440\u0443\u0442\u044b\u0435 \u0448\u0442\u0443\u043a\u0438 \u0432 python. \u0427\u0430\u0441\u0442\u044c \u0432\u0435\u0449\u0435\u0439 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u0438 \u043b\u0435\u0433\u043a\u043e, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u044b\u0448\u043b\u043e \u0441\u0442\u0440\u0430\u0448\u043d\u044b\u043c \u0438 \u043d\u0435\u043f\u0440\u0438\u0433\u043e\u0434\u043d\u044b\u043c \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>  \u0421\u0442\u0430\u0442\u044c\u044f \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f:  <\/p>\n<ul>\n<li>\u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0445 \u0441\u043b\u043e\u0432;<\/li>\n<li>\u043a\u0430\u0440\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435;<\/li>\n<li>pattern matching;<\/li>\n<li>\u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044f (\u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0445\u0432\u043e\u0441\u0442\u043e\u0432\u0443\u044e).<\/li>\n<\/ul>\n<p>  \u0421\u0442\u0430\u0442\u044c\u044f \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d\u0430 \u043d\u0430 python 3.3+.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-193920","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/193920","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=193920"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/193920\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=193920"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=193920"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=193920"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}