package spotlib
Module Spotlib.BaseSource
Basic functionns. They are accessible via open Spotlib.Spot
Common types
Result/Either monad using polymorphic variant. Obsolete. Use the primitive type result instead.
Function compositions and other operators
Functional composition. Haskell's (.) Use power if you want to use the original ( ** ).
Same as ( ** ).
Functional composition in swapped order. Same as Haskell's (>>>)
Replacement of ( ** )
Haskell's ($).
Haskell's ($), with label 'f'.
"tee". v |-- f is v but f v is run before v is returned
flip of Haskell
Super flip of Haskell. The first argument is labeled and becomes commutative.
Super flip of Haskell. The first argument is labeled and becomes commutative.
flip f x2 x3 x1 = f x1 x2 x3
Imperative operations
with_ref and with_ref_ runs a function with a reference with the specified initial value.
I/O
Misc things
Printf.sprintf is available without tying Printf.
Printf.ksprintf is available without tying Printf.
Format.eprintf, prefix style.
Generic memozation by hash with fixed point. You can call memoized self inside:
memoize_gen (fun self -> .... self v ....) f
Memozation by hash
Memozation by hash with fixed point. You can call memoized self inside:
memoize_rec (fun self -> .... self v ....) f
Simple profiling. Returns seconds. If f a raises an exception e, then time f a raises e too.
val find_by_iter :
(('a -> unit) -> 'collection -> unit) ->
('a -> bool) ->
'collection ->
'a optionfind the first element where predicate holds by iteration find_by_iter iterator predicate colleciton
find_in_tree get_subs p a visits a and finds the first sub node in which p holds. get_subs returns the sub nodes of a node.
Keep repeating a function until a final result is producted.
Comparison
compare_on f a b compares a and b not by themselves but by f a and f b.
rev_compare_on f a b = - (compare_on f a b)
add_if_not_mem adds a to asref if not (List.mem a !asref) then return `NewlyAdded. Otherwise it returns `AlreadIn and asref is not modified.
String <-> bytes conversions