Last active
September 11, 2023 14:46
-
-
Save MikaelFangel/40556eef6cc5039774cb019460a9d050 to your computer and use it in GitHub Desktop.
How to read 2D array from console in F#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
// Create a rectangular array of chars | |
let read2DCharArray rowCount colCount = | |
let rows = [| for _ in 1 .. rowCount -> Console.ReadLine() |> Array.ofSeq |] | |
Array2D.init rowCount colCount (fun i j -> rows[i][j]) | |
// Create a jagged array of chars | |
let read2DCharArrayJagged rows = | |
[| for _ in 1 .. rows -> Console.ReadLine() |> Array.ofSeq |] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment