tag:blogger.com,1999:blog-8638474063464489651.post4950818748060648631..comments2024-01-15T11:38:29.051-08:00Comments on Multi-paradigm: Zipping and Mapping tuples.Splinter of Chaoshttp://www.blogger.com/profile/14715348728512729776noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-8638474063464489651.post-22402239473293593982013-11-19T07:27:02.020-08:002013-11-19T07:27:02.020-08:00In my view, 'the big picture' is in the el...In my view, 'the big picture' is in the elegance with how certain type of problems can be solved by using C++11 core constructs (tuple, variadic templates, meta functions etc.). Myself, I'm using 'tuple based programming' quite a lot for database access where bind variables, rows and other constructs are mapped to columns in varous ways. Here tuple based programming solves many problems in neat and clean ways. Specifically, I use (and wrote) a thin wrapper around Oracle OCCI (could be done for any database API) which aligns the API with 'STL style programming' making database access in C++ both elegant, simple and as type safe as is possible in just with a few hundred lines of code in a few headers.Hans Ewetzhttps://www.blogger.com/profile/17304495269984016989noreply@blogger.comtag:blogger.com,1999:blog-8638474063464489651.post-80942778158136017692012-12-19T12:33:33.935-08:002012-12-19T12:33:33.935-08:00I have to admit, I'm not sure where the big pi...I have to admit, I'm not sure where the big picture is, really, because I only recently started playing around with them (largely thanks to articles such as yours). The above, and the previous article, are a mathematical basis from which more complex algorithms can be built. But math is only useful when applied.<br /><br />With the example of the article you mention, instead of writing a complex object that handles all the logic at once, you can write simple, small, obvious functions and describe them in terms of folds, maps, and zips. Using "translate" from this article, you could achieve the same affect with <br /><br /> translate( tuple, v1, v2, v3, ... );<br /><br />where "tuple" (not std::tuple) is defined as a polymorphic function object [1]. <br /><br />Also, with this technique, you do not have to write a class to deduce the type of the result, you can use std::result_of.<br /><br />[1]: https://gist.github.com/4268029#file-zip-map-tuple-cpp-L97Splinter of Chaoshttps://www.blogger.com/profile/14715348728512729776noreply@blogger.comtag:blogger.com,1999:blog-8638474063464489651.post-19390386338163937862012-12-19T10:28:58.238-08:002012-12-19T10:28:58.238-08:00Interesting article! However, I'm still missin...Interesting article! However, I'm still missing a compelling reason to use such techniques. It is a bit exhausting to understand the code. What's the big picture here? <br /><br />You might be interested in a blog post I wrote on "Generic Transpose using boost tuples". It is really a generic zip operation on vectors not a transpose. I'm using that facility in a generic XML processing library.Sumanthttps://www.blogger.com/profile/11957855386259543653noreply@blogger.com