Search code examples
programming-languagesfunctional-programmingsmlsmlnj

convert string to list in Standard ML


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?


Solution

  • 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.