Skip to content

Instantly share code, notes, and snippets.

@Heimdell
Created October 24, 2017 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Heimdell/6fc12bd32b8ff85f0c97d64e3897ebcc to your computer and use it in GitHub Desktop.
Save Heimdell/6fc12bd32b8ff85f0c97d64e3897ebcc to your computer and use it in GitHub Desktop.
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