Skip to content

Instantly share code, notes, and snippets.

@DeMarko
Created April 7, 2010 21:04
Show Gist options
  • Save DeMarko/359459 to your computer and use it in GitHub Desktop.
Save DeMarko/359459 to your computer and use it in GitHub Desktop.
(* written by @chrisamaphone of chrisamaphone fame *)
val s_end = "\nval s_start = \"val s_end = \"\nfun quote #\"\\n\" = \"\\\\n\"\n\t| quote #\"\\\\\" = \"\\\\\\\\\"\n\t| quote c = Char.toString c\n\nfun q () = print (s_start ^ \"\\\"\" ^ (concat (map quote (explode s_end))) ^ \"\\\"\" ^ s_end)"
val s_start = "val s_end = "
fun quote #"\n" = "\\n"
| quote #"\\" = "\\\\"
| quote c = Char.toString c
fun q () = print (s_start ^ "\"" ^ (concat (map quote (explode s_end))) ^ "\"" ^ s_end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment