tags:

views:

180

answers:

2

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

A: 

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

Dave Hinton
Actually, they work on Foldables.
jrockway
+2  A: 

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?

Tim Perry
thank you so much. i did it. its working fine. now im trying to figure out how to do filter and Maps
Nubkadiya