Home Ask Login Register

Developers Planet

Your answer is one click away!

Rvfvl January 2017

F# entry point taking integers as parameters

I have simple problem with using entry points in F#. How can I take integers as a entry point parameters. So far it only works with strings, but I am trying to define entry point which will take 2 integers and perform algorithm and then print the results in the console.

open System

let rec Algorithm x y =
    if y = 0 then x
    else Algorithm y (x % y)

Algorithm 270 192 |> ignore;;

let main args = 
    Console.WriteLine("Result is: {0}",(Algorithm args.[0] args.[1]))
    Console.ReadKey() |> ignore
    0 // return an integer exit code

I can't run it because I am receiving error message for args.[0] and args.[1].

This expression was expected to have type int but here has type string.


Mark Pattison January 2017

The arguments can only be strings. You can convert them to ints yourself, of course.

The entry point function has type string array -> int

Post Status

Asked in January 2017
Viewed 3,776 times
Voted 11
Answered 1 times


Leave an answer

Quote of the day: live life