Created
November 15, 2015 14:54
-
-
Save monkieboy/1e170e8da28d665e45eb to your computer and use it in GitHub Desktop.
Unfold to generate a sequence of turtle commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#load "Spirograph.fs" | |
open System.Drawing | |
open FSharp.TV.Spirograph | |
let cmdsStripe = | |
[ | |
curve3rd 60.0 5 | |
turn -170.0 | |
move 80 | |
curve3rd 60.0 -5 ] | |
let cmdsGen = | |
[] | |
|> Seq.unfold (fun save -> Some(save, cmdsStripe)) | |
|> Seq.collect id | |
let innerCmds = | |
cmdsGen | |
|> Seq.take 70 | |
|> Seq.toList | |
let appendSave sCmd iCmd = | |
let revd = sCmd :: (iCmd |> List.rev) | |
revd |> List.rev | |
let cmds = | |
moveTo (250.0,250.0) | |
:: (appendSave (saveAs "basic-loop") innerCmds) | |
Seq.fold | |
(fun s f -> f s) | |
(newTurtleWithSize 500 500) | |
cmds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment