0 people like it.
Like the snippet!
Pseudoword generator
Pseudoword generator based on code from Evan Fosmark circa 2009.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
|
let rnd = System.Random()
let vowels = "aeiou"
let consonants = set ['a'..'z'] - set vowels
let from xs = xs |> Seq.nth (rnd.Next(Seq.length xs))
let vowel () = from vowels |> string
let consonant () = from consonants |> string
let cv () = consonant() + vowel()
let cvc () = cv() + consonant()
let syllable () = (from [vowel; cv; cvc])()
let pseudoword() = String.concat "" [for x in 0..rnd.Next(1,3) -> syllable ()]
pseudoword()
|
val rnd : System.Random
namespace System
Multiple items
type Random =
new : unit -> unit + 1 overload
member GetSampleForLargeRange : unit -> float
member InternalSample : unit -> int
member Next : unit -> int + 2 overloads
member NextBytes : buffer: byte [] -> unit + 1 overload
member NextDouble : unit -> float
member Sample : unit -> float
static member GenerateGlobalSeed : unit -> int
static member GenerateSeed : unit -> int
static val s_globalRandom : Random
...
--------------------
System.Random() : System.Random
System.Random(Seed: int) : System.Random
val vowels : string
val consonants : Set<char>
val set : elements:seq<'T> -> Set<'T> (requires comparison)
val from : xs:seq<'a> -> 'a
val xs : seq<'a>
module Seq
from Microsoft.FSharp.Collections
System.Random.Next() : int
System.Random.Next(maxValue: int) : int
System.Random.Next(minValue: int, maxValue: int) : int
val length : source:seq<'T> -> int
val vowel : unit -> string
Multiple items
val string : value:'T -> string
--------------------
type string = System.String
val consonant : unit -> string
val cv : unit -> string
val cvc : unit -> string
val syllable : unit -> string
val pseudoword : unit -> string
module String
from Microsoft.FSharp.Core
val concat : sep:string -> strings:seq<string> -> string
val x : int
More information