views:

134

answers:

2

Possible Duplicate:
Open file in ML(SMLNJ)

I have a string value which has value like this:

"[(1,2,3),(2,3),(6,8)]" -> string

but I want to have these values in int type like this:

[(1,2,3),(2,3),(6,8)] ->   (int list) list

what should I do?is there any function which can help me? or I have to do it myself?

A: 

You can use stringint from the String module. See for example http://wwwcgi.rdg.ac.uk:8081/cgi-bin/cgiwrap/wsi14/poplog/ml/help/string#Character%20Transformation%20Functions

swegi
JGC
Well, you have to split the input string by yourself, but this should be easy with `explode` and `implode`
swegi
+2  A: 

This problem is perfectly suited to parsing combinators, which you can steal from my friend Greg Morrisett at Harvard.

If you want to understand the underlying ideas, read Graham Hutton's paper Higher-Order Functions for Parsing. If you want to know how to implement I/O in Standard ML, consult the TextIO module in the Standard Basis Library. If you want someone to write the code for you, you may have reached the wrong web site.

Norman Ramsey
This is probably not very helpful for him directly, but I agree with your answer. I was considering offering some advice; on rereading the explanation, I realized anything I said would fall on deaf ears, especially if I didn't provide the exact code.
nlucaroni