4 ms·
While working on my last projects I accumulated a collection of pure functions I needed now and then. So I thought, why not write a short pitch as a README and
by Dobiasd 11y ago
While working on my last projects I accumulated a collection of pure functions I needed now and then. So I thought, why not write a short pitch as a README and make it public? So here it is.
It would be very nice of you if you could tell me what you think, so I can learn and improve.
- Ace17 11y agoAlthough an implementation based on streaming combinators (=no intermediate allocations) clearly is faster, the interface you provided definitely corresponds to the way I want to program. You might want to have a look to std.algorithm from Phobos (the D programming language standard library) ; it's full of such utilities : http://dlang.org/phobos/std_algorithm.html http://dlang.org/phobos/std_algorithm.html That's a shame there's nothing similar in the C++ standard library.
- frozenport 11y agoI generally use python when manipulating lists, and C++ for floating point oriented tasks.
- Dobiasd 11y agoWhat do you do if your application needs to do both?
- frozenport 11y agoThats a great question! In one case I used a python wrapper around a C++ core, but when it came time to re-write it we switched to pure python and have so far hit our performance benchmarks - mostly because libraries like OpenCV or PyCuda are now able to efficiently wrap our critical paths.
- Ace17 11y agoThe OP's work shows it clearly is possible to manipulate lists in C++, in a simple and concise way.
- vitd 11y agoI'll just say that it looks very interesting, and it's the type of thing that might help me to better learn functional programming. I jumped in with Haskell a year or two ago, and while it was interesting, learning it has been a pain because it's so different from imperative programming. Something like this where I can dip a toe in a little at a time in a language I already understand looks appealing. I'm not concerned about efficiency of code in this case, just efficiency of learning the concepts.
- Dobiasd 11y agoGreat to hear that. Good luck on your journey to functional programming. I also started with Haskell and had problems with it. Then I found Elm, and that was like of a gateway drug for me. Here is my story in case you are interested: https://github.com/Dobiasd/articles/blob/master/switching_from_imperative_to_functional_programming_with_games_in_Elm.md https://github.com/Dobiasd/articles/blob/master/switching_fr...