Skip to content

GeneralD/FsharpHanoi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FsharpHanoi

language framework FSharpPlus type status

FsharpHanoi hero banner

A small F# console sample that solves the Tower of Hanoi puzzle using the State monad from FSharpPlus. Each recursive move is pushed onto a state-tracked list via monad { ... } computation expressions, and the final move sequence is printed to the console.

This is a legacy learning sample (last updated in 2020) targeting .NET Framework 4.5.1 with the classic .fsproj / packages.config project format.

How It Works

  • hanoi src bare dst height recursively builds the move sequence inside State<Step list, unit>
  • Each move is recorded as a Step record (Src, Dst, Height) using modify
  • State.exec runs the computation against an empty list and yields the ordered move list
  • main solves a 3-disk puzzle from "Left" to "Right" and prints the result with printfn "%A"

Requirements

  • .NET Framework 4.5.1 (or Mono) with F# tooling — Visual Studio / Visual Studio for Mac era
  • NuGet packages (via packages.config): FSharp.Core 4.7.2, FSharpPlus 1.1.1, System.ValueTuple 4.4.0

Usage

Open FsharpHanoi.sln in Visual Studio, restore NuGet packages, then build and run. The program prints the move list for a 3-disk Tower of Hanoi. Change the argument of result in Program.fs to solve for a different disk count.

Project Structure

FsharpHanoi.sln          # Solution file
FsharpHanoi/
  Program.fs             # Hanoi solver using FSharpPlus State monad
  FsharpHanoi.fsproj     # Legacy-format F# project (net451)
  packages.config        # NuGet package pins

About

Tower of Hanoi solver in F# using the FSharpPlus State monad — a legacy .NET Framework console sample.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages