Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Your F# example can be more concise:

    type Shape =
        | Circle of float
        | Square of float

    let area = function 
        | Circle r -> Math.PI * r * r
        | Square sd -> sd * sd

    let perimeter = function 
        | Circle r -> 2.0 * Math.PI * r
        | Square sd -> sd * 4.0


Well, that's just... neat.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: