Professional Documents
Culture Documents
LANGUAGES
CS F301 – Ranges
PROF. KUNAL KORGAONKAR
BOOKS
• Ravi Sethi , "Programming Languages: Concepts and Constructs" 2nd Edition by
Addison Wesley
• Robert W. Sebesta, "Concepts of Programming Languages", 2nd Edition by The
Benjamin/Cummings, Publishing Company, Inc
• Aho, Lam, Sethi and Ullman, "Compilers Principles, Techniques, and Tools". Pearson
Education. Low Price Edition. 2004
• Michael L. Scott, Programming Language Pragmatics, Fourth Edition, Morgan
Kaufmann Publishers
• Benjamin C. Pierce, Types and Programming Languages, January 2002, The MIT
Press
• Shriram Krishnamurthi, Programming Languages: Application and Interpretation,
Creative Commons License
• Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides, Design Patterns:
Elements of Reusable Object-Oriented Software, Addison-Wesley
• Ivan Čukić, Functional Programming in C++, Manning Books (available online)
References
Contents based on and an interpretation of:
Ivan Čukić, Functional Programming in C++, Manning Books (available online).
Ranges
• For the time being, let’s think of ranges as a simple structure that contains two
iterators—one pointing to the first element in a collection, and one pointing to
the element after the last one.
• The main benefit is that you can return a complete range as a result of a
function and pass it directly to another function without creating local variables
to hold the intermediary results.
Example
std::vector<std::string> names =
transform(
filter(people, is_female),
name
);
• The filter function will return a range containing elements from the
people collection that satisfy the is_female predicate.
• The transform function will then take this result and return the range of
names of everybody in the filtered range.
Example
std::vector<std::string> names = people |
filter(is_female) | transform(name);