7
votes

I'm very new to F# so please excuse the completely newbie question:

I have a sequence stored in a variable called prices. I'd like to output the contents of this sequence to the interactive window. What's the easiest command to do this?

Here is my sequence:

> prices;;
val it : seq<System.DateTime * float> = seq []

I've tried printf'ing it but that gives me the error:

> printf("%A", prices);;

  printf("%A", prices);;
  -------^^^^^^^^^^^^

stdin(82,8): error FS0001: The type ''b * 'c' is not compatible with the type 'Printf.TextWriterFormat<'a>'

Any help would be appreciated.

3

3 Answers

16
votes

printf does not take parentheses:

printfn "%A" prices;;

(See F# function types: fun with tuples and currying for details)

You might also convert the seq to a list, e.g.

printfn "%A" (Seq.toList prices);;
3
votes

Also, you can control interactive session printer capabilities by changing fsi.* properties (FloatingPointFormat, PrintWidth, PrintDepth, PrintLength, ...) F.e. please see: http://cs.hubfs.net/forums/post/7438.aspx

2
votes
> prices;;
val it : seq<System.DateTime * float> = seq []

It's doing its job: seq [] means the sequence is empty.