Sha256: bc3f0043476f615056b10be18aa74181cea5a3a6e86ce86cfeeb3347c4653fa1

Contents?: true

Size: 686 Bytes

Versions: 396

Compression:

Stored size: 686 Bytes

Contents

module RobotName

let random = System.Random()

type Robot = { name: string }

let letters = ['A'..'Z']
let digits = ['0'..'9']

let NumberOfLetters = 2;
let NumberOfDigits = 3    

let takeRandomElements xs length = List.init length (fun _ -> List.item (random.Next(List.length xs)) xs)
let generateRandomString chars length = new System.String(takeRandomElements chars length |> List.toArray)
let generateLetters() = generateRandomString letters NumberOfLetters
let generateDigits() = generateRandomString digits NumberOfDigits
let generateName() = generateLetters() + generateDigits()

let mkRobot() = { name = generateName() }

let name robot = robot.name
let reset _ = mkRobot()

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/fsharp/exercises/robot-name/Example.fs
trackler-2.2.1.179 tracks/fsharp/exercises/robot-name/Example.fs
trackler-2.2.1.178 tracks/fsharp/exercises/robot-name/Example.fs
trackler-2.2.1.177 tracks/fsharp/exercises/robot-name/Example.fs
trackler-2.2.1.176 tracks/fsharp/exercises/robot-name/Example.fs
trackler-2.2.1.175 tracks/fsharp/exercises/robot-name/Example.fs
trackler-2.2.1.174 tracks/fsharp/exercises/robot-name/Example.fs
trackler-2.2.1.173 tracks/fsharp/exercises/robot-name/Example.fs
trackler-2.2.1.172 tracks/fsharp/exercises/robot-name/Example.fs
trackler-2.2.1.171 tracks/fsharp/exercises/robot-name/Example.fs
trackler-2.2.1.170 tracks/fsharp/exercises/robot-name/Example.fs
trackler-2.2.1.169 tracks/fsharp/exercises/robot-name/Example.fs
trackler-2.2.1.167 tracks/fsharp/exercises/robot-name/Example.fs
trackler-2.2.1.166 tracks/fsharp/exercises/robot-name/Example.fs
trackler-2.2.1.165 tracks/fsharp/exercises/robot-name/Example.fs
trackler-2.2.1.164 tracks/fsharp/exercises/robot-name/Example.fs
trackler-2.2.1.163 tracks/fsharp/exercises/robot-name/Example.fs
trackler-2.2.1.162 tracks/fsharp/exercises/robot-name/Example.fs
trackler-2.2.1.161 tracks/fsharp/exercises/robot-name/Example.fs
trackler-2.2.1.160 tracks/fsharp/exercises/robot-name/Example.fs