Convert option to list in sml
list, pattern-matching, sml
Solution
You have basically two options. If you know that it (for sure) always returns `SOME lst`, then you could use the `valOf` function which takes an `'a option` and returns an `'a` value
- val a = SOME [1,2,3,3];
val a = SOME [1,2,3,3] : int list option
- val b = valOf a;
val b = [1,2,3,3] : int list
Your other option is to unpack it using pattern matching
case x of
SOME lst => lst
| NONE => ...
Problem
I have the following function that accepts string list list and a string. It returns a string list. ``` fun get_substitutions1 ((x::xs)::ys, s) = all_except_option((x::xs),s) @ get_substitutions1(ys,s) ; ``` The issue that I face is that all_except_option returns OPTION and so I get an error when I try to concatenate it. My question is how can I extract LIST from OPTION.