//========================================================================= // (c) Microsoft Corporation 2005-2009. //========================================================================= namespace Microsoft.FSharp.Core open System.Diagnostics open Microsoft.FSharp.Core open Microsoft.FSharp.Core.LanguagePrimitives.IntrinsicOperators open Microsoft.FSharp.Collections open Microsoft.FSharp.Core.Operators [] module Option = [] let get option = match option with None -> invalidArg "option" "The option value was None" | Some x -> x [] let isSome option = match option with None -> false | Some _ -> true [] let is_some option = match option with None -> false | Some _ -> true [] let isNone option = match option with None -> true | Some _ -> false [] let is_none option = match option with None -> true | Some _ -> false [] let count option = match option with None -> 0 | Some _ -> 1 [] let fold f s inp = match inp with None -> s | Some x -> f s x [] let foldBack f inp s = match inp with None -> s | Some x -> f x s [] let fold_left f s inp = match inp with None -> s | Some x -> f s x [] let fold_right f inp s = match inp with None -> s | Some x -> f x s [] let exists p inp = match inp with None -> false | Some x -> p x [] let forall p inp = match inp with None -> true | Some x -> p x [] let filter p inp = match inp with None -> None | Some x -> if p x then inp else None [] let partition p inp = match inp with None -> None,None | Some x -> if p x then inp,None else None,inp [] let iter f inp = match inp with None -> () | Some x -> f x [] let map f inp = match inp with None -> None | Some x -> Some (f x) [] let bind f inp = match inp with None -> None | Some x -> f x [] let to_array option = match option with None -> [| |] | Some x -> [| x |] [] let to_list option = match option with None -> [ ] | Some x -> [ x ] [] let length option = match option with None -> 0 | Some _ -> 1 [] let for_all p inp = match inp with None -> true | Some x -> p x