+ Reply to Thread
Results 1 to 2 of 2

Thread: How to build a recursive lambda in C++?

  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    28

    How to build a recursive lambda in C++?

    I want to learn how to build a recursive lambda in C++? please help.

  2. #2
    Junior Member
    Join Date
    May 2012
    Posts
    29
    You can build recursive lambda and below is an example:

    Code:
    void RecursiveLambda()
    {
    	std::tr1::function<int (int)> fact ;
    
    	fact = [&fact] (int value)-> int 
    					{
    						if (0 == value)
    						{
    							return 1 ;
    						}
    
    						return value * fact(value - 1) ;
    					} ;
    
    	int value = fact(6) ;
    }

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts