This contactCodeMore, and have some in-depth understanding of various programming methods.
Especially when I learned lisp, I had a little bit of experience.
Like lisp, the simplest syntax is used for functional programming. According to my guess, LISP comes from the lambda algorithm (derived from the three principles of the lambda algorithm into seven principles)
Its biggest feature is that there is on
Recently learn c++11 variadic template argument, finally can get rid of the Fpmacro template to copy a lot of code of practice, good fun. The main function of this example uses lambda to write a recursive computational function of a Fibonacci sequence. Unlike in the past, with the help of the Y function, this
Want to send Http_post request in C + +, use Libcurl.Want to wrap it, because the default HTTP response results are printed to stdout, if you want to deal with the results of the response, you need to define a callback function.Considering that we want to wrap the functionality, a callback function is not very good to put on the outside, so consider using a lambda expression.Here are the forms you can use:1
======= Static voidMain (string[] args) { Object[] Nums = {1,2,3,4,5,0 }; MyDelegate Mydel=Delegate(ObjectObj1,ObjectOBJ2) {return(int) Obj1 > (int) Obj2; }; ObjectMax =Getmax (Nums, Mydel); Console.WriteLine (max); Console.readkey (); }================= because the system comes with action and func two kinds of delegates, there is no need to customize the delegate =================Action delegate return value is voidFunc has a return valueThe Get
funcint,int,int> fc= (int x,int y) =>x*y;Console.WriteLine (FC (5, 2));//declares a method with a return value of int and a parameter of two int. The function is to calculate the product of two integers. IListint> list = Enumerable.range (1, -). ToList (); Funcint,BOOL> Mydel =Delegate(intx) {returnX%2==1; };//Delegate anonymous method varCOUNTODD1 = list. Count (Mydel);//Invoke Delegate varCOUNTODD2 = list. Count (x = x%2==1);//
The concept of functional interface is added to Java 8. And added a new annotation @FunctionalInterfaceI1 What is the functional interface function interface?Functional Interface:functional interface only has 1 abstract method. This is the definition of the function interface. Simply understood, the function interface is actually an interface of an abstract metho
def groupBy (FN): def Go (LST): = {} for in lst: ifelse m.update ({fn (v): [v]}) #如果存在dict, append to the corresponding key, or none if it does not exist, then update a new key to return m return = GroupBy (lambdais 1) grpby ([1, 2, 3]) The Python implements the GroupBy function. Grpby = GroupBy (lambda x:x%2 is 1), the result of Grpby ([1, 2, 3]) is {True: [1, 3], False: [2]}
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.