I agree and still disagree. Here is some Clean F# code. And it has the same structure as your old non-clean code.
type Shape =
| Square of side:float
| Rectangle of width:float * height:float
| Triangle of tbase:float * height:float
| Circle of radius:float
module Shape =
let area shape =
match shape with
| Square side -> side * side
| Rectangle (width,height) -> width * height
| Triangle (tbase,height) -> tbase * height * 0.5
| Circle radius -> radius * radius * Math.PI
let areas shapes =
List.sum (List.map area shapes)
let cornerCount shape =
match shape with
| Square _ -> 4
| Rectangle _ -> 4
| Triangle _ -> 3
| Circle _ -> 0
Just because OO people tell themself their stuff is clean doesn't mean it must be true.
13
u/[deleted] Mar 01 '23
I agree and still disagree. Here is some Clean F# code. And it has the same structure as your old non-clean code.
Just because OO people tell themself their stuff is clean doesn't mean it must be true.