Created
March 7, 2012 13:35
-
-
Save loverdos/1993160 to your computer and use it in GitHub Desktop.
Show PATH elements in separate lines
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
(* My second Ocaml program ever *) | |
(* *) | |
(* @author Christos KK Loverdos *) | |
open Str | |
(* Version 1 *) | |
(* ========= *) | |
(* let () = *) | |
(* let colon_re = Str.regexp ":" *) | |
(* and path = Sys.getenv "PATH" in *) | |
(* let paths = Str.split colon_re path in *) | |
(* let print s = *) | |
(* print_string s; *) | |
(* print_newline (); *) | |
(* in *) | |
(* List.iter print paths *) | |
(* Version 2 *) | |
(* ========= *) | |
(* List.iter (print_endline) (Str.split (Str.regexp ":") (Sys.getenv "PATH")) *) | |
(* Version 3 *) | |
(* ========= *) | |
let (|>) x f = f x | |
let () = | |
Sys.getenv "PATH" |> Str.split (Str.regexp ":") |> List.iter print_endline |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment