There doesn't开发者_Python百科 seem to be much online on making sure functions remains pure in F#.
To create an example, is there any way to make printfn/IO pure in F#?
you can google for F# implementations of Haskell's IO monad. Here's a nice example.
Printing to the Console is per definition something that changes state (console state) and do have side-effects (like deleting some of the console buffer).
If you are using somekind of CodeContracts or the like you should consider writing out the function result somewhere else, or using an assertion (Contract.Assume or Contract.Assert(this is used for static assertions)) for easier confirmation that you code works.
精彩评论