0

Create a function in Oz that takes as input a list of integers. The function's outputs are two lists: the first list contains even numbers the second list odd numbers. The two lists are separated by a #.

Es. {Browse {F [1 2 3 4]}} -----> [1 3]#[2 4]

I try with this, but it's wrong. Can you explain me why and how to fix it?

declare
fun{F L}
fun{Fun2 L L1#L2}
case L of nil then nil#nil
[ ]H|T then if H mod 2 == 0 then
(H|L1)#L2
{Fun2 T L1#L2}
else
L1#(H|L2)
end
end
{Fun2 L nil#nil}
end
end

0 Answers0