Home / Interview / F# :: General Questions

Interview :: F#

11) What is let bindings in F#?

Binding is a process of associating of identifier or function to a value. Let keyword is used to bind an identifier to a value. In F#, We use let keyword to declare variable, function and private class members.

F# Let binding in function

We use let keyword to define a function in F#.

12)

What is "do bindings" in F#?

Do binding is used to execute code without defining a function or any type. You can write independent code by using do binding in F#.

EXAMPLE 

13)

What is type annotation in F#?

F# allows type annotation so that you can explicitly mention the type of identifier or parameter or return type of a function. You must use: (colon) to apply annotation in F#.

EXAMPLE 

14)

What is Type Inference in F#?

Type inference means when you are writing code then you don't need to specify the type of values or variables. F# compiler is strong enough to infer the type of value.

EXAMPLE

15) What is Automatic Generalization in F#?

When code does not specify any type explicitly, then the compiler considers generic type. It is called an automatic generalization. It helps to write generic code without increasing complexity.

16) What are the Tuples in F#?

In F#, tuples are a collection of anonymous values. Values may be the same or different types. It allows us to put expression as a value also.

Example

17) Can a function return multiple values in F#?

Yes, by using a tuple, you can return multiple values in a function.

Example

18) What is a list in F#?

It is an immutable collection of same type elements. It maintains the order of elements.

F# List Example

19) What is Array in F#?

Arrays are mutable collections of data of the same type. It starts from index 0 and goes to n-1 where n is the length of arrays.

Example

20)

What is Sequence in F#?

The Sequence is a series of the same type of elements. It provides better performance than list.

Example

You can create sequence expression like following. Here, we have used Seq.iter () function to iterate sequence. We can also use for loop or array format specifier to iterate sequence elements.