You can simply write:
let explode s = [for c in s -> string c] let matches str strc = let eStr = explode str List.contains strc eStr let space = matches " \t\n\r" let punctuation = matches "() [] {}," let symbolic = matches "~' !@ #$%^&*-+=|\\:;<>.?/" let numeric = matches "0123456789" let alphanumeric = matches "abcdefghijklmopqrstuvwxyz_'ABCDEFGHIJKLMNOPQRSTUVWXYZ"
F # tends to be written using easy rather than verbose syntax, so you usually don't need to use the in , begin and end . See https://msdn.microsoft.com/en-us/library/dd233199.aspx for more details on the differences.
Personally, I would probably reorganize all these string -> bool functions into active templates, for example:
let (|Alphanumeric|_|) str = match matches "abcdefghijklmopqrstuvwxyz_'ABCDEFGHIJKLMNOPQRSTUVWXYZ" str with |true -> Some str |false -> None let (|Symbolic|_|) str = match matches "~' !@ #$%^&*-+=|\\:;<>.?/" str with |true -> Some str |false -> None
Then you can map the image, for example:
match c with |Alphanumeric _ -> // alphanumeric case |Symbolic _ -> // symbolic case |_ -> // other cases
source share