Giter VIP home page Giter VIP logo

Comments (6)

Dobiasd avatar Dobiasd commented on May 18, 2024

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.

sjeps avatar sjeps commented on May 18, 2024

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.

Dobiasd avatar Dobiasd commented on May 18, 2024

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.

sjeps avatar sjeps commented on May 18, 2024

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.

Dobiasd avatar Dobiasd commented on May 18, 2024

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.

Dobiasd avatar Dobiasd commented on May 18, 2024

@sjeps OK, this is fixed now. You will find enumerate as expected with [a] -> [(Int, a)].

from functionalplus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.