Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Wanted to make sure I can consistently do my 5x5 workout in under an hour. Of course F# is needed for the task!
type event = { text : string; minutes: double }
type exercise = {
text : string
setNum : int
setupTime : double
setTime : double
restTime : double
}
let exerciseExpander exercise =
[
yield { text = "Set up for " + exercise.text; minutes = exercise.setupTime}
for i=0 to exercise.setNum do
yield { text = exercise.text + ", set 1"; minutes = exercise.setTime}
yield { text = "rest"; minutes = exercise.restTime}
]
let expanded (workout: exercise list) =
workout
|> List.map (fun (z:exercise) -> exerciseExpander z)
|> List.collect (fun z -> z)
let workoutTimePrinter name (workout : exercise list) =
workout
|> expanded
|> List.sumBy (fun (t : event) -> t.minutes)
|> printfn "%s: %A" name
let squats = { text = "squats"; setNum = 5; setupTime = 0.5; setTime = 0.5; restTime = 2.0 }
let benchPress = { text = "bench press"; setNum = 5; setupTime = 0.5; setTime = 0.5; restTime = 2.0 }
let bentOverRow = { text = "bent over row"; setNum = 5; setupTime = 0.5; setTime = 0.5; restTime = 2.0 }
let deadlift = { text = "deadlift"; setNum = 1; setupTime = 1.0; setTime = 0.5; restTime = 2.0 }
let standingPress = { text = "standing press"; setNum = 5; setupTime = 0.5; setTime = 1.0; restTime = 2.0 }
let workoutA = [squats; benchPress; bentOverRow]
let workoutB = [squats; standingPress; deadlift]
workoutA |> workoutTimePrinter "Workout A"
workoutB |> workoutTimePrinter "Workout B"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.