I have list in SML, which contains members from datatype "expr"
(list "b").
I also have function "What"
, which it's arguments are only from dayatype "expr"
.
Now I have problem in the next code:
datatype expr = K of string| Number2 of expr * (expr list);
datatype number = Number1 of string | Number3 of int;
What....
| What (Number2 (t,[]))= Number3(0)::What(t)
| What (Number2 (y,(a::b)) = append (What(a), What(b));
The error occurred because b is list of expr
, and the function What
got only "expr
" and not "expr list
". All I want to do is to check all the members is "b"
, and make a new list - which member is from datatype "number"
.
I tried to use map function
, but it didn't help (see the marks here: SML - unbound variable or constructor).
Any idea? There is another way to do it, without using map? I stack on it for a day..