-2

hey there another haskell question i have a function of type f :: CSP -> Assignment -> Var -> Int -> CSP

i want to write a function with the type

g :: CSP -> Assignment -> Var -> [Int] -> CSP

which applies the original function to all of the elements in the list [Int]. The CSP that it is passed should be updated each time f is applied, the Assigment will stay the same as will the Var. I'm pretty sure I need to use a fold but I really don't understand them. I'd really appreciate it if somebody could help me out and maybe try and explain folds.

Thomas M. DuBuisson
  • 64,245
  • 7
  • 109
  • 166
user1226239
  • 69
  • 1
  • 1
  • 6

1 Answers1

2

You said you've worked it out, but just in case:

g c a v is = foldl (\c i -> f c a v i) c is
Thomas M. DuBuisson
  • 64,245
  • 7
  • 109
  • 166