@@ -37,14 +37,14 @@ let inline isSingleton l =
3737
3838let inline isNonNull x = not ( isNull x)
3939let inline nonNull msg x = if isNull x then failwith ( " null: " ^ msg) else x
40- let (= ==) x y = LanguagePrimitives.PhysicalEquality x y
40+ let inline (= ==) x y = LanguagePrimitives.PhysicalEquality x y
4141
4242//---------------------------------------------------------------------
4343// Library: ReportTime
4444//---------------------------------------------------------------------
4545let reportTime =
46- let tFirst = ref None
47- let tPrev = ref None
46+ let tFirst = ref None
47+ let tPrev = ref None
4848 fun showTimes descr ->
4949 if showTimes then
5050 let t = System.Diagnostics.Process.GetCurrentProcess() .UserProcessorTime.TotalSeconds
@@ -237,36 +237,12 @@ module Option =
237237 let mapFold f s opt =
238238 match opt with
239239 | None -> None, s
240- | Some x -> let x ' , s' = f s x in Some x', s'
241-
242- let otherwise opt dflt =
243- match opt with
244- | None -> dflt
245- | Some x -> x
246-
247- let fold f z x =
248- match x with
249- | None -> z
250- | Some x -> f z x
251-
252- let attempt ( f : unit -> 'T ) = try Some ( f()) with _ -> None
253-
254-
255- let orElseWith f opt =
256- match opt with
257- | None -> f()
258- | x -> x
259-
260- let orElse v opt =
261- match opt with
262- | None -> v
263- | x -> x
264-
265- let defaultValue v opt =
266- match opt with
267- | None -> v
268- | Some x -> x
240+ | Some x ->
241+ let x ' , s' = f s x
242+ Some x', s'
269243
244+ let attempt ( f : unit -> 'T ) = try Some ( f()) with _ -> None
245+
270246module List =
271247
272248 //let item n xs = List.nth xs n
@@ -442,9 +418,6 @@ module List =
442418 | x:: xs -> if i= n then f x:: xs else x:: mn ( i+ 1 ) xs
443419
444420 mn 0 xs
445-
446- let rec until p l = match l with [] -> [] | h:: t -> if p h then [] else h :: until p t
447-
448421 let count pred xs = List.fold ( fun n x -> if pred x then n+ 1 else n) 0 xs
449422
450423 // WARNING: not tail-recursive
@@ -521,23 +494,9 @@ module String =
521494 if s.Length = 0 then s
522495 else lowercase s.[ 0 .. 0 ] + s.[ 1 .. s.Length - 1 ]
523496
497+ let dropPrefix ( s : string ) ( t : string ) = s.[ t.Length.. s.Length - 1 ]
524498
525- let tryDropPrefix ( s : string ) ( t : string ) =
526- if s.StartsWith t then
527- Some s.[ t.Length.. s.Length - 1 ]
528- else
529- None
530-
531- let tryDropSuffix ( s : string ) ( t : string ) =
532- if s.EndsWith t then
533- Some s.[ 0 .. s.Length - t.Length - 1 ]
534- else
535- None
536-
537- let hasPrefix s t = Option.isSome ( tryDropPrefix s t)
538- let dropPrefix s t = match ( tryDropPrefix s t) with Some( res) -> res | None -> failwith " dropPrefix"
539-
540- let dropSuffix s t = match ( tryDropSuffix s t) with Some( res) -> res | None -> failwith " dropSuffix"
499+ let dropSuffix ( s : string ) ( t : string ) = s.[ 0 .. s.Length - t.Length - 1 ]
541500
542501 open System
543502 open System.IO
0 commit comments