TheSharperDev

Educating about C# and F#

Absolute max value function - F#

I’m starting to use talonvoice to program.

To get started, I’m copying the following function

let absoluteMax (x: int list) =
    let mutable j = x.[0]

    for i in x do 
        if abs i > abs j then j <- i

    j

[<EntryPoint>]
let main argv =    
    let numbers = [1;2;3;10;100;55;20;-20]
    let max = absoluteMax numbers
    printfn "%d" max
    0