views:

95

answers:

1

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?

+3  A: 

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