Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Fetching latest commit…
Cannot retrieve the latest commit at this time.
|Failed to load latest commit information.|
NOTE: Sadly I can't summon the effort needed to maintain this library. If you want to take over, email me at email@example.com Prelude.ml: an OCaml stdlib replacement with a Haskellish flavour. Requirements: pcre, netstring (ocaml-net) oUnit for the tests Compile: omake Run tests: omake test Run tests, printing out the test name before running it: omake test_verbose Released under the MIT license. Features -------- A more consistent interface across lists, arrays, strings and bytestrings. Bytestrings, strings wrapped in char_of_int / int_of_char. Parallel combinators for (1D) Bigarrays and the aforementioned collections. Shell command utilities. Filesystem utilities. Path utilities. IO utilities. User/group utilities. Time utilities. Function combinators, option combinators, exception combinators, tuple combinators, comparisons, conversions, recursions, floats, ints, hashes, maps, unfolds, folds, scans, spans, slices and subs. Everything in a single module for a very scripting language -like experience. I have aimed to keep the list functions tail-recursive, the trade-off between a speed loss from reversing lists and having support for arbitrary length lists weighing towards the latter in my scales. Some functions are implemented in a very combinatorial wanking -fashion and should be rewritten for speed and clarity. Alternatively I could say that they're good eta/beta-reduction tests for the compiler. Latest news ----------- - working on other stuff, will try to trickle in bug fixes when found, along with extra tests - done with writing a more complete set of tests for src/prelude.ml Examples -------- open Prelude (* my last modified file in /tmp *) lsFull "/tmp" |> filter (eq (currentUid ()) @. fileUid) |> maximumBy mtime (* concatenate files a, b and c into d *) concatFiles "d" ["a"; "b"; "c"] (* grep `find' output for AAC files *) readCmd ["find"; "music"] |> lines |> filter (xmatch "\\.m4[ap]$") (* fill a 100MB Bigarray with coreCount() parallel processes *) bapinit Bigarray.char (fun i -> chr (Unix.getpid() mod 256)) (int 10e8) (* blend two bytestrings together in parallel *) bpzipWith average2 s1 s2 (* the speed gains here are likely non-existent, as forking and marshalling overheads dominate the compute-poor blending function *) (* or written out as a parallel init that reads from the closure *) bpinit (fun i -> ((buget s1 i) + (buget s2 i)) / 2) (min (blen s1) (blen s2)) As you may notice, the different collections have different prefixes for the function names. List functions have no prefix, Array functions have 'a', String functions have 's', Bytestring functions have 'b' and Bigarray functions have 'ba'. Additionally, float functions use a 'f' suffix, e.g. sumf [1.0; 2.0] vs. sum [1; 2]. There are PreList, PreArray, PreString and Bytestring modules for the collections as well, but do note that they take some liberties with the argument orders of some functions in the name of easier composition, e.g. Array.init : int -> (int -> 'a) -> 'a array vs. PreArray.init : (int -> 'a) -> int -> 'a array. in map (PreArray.init id) (10--15) and map (fun i -> Array.init i id) (10--15) Development ----------- http://www.github.com/kig/preludeml/tree/master Contact ------- Ilmari Heikkinen <firstname.lastname@example.org>