Comments (6)
Thanks for the feedback. I was thinking about infinite ranges and generators, but decided to not implement them up to now.
Perhaps we can solve the problems in your use cases differently, i.e. with the currently available functionality.
The result of the example you posted can be achieved with the following code:
std::vector<std::string> vec = {"first", "second", "third"};
for(auto & el : fplus::enumerate(vec))
std::cout << el.second << " " << el.first << '\n';
Do you have other typical use cases for generators in mind yet?
from functionalplus.
Well, enumerate seems very helpful.. I didn't know of it..
I'd need to read all the provided functions to learn all the useful stuff. Are you taking inspiration from Haskell or Python? Should i try searching for the relevant function names of these two languages?
Also I suppose that this being a functional library I should learn from other languages how to do funny stuff in a functional way (being a C++ programmer i can't appreciate the utility of "tail" or "maybe").
It could be useful to link some more examples or tutorials from other languages to better understand the functional usage of the library.
Lastly I don't have much more use cases in mind, probably because there isn't language support for yeld and other stuff like that, so I could only think of use cases after having some experience with these techniques.
from functionalplus.
My main inspiration comes from Haskell and Elm.
But instead of searching for functions there, I suggest you try out the FunctionPlus API search.
If you for example need a function to concatenate a vector of strings with some delimiter string, you can search for the type of this hypothetical function (vector<string>, string) -> string
and you will find fplus::join that does exactly what you want. In this functional style, the type signature of the function often is enough to deduce what the function does. :)
But I understand very well that functional thinking can be quite unfamiliar if you come from an imperative background. I went through the same transformation. In case you are interested, I wrote an article about my experience back then.
tail
is btw. something that is not used very often in daily work with functional languages. maybe
on the other hand is.
A few tutorials about using fplus
to solve problems functionally sounds like a very good idea. Perhaps one could use fplus
to solve basic exercises from hackerrank or somethink alike and explain the process.
Is this something you would be interested in contributing. It could be a very good exercise for you and of course it would help other learners a lot.
from functionalplus.
I don't think I'll have time to help... sorry.
Anyway I'm having mixed results with the API search:
searching for:
[a] -> [(Int, a)]
will return "enumerate" very low in the rankings
from functionalplus.
No problem, your feedback already is helpful. :)
Especially the problem with the search for [a] -> [(Int, a)]
seems to be a bug in the matching algorithm. I will have a deeper look at it.
from functionalplus.
@sjeps OK, this is fixed now. You will find enumerate
as expected with [a] -> [(Int, a)]
.
from functionalplus.
Related Issues (20)
- implement drop_last_while method HOT 2
- Unit tests always succeeding, even when breaking them on purpose HOT 5
- Consecutive build should only re-build changed files instead of all. (Circular build dependency in CMake setup?) HOT 2
- error: exception handling disabled, use ‘-fexceptions’ to enable HOT 1
- keep_by_idx() returns list of empty elements. HOT 4
- Branch `master` will be renamed to `main` in November HOT 1
- 0.2.16-p0: Tests fail to build: "EQUAL" "1" Unknown arguments specified HOT 10
- Cannot compile with gcc 11.2 in C++20 mode HOT 3
- make c++ class function to c pointer HOT 7
- Add int overrides for (some) size_t params as a convenience for fplus::fwd? HOT 3
- fplus::compose with yet unknown output type HOT 3
- parallel_for ? (no, this is not the 1st of April ;-) HOT 3
- IO Monad HOT 5
- composition.hpp uses std::result_of HOT 5
- Function to print std::tuple HOT 5
- Some List Functions (in particular, fplus::transform etc.) do not work with custom container. What needs to be added? HOT 6
- Clang 16: incompatible initializer of type (container_common_test) HOT 3
- FunctionalPlus does not compile with C++20 (std::result_of was removed) HOT 3
- CI fails because of missing GLIBC HOT 8
- Conan packages of this library are often outdated HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from functionalplus.