Nested function: Difference between revisions
Content added Content deleted
(added haskell) |
(added c++) |
||
Line 35: | Line 35: | ||
print( ( make list( ". " ) ) ) |
print( ( make list( ". " ) ) ) |
||
</lang> |
</lang> |
||
=={{header|C++}}== |
|||
{{works with|C++11}} |
|||
<lang cpp>#import <iostream> |
|||
#import <string> |
|||
#import <sstream> |
|||
std::string makeList(std::string separator) { |
|||
int counter = 1; |
|||
auto makeItem = [=](std::string item) mutable { |
|||
return (std::ostringstream() << counter++ << separator << item << "\n").str(); |
|||
}; |
|||
return makeItem("first") + makeItem("second") + makeItem("third"); |
|||
} |
|||
int main() { |
|||
std::cout << makeList(". "); |
|||
return 0; |
|||
}</lang> |
|||
=={{header|C#}}== |
=={{header|C#}}== |