Home / Interview / F# :: General Questions

Interview :: F#

1) What is F#?

F# is a Computer programming language. It was designed and developed by Microsoft. It supports functional, object-oriented and imperative programming approaches. You can create an application by using this programming language.

2) What are the features of F#?

F# has many features. Following are the main features of F#:

  • Type inference
  • Type extension
  • Less code
  • Immutable data
  • Pattern matching
  • Assertion
  • Lambda expression
  • Function composition and pipelining
  • Object expression
  • Lazy computation and many more
3) What are the available data types in F#?

F# provides a rich set of data types. It helps to deal with any data whether it is scientific data, data of business analysis, etc. You can see the table of data types here.

Data Types in F#

Types Data Types
Primitive data types char, byte, bool, int, float
Derived data types class, array, list, records, sequence
Enumeration enum
Unit type It is used if other data types are not specified.
4) What is the unit type in F#?

The unit type is a type which indicates the absence of specific value. The unit type has only a single value. This value acts as a placeholder when no other value exist.

Example:

5) What is upcasting and downcasting in F#?

Casting is a process of converting one type to another type. F# provides mainly two operators to deal with upcasting and downcasting. The :> operator is used to upcast object and :?> operator is used to downcast object.

Example:

6) What are available operators in F#?

An operator is simply a symbol that is used to perform operations. There can be many types of operations like arithmetic, bitwise, logical, etc.

There are following types of operators to perform different types of operations in F# language.

  • Arithmetic operators: The Arithmetic operators take numerical values as their operands and return a single numerical value.
  • Boolean operators: The Boolean operators are used to check conditional expressions. It returns true if expression satisfies the condition otherwise it returns false.
  • Bitwise operators: In F#, the bitwise operator works on individual bits and return a result after evaluation.
  • Nullable operators: The Nullable operators are used to work with database queries. It handles null values which are stored in tables in place of data.
7) Which tokens are available in F#?
  • Keywords: It contains the links to information about all F# language keywords.
  • Symbol and operators: It contains a table of symbols and operators that are used in the F# language.
8) What is function composition and pipelining in F#?

In F#, functions can be composed from other functions. It is a process of composing in which a function represents the application of two composed functions. F# function pipelining allows us to call functions in the chain. Pipelining operator takes a function and an argument as operands and returns a value.

F# Function Composition Example

F# Function Pipelining Example

9) What is lambda expression in F#?

Lambda expression is an unnamed or anonymous function. Sometimes instead of defining a full name function, you may create a lambda expression. It optimizes the code. You must use a fun keyword to define lambda expression.

Example

10) What is an inline function in F#?

The F# inline function is a function that is integrated directly into the calling code. It helps to optimize code and sometimes can improve performance too.

Example