0

I am reading the Foundations of F# by Robert pickering. When I try to run the first example in the book (below) I am getting a runtime error at function print, "Unable to parse format string 'Missing format specifier'"

#mytestapp
let message = "Hello
    World\r\n\t!"
let dir = @"c:\projects"

let bytes = "bytesbytesbytes"B

let xA = 0xFFy
let xB = 0o7777un
let xC = 0b10010UL
let print x = printfn "A%" x
let main() =
    print message;
    print dir;
    print bytes;
    print xA;
    print xB;
    print xC
main()

The output should be (according to the book):

"Hello\n        World\r\n\t!"
"c:\projects"
[|98uy; 121uy; 116uy; 101uy; 115uy; 98uy; 121uy; 116uy; 101uy; 115uy; 98uy;
  121uy; 116uy; 101uy; 115uy|] -1y
4095
18UL

I think, that maybe I don't have something referenced that I should?

Peter
  • 47,963
  • 46
  • 132
  • 181
Andrew
  • 3,524
  • 5
  • 35
  • 50
  • I have edited printmessage to print message. That is not the error is it? – Peter Dec 11 '09 at 15:25
  • I think you might want to look at this thread; http://stackoverflow.com/questions/791706/in-f-how-do-i-customize-output-of-a-custom-type-using-printf – nlucaroni Dec 11 '09 at 15:35
  • yeah print message was a typo, A% was not that's how it is in the book and it fixed it. thank you Mauricio. – Andrew Dec 11 '09 at 15:36

1 Answers1

5

You want your format string to be "%A", not "A%". The format specifier comes after the % sign. There's nothing after your % sign -- hence, Missing format specifier

Dathan
  • 7,266
  • 3
  • 27
  • 46