From lliao@ren.eecis.udel.edu Sun Oct 6 13:09:01 2002 Date: Sun, 6 Oct 2002 13:07:38 -0400 (EDT) From: Li Liao To: Damian Dechev Subject: Re: HW2 question > I am having trouble applying foldl to exec and I think that > the problem comes from the fact that State is actually not > a Command List but a (Value list*Value Dict list), I would have > no doubt how to use foldl with exec if the arguments of exec > were for example (command, command list) Beware "execute" is a function that takes a command list. While I am assuming you understand how foldl works, let me write the definition here to just remind ourselves. foldl f e [x_1, x_2, ..., x_n] = f(x_n, ..., f(x_1, e)...) and its type is ('a * 'b -> 'b) -> 'b -> 'a list -> 'b. Function f takes two arguments: x and e. Function foldl enables f to work on a list of xs given e. Stick to the definition and try to connect "f, e, and xs" with "exec, state, command list", it should not be difficult to construct "execute" out of "exec" using foldl. > but in this case I am not sure how can I make foldl work. > Can you please give me some advice how can I apply foldl on exec ? > Thank you so much. However, if you can write a version of "execute" without using foldl, it is also fine. I decided to lift the requirement of using foldl and to give a few extra credits if foldl is used. Li