Troy shows his solution to the factorial challenge in this short video.
(electronic music)…- [Instructor] My solution is somewhat similar…to the incremental lambda we created earlier…except it sets the initial value…to the past initial argument…and it adds the value of addBy instead of one…each successive call.…So let's take a look at it in code.…Open up our main.…We've already got our include file…and our namespace.…And right here we want to create…auto space continuousAdd…and the we have an open and closed square brace.…
We have our parenthesis.…And we have an init integer.…Initial comma integer addBy…and then we're going to say that…auto total equals initial.…Now this step's probably not necessary…but I like the purpose of all my variables…to be very clear to me.…Then we're going to say return.…
And then we want to capture…total and addBy in our scope.…Then we have take no variables here.…And we're going to say that this is mutable.…Because we're going to change the value of total.…And then we're going to do a total…plus equals addBy.…
And finally we'll do a return total.…And then we have to add a semi colon here.…
- Unit testing and functional programming
- Function and Lambda functions
- C++ templates
- Working with the Standard Template Library and Boost.Hana
- Functional reactive programming
Skill Level Intermediate
Learning Functional Programming with Swiftwith Shaun Wassell53m 12s Intermediate
2. Functional Programming in Modern C++
3. Template Metaprogramming
4. Functional Reactive Programming
RxCpp library5m 21s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.