Quick actions

cmd+k|ctrl+k

Navigation

Languages

Seq.unfold maze example

Snippet info

Language

Fsharp

Visibility

public

Author

mjg.py3

Created

2017-06-01T11:15:50Z

Updated

2017-06-01T11:15:50Z

type Maze = unit

type Point = unit
type VisitedPoint = Point
type NextPoint = Point


let deadEnd = failwith "hole"
let atEnd = failwith "hole"
let startingPoint = failwith "hole"
let takeRandomStepFrom = failwith "hole"


let tryRandomDirection (maze: Maze) (currentPosition: Point): (VisitedPoint*NextPoint) option =
  match (deadEnd currentPosition maze, atEnd currentPosition maze) with
  | _, true -> None
  | true, _ -> Some (currentPosition, startingPoint)
  | _       -> Some (currentPosition, takeRandomStepFrom currentPosition maze)
 
let someMaze = failwith "hole"
 
let howWeGotThere = Seq.unfold (tryRandomDirection someMaze) startingPoint
INFO