On Fri, Nov 25, 2011 at 2:45 PM, Martin Hamant <martin@...> wrote:
> fold_left() ? What is that ?
> Can I redefine remove_assoc directly in my script ?
My bad, it's list.fold, not fold_left. It's a general way of writing
recursive functions on lists, so we can redefine a (correct)
remove_assoc using it. It is now tested:
# list.remove_assoc = fun(x,l) -> list.fold(fun(l,y)->if fst(y)==x
then l else list.append([y],l) end,,l) ;;
list.remove_assoc : ('a,[('a*'b)])->[('a*'b)] where 'a is an orderable type =
# list.remove_assoc("foo",[("bar",1),("foo",2),("baz",3),("foo",5)]) ;;
- : [(string*int)] = [("baz",3), ("bar",1)]
You should use this workaround for now. In fact, my proposal for the
bug you pointed out would be to remove the builtin remove_assoc and
replace it by this cleaner scripted version.