What's your naming convention for helper functions?

You can call the helper function anything you want, and it won't matter as long as you don't put the helper function in the "global" namespace. Simply adding a "prime" seems a common practice. :) E.g., in Haskell,

reverse :: [a] -> [a]
reverse = reverse' []
    where reverse' :: [a] -> [a] -> [a]
          reverse' result [] = result
          reverse' result (x:xs) = reverse' (x:result) xs

I always use do_, like "do_compute" with "compute". I find it quite descriptive as it is effectively the part of the function that performs the action, whereas the "compute" that gets called needs to have a simple descriptive name for the outside world.


I agree with ShreevatsaR, if you don't make the helper function top-level (or worse, put it in the export list), than it doesn't matter what its name is. I tend to call helper functions f and g.

reverse :: [a] -> [a]
reverse = f []
  where
    f ys []     = xs
    f ys (x:xs) = f (x:ys) xs

I just use this naming scheme for small functions (otherwise I don't know what the f refers to). Then again, why would you ever write big functions?

However, if you do want to export your 'helper' function because it might be useful to others, I would call it:

reverseAccumulator

Like Haskell's zip and zipWith. But I wouldn't call those 'helper' functions, zipWith is just a generic function and zip is the default implementation (probably the one thats used the most).