1 people like it.
Like the snippet!
Fythia
F# port of https://github.com/g0d/Pythia/. All the awesomeness of the original + purely functional!
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
|
type Pythia = private | Results of int list with
static member Create() = Results []
member p.Generate() =
let (Results r) = p
let rec aux () =
let mynum = int(System.Random().NextDouble() * 9007199254740992.)
if r |> List.exists ((=) mynum) then aux ()
else
mynum, Results(mynum :: r)
aux ()
|
union case Pythia.Results: int list -> Pythia
Multiple items
val int : value:'T -> int (requires member op_Explicit)
Full name: Microsoft.FSharp.Core.Operators.int
--------------------
type int = int32
Full name: Microsoft.FSharp.Core.int
--------------------
type int<'Measure> = int
Full name: Microsoft.FSharp.Core.int<_>
type 'T list = List<'T>
Full name: Microsoft.FSharp.Collections.list<_>
static member Pythia.Create : unit -> Pythia
Full name: Script.Pythia.Create
val p : Pythia
member Pythia.Generate : unit -> int * Pythia
Full name: Script.Pythia.Generate
val r : int list
val aux : (unit -> int * Pythia)
val mynum : int
namespace System
Multiple items
type Random =
new : unit -> Random + 1 overload
member Next : unit -> int + 2 overloads
member NextBytes : buffer:byte[] -> unit
member NextDouble : unit -> float
Full name: System.Random
--------------------
System.Random() : unit
System.Random(Seed: int) : unit
Multiple items
module List
from Microsoft.FSharp.Collections
--------------------
type List<'T> =
| ( [] )
| ( :: ) of Head: 'T * Tail: 'T list
interface IEnumerable
interface IEnumerable<'T>
member GetSlice : startIndex:int option * endIndex:int option -> 'T list
member Head : 'T
member IsEmpty : bool
member Item : index:int -> 'T with get
member Length : int
member Tail : 'T list
static member Cons : head:'T * tail:'T list -> 'T list
static member Empty : 'T list
Full name: Microsoft.FSharp.Collections.List<_>
val exists : predicate:('T -> bool) -> list:'T list -> bool
Full name: Microsoft.FSharp.Collections.List.exists
More information