Answered step by step
Verified Expert Solution
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!
- let testA = 2
- let testB x = 2 + x
- let testC x = 2.0 + x
- let testD = "hello"
- let testE = printfn "hello"
- let testF () = 42
- let testG () = printfn "hello"
- let testH x = String.length x
- let testI x = sprintf "%i" x
- let testJ x = printfn "%i" x
- let testK x = printfn "x is %f" x x // return x
- let testL (f:int -> string) x = f x
- let testM f (x:int) :string = f x
- let testN x :string = x 1 // hint: what does :string modify?
- let testO x = 1
- let testP x = x 1 // hint: what kind of thing is x?
- let testQ x y = x
- let testR x y z = z
- let testS x = x=x
- let testT f = (f 1) + 2
- let testU f = sprintf "%i" (f 1)
- let testV f = f() + 2
- let testW x = fun y -> y * x
- let testX x y = y * x
- let testY = fun x y -> y * x
- let testZ f x = (f 1) + x
- 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started