Skip to content

Instantly share code, notes, and snippets.

/ls.ml Secret

Created October 5, 2014 21:28

Revisions

  1. @invalid-email-address Anonymous created this gist Oct 5, 2014.
    16 changes: 16 additions & 0 deletions ls.ml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@

    open Core.Std

    module Regex = Re2.Regex

    let ls pattern =
    let pat = Regex.create_exn pattern in
    let matcher = Regex.matches pat in
    Sys.ls_dir "."
    |> List.filter ~f:matcher
    |> List.iter ~f:(fun s -> print_string s; print_newline ())

    let () =
    match In_channel.input_line stdin with
    | None -> (print_string "No Input"; print_newline ())
    | Some pat -> ls pat