20180720 (Lambda anonymous function, sorded () sort function, filter () filtering function, map () mapping function, recursive, dichotomy function)

Source: Internet
Author: User

I. Lambda anonymous function (one line for a function, but not a complex function operation)

Syntax: function name = lambda parameter: return value

Attention:

1. Functions can have more than one argument, separated by commas

2. Anonymous functions no matter how complex, can only write one line, and the logic is finished directly return data

3. The return value, like a normal function, can be any data type

For example: normal function

def func (N)

Return N*n

Print (func (6)) ======>36

For example: Lambda

a = lambda x:x*x (Lambda is an anonymous function, and the x parameter is followed by the function body (return content))

 print (a) =====>36

Two. Sorted sorting function

20180720 (Lambda anonymous function, sorded () sort function, filter () filtering function, map () mapping function, recursive, dichotomy function)

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.