函数式编程C++版本》
此专栏代码为塞尔维亚的函数式编程C++版本的源码gitlab下载链接为
https://gitlab.com/manning-fpcpp-book/code-examples/tree/master/chapter-04
楼兰公子
这个作者很懒,什么都没留下…
展开
-
统计文件行数
int count_lines(const std::string &filename){ std::ifstream in(filename); return std::count(std::istreambuf_iterator<char>(in),std::istreambuf_iterator<char>(),'\n'); }原创 2020-05-23 17:43:09 · 166 阅读 · 0 评论 -
chapter-02\filter-and-transform-combined
#include <string> #include <iostream> #include <vector> #include <algorithm> #include "../../common/person.h" std::string name(const person_t &person) { return person.name(); } bool is_female(const person_t &person)..原创 2020-05-18 16:29:05 · 94 阅读 · 0 评论 -
函数式编程C++版本--chapter-02\filter-and-transform
#include <string> #include <iostream> #include <vector> #include <algorithm> #include <iterator> #include "../../common/person.h" std::string name(const person_t &person) { return person.name(); } bool is_female(c..原创 2020-05-18 16:26:09 · 96 阅读 · 0 评论 -
函数式编程C++版本--chapter-02\count-lines-using-accumulate
#include <iostream> #include <numeric> // Implementing counting through folding. // We have our previous count, and we are returning the new count // after checking out the current character. int counter(int previous_count, char c) { ret..原创 2020-05-18 16:20:50 · 114 阅读 · 0 评论 -
函数式编程C++版本-ch02-average-score
#include <iostream> #include <numeric> #include <vector> #if 0 // Imperative version double average_score(const std::vector<int> &scores) { int sum = 0; for (int score: scores) { sum += score; } retu..原创 2020-05-18 16:19:28 · 275 阅读 · 0 评论 -
函数式编程C++版本-ch01-count-lines-transform
#include <iostream> #include <string> #include <vector> #include <unordered_map> #include <fstream> #include <algorithm> #include <iterator> /** * This function opens a file specified by the filename argument, ..原创 2020-05-18 16:16:44 · 153 阅读 · 0 评论 -
函数式编程C++版本--ch01--count-lines-stdcount
#include <iostream> #include <string> #include <vector> #include <unordered_map> #include <fstream> #include <algorithm> #include <iterator> /** * This function opens a file specified by the filename argument, ..原创 2020-05-18 16:14:17 · 213 阅读 · 0 评论 -
《函数式编程C++版本》count-lines-test
// vim: set undofile: // Program: count_lines_test #include <string> #include <sstream> #include <iterator> #include <algorithm> #include <forward_list> #include <iostream> #include <range/v3/view.hpp> using nam.原创 2020-05-17 17:30:32 · 280 阅读 · 0 评论 -
《函数式编程C++版本》----count-lines-test-generation
// vim: set undofile: // Program: count_lines_test #include <string> #include <sstream> #include <iterator> #include <algorithm> #include <forward_list> #include <iostream> #include <range/v3/view.hpp> using nam.原创 2020-05-17 17:27:35 · 187 阅读 · 0 评论 -
《函数式编程C++版本》--Chp13--diantance
#include <ratio> template < typename Representation , typename Ratio = std::ratio<1> > class distance { public: explicit constexpr distance(Representation value) : value(value) { } distance op.原创 2020-05-17 17:26:14 · 213 阅读 · 0 评论