I feel like this should be easier than I’m making it, but I’m having some trouble with this function that should change a set to a list.
fun explode(st(x, xs)) =
let
val listTemp = []
in
if isEmpty(xs) then listTemp::x else explode(xs)::x
end
| explode(nilset) = [];
I’m getting a type clash, saying I’m trying to go from ''a list list to ''a list. Any help would be much appreciated.
edit: said ”a list -> ”a list list… oops.
The left operand of the
::operator should be an element and the right operand a list. You’re using it with a list as the left operand and an element as the right operand. That’s the type error.Assuming the order of the generated list does not matter, you can simply switch the operands. If it does matter, you can still switch the operands and then use
List.revto reverse the resulting list after building the complete list.