I am trying to convert the following variable:
- final "in1.txt";
val it = [|[#"S",#".",#".",#"."],[#".",#".",#".",#"."],[#"W",#".",#"X",#"W"],
[#".",#".",#"X",#"E"]|] : char list array
from 'char list array' to 'char array array' in SMLNJ. The only reason I want to do this is because I need to be able to randomly iterate through this data, to perform a Dijkstra-like algorithm for a school project (if there 's a more efficient way to make this data iteratable, I am all ears). Is there a way to do this? The function that reads the input file and returns the above is this (I found it in Stack Overflow):
fun linelist file =
let
open Char
open String
open List
val instr = TextIO.openIn file
val str = TextIO.inputAll instr
in
tokens isSpace str
before
TextIO.closeIn instr
end
fun final file =
let
fun getsudo file = map explode (linelist file)
in
Array.fromList (getsudo file)
end
and the input files that need to be processed are like the one that follows:
S...
....
W.XW
..XE