-3

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

Don Stewart
  • 137,316
  • 36
  • 365
  • 468
Nubkadiya
  • 3,285
  • 13
  • 40
  • 45
  • 1
    Smells a like a homework question. – rlb.usa Mar 18 '10 at 16:53
  • no its not. i have done my problem. but dont know how to use foldr function properly. need to know how to. with the tuple. by taking one value from the tuple and should do the foldr function. – Nubkadiya Mar 18 '10 at 17:09

2 Answers2

3

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
  • 3,066
  • 1
  • 24
  • 40
0

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

dave4420
  • 46,404
  • 6
  • 118
  • 152