hubFS: THE place for F#

. . . are you on The Hub?
Welcome to hubFS: THE place for F# Sign in | Join | Help
in Search

Error while compiling simple code.Newbie question

Last post 07-01-2008, 4:36 by Anuviswan. 2 replies.
Sort Posts: Previous Next
  •  06-29-2008, 6:28 6240

    Error while compiling simple code.Newbie question

    Hi

    I am a newbie with F# and has been creating a function which calculates power of n for any integer. I wanted to result to hold very large values like 5^5000.

    I created following function  for the same


    open Microsoft.FSharp.Math.BigInt

    let rec Power (x:bigint) (y:bigint)   =  if y=of_int 1 then x else  x* Power of_int x of_int y-1

    However, when compiled i am getting following error.

    Error    1    This value is not a function and cannot be applied  
    Error    2    This value is not a function and cannot be applied  

    I have "bolded" the place where the error is  being shown.

    If i put a braces around the arguements of power, i am getting following error.
    Error    1    Expecting a type supporting the operator '*' but given a function type. Are you missing an argument to a function?   


    Can any one please guide me ?? Also can anyone please tell how i can accept parameters as int and return as bigint ??

    Thanks n Regards
    Anu Viswan

  •  06-30-2008, 8:46 6249 in reply to 6240

    Re: Error while compiling simple code.Newbie question

    Perhaps you need to write something like that
      let rec Power (x:bigint) (y:bigint)   =  if y=of_int 1 then x else  x* Power (x) (y-of_int 1)
    and use it as
       Power (of_int 120) (of_int 10)

    B.R.
    Pavel
  •  07-01-2008, 4:36 6255 in reply to 6249

    Re: Error while compiling simple code.Newbie question

    Thanks Pavel.
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems