Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

0130913677, 978-0130913678

More Books

Students also viewed these Databases questions

Question

Solve the proportion. 3 2p + 5 || 1 9

Answered: 1 week ago

Question

=+19.4. Consider weak convergence in LP((0, 1], @, ).

Answered: 1 week ago

Question

10. Describe the relationship between communication and power.

Answered: 1 week ago