A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by TheRenegadeCoder
Welcome to the Remove All Whitespace in OCaml page! Here, you'll find the source code for this program as well as a description of how the program works.
(* Use custom function instead of Char.Ascii.is_white because the builtin also matches
on vertical tab and form feed which are not considered whitespace for the
purposes of this problem *)
let is_whitespace = function ' ' | '\t' | '\n' | '\r' -> true | _ -> false
let remove_whitespace s =
String.to_seq s |> Seq.filter (Fun.negate is_whitespace) |> String.of_seq
let () =
print_endline
@@
match Sys.argv with
| [| _; s |] when s <> "" -> remove_whitespace s
| _ -> "Usage: please provide a string"
Remove All Whitespace in OCaml was written by:
If you see anything you'd like to change or update, please consider contributing.
No 'How to Implement the Solution' section available. Please consider contributing.
No 'How to Run the Solution' section available. Please consider contributing.