From: Janne H. <jjh...@gm...> - 2005-08-10 08:00:39
|
> Having gone back and read the first message in this thread- the only > difference between my code and the original proposed code is: > 1) I shortened some of the variable names (note that this is not > necessarily good) > 2) I created an inner loop function, instead of making fold_left_while > recursive. >=20 > Otherwise, my code is identical to the code originally posted. Yep. I take it now that fold_left_while is OK as it is now. If we decide to add it, we should add fold_right_while as well. If we make it tail-recursive, it's actually more convenient than fold_left_while. Skaller suggested split/fold_*_while should take the rest of the list as an argument to the while-condition predicate. I don't like that idea, especially as it's not orthogonal to the already existing dropwhile and takewhile functions, or pretty much all the other list functions taking some ('a -> bool) function as a parameter. I don't have a good name to propose for split. I'd rather rename List.split and List.combine to List.unzip and List.zip respectively. But I'm not sure if changing the stdlib function names is such a good idea.. Haskell prelude contains "break" function. It is similar to the split function I'm proposing. But if we add functions that can be found from Haskell's standard library, we should try to make them behave similarly. How about the name "separate" instead of "split"? That is what it's doing anyway, isolating parts of a list separated by some values. I still think "split" a better name for it though. Best regards, Janne |