Python built-in && recursive

Source: Internet
Author: User

Lambda

Advantages:

1: Can simply use a script instead of our function

2: Do not consider the problem of naming

3: Simplify the readability of your code without jumping to def, eliminating the need for such a step

Built-in functions: BIF

Filter: Filters

Map: Map

650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" Margin:0px;padding:0px;border:none; "/>

 1 >>> lambda x: 2*x+1 2 <function <lambda> at  0x00000000026C6AC8> 3 >>> g=lambda x: 2*x+1 4 >> > g (3)  5 7 6 >>> help (filter)  7 help on built-in  function filter in module __builtin__: 8  9 filter (...) 10     filter (function or none, sequence)  -> list,  Tuple, or string11     12     return those  items of sequence for which function (item)  is true.  if13      function is none, return the items that are  true.  If sequence is a tuple14     or  String, return the saMe type, else return a list.15 16 >>> filter (None,[1,0,True, False]) 17 [1, true]18 >>> 19 >>> 20 >>> tmp =range (21 >>> tmp22 [0, 1, 2, 3, 4, 5, 6, 7),  8, 9]23 >>> def fun (x): 24     return x%225  26 >>> filter (fun,tmp) 27 [1, 3, 5, 7, 9]28 >>>  list (Filter (lambda x:x%2,range)) 29 [1, 3, 5, 7, 9]30 >>>  list (Map (lambda x:x*2,range)) 31 [0, 2, 4, 6, 8, 10, 12,  14, 16, 18]32 >>>

650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" Margin:0px;padding:0px;border:none; "/>

Recursive

Python limits the recursion depth to about hundreds of levels, but can be set manually

"" Import sys

>>> Sys.setrecursionlimit (10000)

Python---------------------------------------eg ' 1------------------

650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/730879/201611/730879-20161109154126936-132521667. PNG "style=" margin:0px;padding:0px;border:0px; "/>

650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/730879/201611/730879-20161109154240936-1171601083. PNG "style=" margin:0px;padding:0px;border:0px; "/>


Python built-in && recursive

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.