Question

i want to add some amounts which in my tuple. i want to take that out and total it and show. i want to use Foldr function.

can someone help me out how to do

Was it helpful?

Solution

Assuming you have a list of tuples, you probably want to start by reading up on the fold functions, perhaps here. It dives into foldl, but foldr is similar. It just works from the other end of the list. The graphical representation at the bottom of this other thread should help.

Once you've done that, you should be able to work out the details. I assume you already know how to get a value out of a tuple?

OTHER TIPS

You can't. foldr (and foldl, etc) work on lists, not tuples.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top