Question: ) Briefly explain what the following function is doing: fun foo 11 12 = foldl (fn (hd, acc) => if (exists 12 hd) then

) Briefly explain what the following function is doing: fun foo 11 12 = foldl (fn (hd, acc) => if (exists 12

) Briefly explain what the following function is doing: fun foo 11 12 = foldl (fn (hd, acc) => if (exists 12 hd) then acc else hd ::acc) [] 11 foo: 'a list -> 'a list -> 'a list assuming that function exists is defined as fun exists [] n = false I exists (x:xs) n = if n = x then true else exists xs n For example, what is the result of foo ["a","b", "c"] ["b", "c"]?

Step by Step Solution

3.49 Rating (149 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The function foo performs a left fold on a list using a function that returns the head of the list if the element 12 is not in the head and the accumu... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!