Multi-Paradigm Programming in C++: Functional Programming at Washington University

e81 cse 428s n.w
1 / 4
Embed
Share

Explore the world of multi-paradigm programming in C++ with a focus on functional programming concepts and techniques. Discover callable types, function pointers, lambda expressions, and composition of callable types. Practice calling, chaining, and composing basic functions in C++ to enhance your programming skills.

  • C++
  • Functional Programming
  • Callable Types
  • Lambda Expressions
  • Washington University

Uploaded on | 1 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. E81 CSE 428S: Multi-Paradigm Programming in C++ Functional Programming Department of Computer Science & Engineering Washington University, St. Louis MO Chris Gill cdgill@wustl.edu 1

  2. C++ Supports Functional Programming There are many callable types we can use or adapt E.g., call object s public function call operator (operator()()) E.g., construct and run a C++ std::thread with it in CSE 532 Function pointers let you store and pass aliases to ordinary C and C++ functions E.g., std::size_t (*p)( const char* ) = std::strlen; Lambda expressions define callable types in-place When combined with templates from the standard <functional> library this gives you generic function objects E.g., function<float(float)> sn = [](auto i) { return std::sin(i); }; CSE 428S Multi-Paradigm Programming in C++ 2

  3. Callable Types can be Transformed You can bind arguments to their parameters modifies a callable type and its interface and in doing so produces a new callable type Composition combines callable types into new ones E.g., f of g of x sometimes written as f g (x) We will consider a simple template that illustrates how unary functions can be composed to form a new unary function We will also consider how binding the composed function s single argument creates a new 0-ary function CSE 428S Multi-Paradigm Programming in C++ 3

  4. Studio 5 Practice calling and chaining basic functions Examine different ways to invoke basic functions Declare and use function pointers and lambdas Declare, compose, and bind different callable types Studios 0 through 11 are due 11:59pm Monday October 16th (the night before Exam 0) Submit as soon as each is done so you get feedback and can resubmit any that may be marked incomplete CSE 428S Multi-Paradigm Programming in C++ 4

More Related Content