There was fold_left and fold_right. I didn't like these names, and I don't think they were meaningful (fold_left goes to the right, fold_right goes to the left, uh?). When order doesn't matter, e.g. if you multiply list items, beginners don't know which one they should use. In Haskell, it's recommended to use foldr (because of laziness), while in OCaml you should use fold_left (because of tail recursion).

In F#, the default is to use fold (which is what you need most of the time). When you need to go backward, you use foldBack. I think it makes more sense.

Laurent.

By on 1/13/2011 1:20 PM ()

While I agree that getting rid of the underscores and going CamelCase/camelCase all the way is a good idea, renaming well known functions like fold_right to foldBack is not, since this can be very confusing for translating code between functional languages, especially to newcomers.

Also the Uppercase type params like 'T and 'U don't really fit a functional language, since a lot of functions are lowercase and abbreviated, the uppercase type params will overshadow the names.
I know it was probably done to get more in line with other .NET languages but I think a good middleground would be to have ('a 'b) ('t 'u) and('T 'U) as an IDE option.

By on 5/18/2009 7:43 PM ()

I think that the name FoldRight makes the intention easier to understand than foldback.

By on 1/13/2011 12:04 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper