functional programming - Readin a two-dimensional array using scala -
functional programming - Readin a two-dimensional array using scala -
suppose have txt file named "input.txt" , want utilize scala read in. dimension of file not available in beginning.
so, how build such array[array[float]]? want simple , neat way rather write code in java iterates on lines , parse each number. think functional programming should quite @ it.. cannot think of 1 now.
best regards
if input correct, can in such way:
val source = io.source.fromfile("input.txt") val info = source.getlines().map(line => line.split(" ").map(_.tofloat)).toarray source.close()
update: additional info using source
check this thread
scala functional-programming
Comments
Post a Comment