F# version of Haskell's list destructuring

Viewed 1999

How do I do this haskell in F#:

f acc (x:y:z:xs) = f (acc-x+y*z) xs
f acc [] = acc

The algorithm there is arbitrary, just the important point is selecting the first 3 and the tail of the list because I need to use all of them and the tail.

Do I have to write it imperatively in F# using repeated head calls to pop off x y and z?

Edit: Please comment what this technique is formally called in haskell and I'll put it in the question title for other peoples future searches, I can't remember it off hand.

2 Answers
Related