Created
October 24, 2017 13:26
-
-
Save Heimdell/6fc12bd32b8ff85f0c97d64e3897ebcc to your computer and use it in GitHub Desktop.
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
fun readLine () = TextIO.inputLine TextIO.stdIn | |
fun writeLine str = TextIO.outputSubstr (TextIO.stdOut, Substring.full str) | |
fun main () = | |
let | |
val words = String.tokens (fn x => x = #" ") | |
fun input keys vals = | |
case readLine () of | |
SOME(line) => ( | |
case words line of | |
(k :: v :: _) => | |
input (k :: keys) (v :: vals) | |
) | |
| NONE => | |
(keys, vals) | |
val (keys, vals) = input [] [] | |
in | |
List.app (fn k => List.app (fn v => writeLine (k ^ " " ^ v)) (List.rev vals)) (List.rev keys) | |
end | |
val _ = main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment