if I do not write the last line (printfn "%A" a) the files will not change.
F# sequences are lazy. So to force evaluation, you can execute some operation not returning a sequence. For example, you can call Seq.iter
(have side effects, return ()
), Seq.length
(return an int
which is the length of the sequence) or Seq.toList
(return a list, an eager data structure), etc.
Can some one tells me why do I have to add
file : string
as a return type of the function "addNumber"?
Method and property access don't play nice with F# type inference. The type checker works from left to right, from top to bottom. When you say file.Contains
, it doesn't know which type this should be with Contains
member. Therefore, your type annotation is a good hint to F# type checker.
if I write the COUNT variable right after the line of the
[<Literal>]
definition it gives an error and says that a constant cannot be "mutable"
Quoting from MSDN:
Values that are intended to be constants can be marked with the Literal attribute. This attribute has the effect of causing a value to be compiled as a constant.
A mutable value can change its value at some point in your program; the compiler complains for a good reason. You can simply delete [<Literal>]
attribute.