Question: F# Programming: Type Inference Q1. For each of the following definitions, say whether it is a simple value or a function, and if a function,

F# Programming: Type Inference

Q1. For each of the following definitions, say whether it is a simple value or a function, and if a function, what is the function signature? If in doubt, run them in the F# Interactive Tool to find out!

  1. let testA = 2
  2. let testB x = 2 + x
  3. let testC x = 2.0 + x
  4. let testD = "hello"
  5. let testE = printfn "hello"
  6. let testF () = 42
  7. let testG () = printfn "hello"
  8. let testH x = String.length x
  9. let testI x = sprintf "%i" x
  10. let testJ x = printfn "%i" x
  11. let testK x = printfn "x is %f" x x // return x
  12. let testL (f:int -> string) x = f x
  13. let testM f (x:int) :string = f x
  14. let testN x :string = x 1 // hint: what does :string modify?
  15. let testO x = 1
  16. let testP x = x 1 // hint: what kind of thing is x?
  17. let testQ x y = x
  18. let testR x y z = z
  19. let testS x = x=x
  20. let testT f = (f 1) + 2
  21. let testU f = sprintf "%i" (f 1)
  22. let testV f = f() + 2
  23. let testW x = fun y -> y * x
  24. let testX x y = y * x
  25. let testY = fun x y -> y * x
  26. let testZ f x = (f 1) + x
  27. let testZZZ f g x = g (f x) // apply f to x, then apply g to the result

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!