Connect with us


An Introduction to F# as Microsoft’s / .NET’s Answer to a Functional-First Programming Language




Author profile picture

@samwalpoleSam Walpole

Fullstack .NET and JavaScript web developer. Coding teacher and advocate

Recently I’ve been learning how to write code in F#. For those who haven’t heard of it, F# is Microsoft’s/.NET’s answer to a functional-first programming language.

My motivation was to learn a functional programming language that would make coding for scientific computing and data analysis more expressive, concise, and maintainable, all while fitting seamlessly into the .NET ecosystem that I already know and love. F# fits that bill perfectly.

Why Functional Programming?

For an object oriented programmer, the idea of functional programming can be a little foreign at first. We’re used to applications in which everything is an object and the application works by changing the state of those objects (mutation) over time.

In contrast, functional programs consist of values and functions, and the application works by applying these functions to values in order to produce new values.

This might sound similar to methods in an object oriented style, but there are two key differences:

1. Values cannot be modified (they are said to be immutable). Instead, operations create and return new values.

2. Functions should be pure, meaning that a given input always produces the same output. This is in contrast to a class method, in which some internal state of the class might have an effect on the output of the method.

Let’s have a look at this in a code example, in which we want to raise an employee’s salary by a given factor:

// C# Object Oriented Example
public class Employee
{ public string Name { get; set; } public float Salary { get; set; }
} public class SalaryRaiser
{ public float Factor { get; set; } public void RaiseSalary(Employee employee) { // function not pure - depends on Factor, which isn't a parameter var raise = employee.Salary * Factor; // employee object is mutated directly employee.Salary += raise; }
} var employee = new Employee { Name = "Bob", Salary = 12345.67F };
var raiser = new SalaryRaiser { Factor = 0.05F };
// F# Functional Example
type Employee = { Name: string; Salary: float } let factor = 0.05
let calculateSalary employee factor = // function is pure - factor is now a parameter let raise = employee.Salary * factor // new employee record returned { employee with Salary = employee.Salary + raise } let employee = { Name = "Bob"; Salary = 12345.67 }
let updatedEmployee = calculateSalary employee factor

The key benefits of these functional features (immutability and pure functions) is that they make your code much more maintainable and testable, since you can be sure that values aren’t accidentally being mutated (also known as side-effects) and that a given function will always behave the same for a given input.

Data Types in F#

In F# data types are static and strongly typed, meaning that they are determined at compile time and a given value cannot change it’s type. This will be familiar to C# programmers. However, there are some slight differences that may take some getting used to:

  • F# has a powerful type inference system meaning that you hardly ever have to explicitly state what the type is – it is inferred from context
  • // C#
    public int AddInt(int a, int b)
    { return a + b;
    } var value = AddInt(1, 2)
    // F#
    let addInt x y = x + y let value = addInt 1 2
  • F# expects explicit conversion between types
  • // C#
    public float AddFloat(float a, float b)
    { return a + b;
    } int a = 1;
    int b = 2; var value = AddFloat(a, b); // ints are implicitly converted to floats
    // F#
    let addFloat a:float b:float = a + b // for the purpose of the example, explictly state the a and b must be floats let value = addFloat 1 2 // will throw exception since 1 and 2 are ints // instead
    let a = float 1
    let b = float 2 let value = addFloat a b

Other than this, F# contains all of the primitive data types that you will be used to in C# and many other languages.



Lists in F# are similar to those in C#, except that (because they are immutable) methods like Add/Remove do not exist. Instead, to perform the equivalent operations, new lists must be created from the existing list.

// 1. Declare a list
let list = [1;2;3] // creates a list with the elements 1, 2 and 3 // 2. Declare a list using range syntax
let list = [1..5] // create a list with the element 1, 2, 3, 4, and 5 // 3. Add an element to the start of a list
let list = [1;2;3]
let list2 = 4::list // create a list [4;1;2;3] // 4. Remove elements from the list
let list = [1;2;3]
let list2 = list.[0..1] // returns a list containing the elements between index 0 and 1. Equivalent to removing the index 3


Sequences are similar to lists, except they are lazily evaluated, meaning that the element values are not loaded in to memory until needed. This is useful for dealing with very large sequences. An equivalent very long list has to have all elements stored in memory simulataneously and may even crash your PC!

// large list
// WARNING: may crash your pc
let list = [1..1000000] // create a list containing 1 million elements // large sequence
let sequence = seq {1..1000000}


The collections we have looked at previously must contain data all with the same data type (i.e. a list of ints). A tuple is different in that it contain contain multiple values each with different data types.

// 1. declare a tuple
let myTuple = (1, "hello") // 2. destructure a tuple
let myTuple = (1, "hello")
let (num, str) = myTuple // assigns num the value 1, and str the value "hello"


Records group data into distinct objects, similar to classes. Records can even have method. However, as with most things in F#, records are immutable, so ‘editing’ a record requires you to create a new record from the existing one.

// 1. Declare a record type with a method
type Person = { Name: string; Age: int;
} with member this.IsAdult = this.Age >= 18 // 2. Create a record
// Note that we don't need to tell the compiler that this is a Person record
// It can infer it from the fields we provide
let sam = { Name = "Sam"; Age = 27 } // 3. Create a record based on an existing one
let olderSam = { sam with Age = 28 }

Discriminated Unions

Discriminated unions are a powerful feature in F# and may not be familiar to a lot of programmers – they certainly weren’t to me! Discriminated unions allow values to be one of a number of named cases, each with potentially different types and values. This is probably shown that explained:

// 1. Basic discriminated union
// this declares a Status type, that can have the value Active or Inactive
type Status = Active | Inactive
let myStatus = Status.Active // 2. A more complex example
type Shape = | Rectangle of width:float * length:float // takes a tuple of two floats | Circle of radius:float // takes a float // both have the Shape type
let cir = Circle 5.
let rect = Rectangle(5., 6.)

Pattern Matching

Pattern matching is very common in F# and is a way of controlling the flow of the application based on the match input value. It can be likened to using if..else statements in this manner, and if statements do exist in F#, but pattern matching is far more idiomatic (and hopefully you’ll agree, more powerful).

// 1. Pattern matching a discriminated union
type Status = Active | Inactive // return true if Active, return false if inactive
let isActive status = match status with | Active -> true | Inactive -> false // 2. Pattern matching to handle errors
type Result = | Error of string | Data of int // handle printing data or error cases to the console
let handle result = match result with | Data data -> printfn "My result: %i" data | Error error -> printfn "An error ocurred: %s" error //3. Pattern matching tuple values
let matchPoint point = match point with | (0, 0) -> printfn "This is the origin" | (x, 0) -> printfn "X is %i, while Y is 0" x | (0, y) -> printfn "Y is %i, while X is 0" y | _ -> printfn "Both values are non-zero" // _ is a catch all case

Some Functional Concepts

Currying and Partial Application

A pure function can only have one input and one output, and this is true for functions in F# as well. However, we’ve already seen some functions with apparently multiple parameters. For example:

let addInt x y = x + y addInt 5 6 // evaluates to 11

Well, behind the scenes, F# is actually taking this declaration and splitting it into two separate functions, each with only one parameter. Something along the lines of:

let addInt x = let subFunction y = x + y subFunction let intermediate = addInt 5 // evaluates to a function that adds five to its parameter intermediate 6 // evaluates to 11

This process of taking a multi-parameter function and splitting it into a pipeline of single parameter functions is called currying. This is all well and good, but what is the practical benefit for us? Well one of the interesting consequences is something called partial application.

Going back to our AddInt function in C#. It has two parameters, and you can only ever call it with two parameters. Calling it with one parameter will just lead to a compiler error.

However, if we call our addInt function in F# with just one parameter, something interesting happens. It returns a function that has our first parameter baked in! This is known as partial application, and is a highly useful concept for creating reusable pieces of code.

let addInt x y = x + y let add5 = addInt 5 // partially apply addInt to create a new function that adds 5 to the input add5 6 // evaluates to 11
add5 7 //evaluates to 12


Piping is a special type of operator that allows you to put the parameter to the function before the function. For example:

let addInt x y = x + y
let add5 = 5 |> addInt // pipe 5 into the addInt function

Its use may not seem immediately obvious , but it is highly useful for creating pipelines of functions, in which the output of one function feeds directly into the input of another.

[1; 2; 3] // create a list
|> (fun x -> x + 1) // add 1 to each element of the list
|> List.filter (fun x -> x > 2) // only return elements that have a value greater than 2 (returns [3; 4])

Note that the expressions prefixed by `fun` above are simply lambda expressions (or anonymous functions) as you would see in many other languages.


Composition is the act of joining multiple functions together to create a single new function. This can seem pretty much the same as piping at first glance, but it is subtly different: a pipe has to start with a value and is immediately evaluated to give an output; function composition joins multiple functions together and returns that new function (i.e. nothing is evaluated at this stage).

// Example comparing piping and composition let add5 = (+) 5
let double = (*) 2 // piping
|> add5
|> double // evaluates to 20 // composition
let add5ThenDouble = add5 >> double // compose into a new function add5ThenDouble 5 // evaluates to 20


This has been my brief introduction into F# for Object Oriented Programmers. The topics I have covered are by no means exhaustive, but hopefully it is enough to whet your appetite for F# and functional programming.

For more resources F# For Fun and Profit is an excellent website and will help you dive deeper into the language.

I post mostly about full stack .NET and Vue web development (and soon maybe some more F# content!). To make sure that you don’t miss out on any posts, please follow this blog and subscribe to my newsletter. If you found this post helpful, please like it and share it. You can also find me on Twitter.

Previously published here.


Join Hacker Noon

Create your free account to unlock your custom reading experience.

Checkout PrimeXBT
Trade with the Official CFD Partners of AC Milan
The Easiest Way to Way To Trade Crypto.


What is an Action Refund Review?




You have been defrauded by a fraudulent broker. What are you going to do ? In this Action Refund review, we’ll explain everything to you.

A study by “Scamwatch”, with the help of the ACCC (Australian Competition & Consumer Commission), suggests that so far, in 2020, around 195,848 reports of all types of scams have been submitted, with a loss of approximately $ 150,838,567. This is insane!

A real company called “Action Refund” had the ambition to help victims internationally to recover their stolen capital from various crooks in the foreign exchange market. Their team is made up of knowledgeable service agents who have helped dozens of users and victims of scams across the world. In addition, Action Refund offers a free consultation over the phone with a professional case analyst. We suggest that you contact Action Refund as soon as possible.

When you are in the middle of the process of filing a refund claim with a complicated case, it is very important to have professional assistance on your side. If you’re curious about what the company’s collection service is all about, below is an interview with a fraud victim to understand what Action Refund did with their case:

Can you tell us how it all started? (Action Refund Review)

At the end of 2019, I came across an advertisement in my inbox approving that Bill Gates made a fortune from forex trading, so I thought “I’ll give it a shot” and left some of my details on the site of this company.

They assigned me an account manager named “Gary Silverson”. He was polite and appeared to be an expert, promising the world and more with future profits. He assured me that with his advice, my trading account could be multiplied by 10 in no time. I thought that was probably an overestimate, however, if the forex market is open to everyone it is very possible to increase my income and triple my investments, at least that’s what I got. has sold. I wanted to deposit around $ 750 to open an account so I followed his instructions.

Gary explained to me very briefly about the application they are using, omitting crucial details and saying “trust me, you don’t need this info, we need more repositories”. You could say that I was very naive.

That seems good to me…

Back then, I was making decent profits instantly. We had a few trading sessions together for two months. Over time, he started to take control of my account transactions and I followed his lead, not asking anything because I knew he wouldn’t respond correctly. A few days later, the agent reached out to me via WhatsApp regarding a new opportunity emerging due to the announcement of the US election. Gary offered me a zero risk plan so that we could increase my earnings. I confirmed it, and we did make a little more profit.

At the time, my account was showing a profit of $ 5,129 from my initial deposit. I wanted to request a withdrawal of $ 1000 and it was returned to me without a problem. I remember I was quite surprised. I thought to myself, “How could I not find this forex trading company before?”. A month passed, and I reconsidered depositing an additional $ 15,000. Then I got promoted for what the company calls “platinum membership”.

So you claim that you had no problem withdrawing funds from the trading account?

Not at all. As I mentioned, everything went well at first. Honestly, it looked like Gary was doing a good job.

Continue Reading


Vestle Review 2021 – CySEC Broker Or CySEC Scam?





Description: Can you be scammed by Vestle broker? Read our comprehensive Vestle review covering the most important information about the broker.

Whether you have or plan to have an account with this broker, this Vestle review is something you must read

Regulated by: CySEC
Headquarters Country: Cyprus
Foundation year: 2015
Platforms: Web trader
Instruments: FX, commodities, shares, indicies, crypto, ETFs

Is Vestle a legit broker?

Over the years, many clients had a terrible experience with CySEC regulated brokers. Therefore, we decided to check few things in our Vestle review. 

For a start, is Vestle regulation a real regulation or yet another attempt of a regulated company to have an off-sight brand. How the broker operates, and the odds that it will steal your money. Let’s start.

 Vestle Regulation and Security

Vestle is a brand owned by iCFD Limited, regulated by CySEC. The company was formerly known as iForex Ltd. Whenever the broker changes its name, there is a reason for that. And usually, the reason is hundreds of unsatisfied traders and bad reviews. 

When it comes to funds, allegedly, every payment method the company uses is supervised by another EU country. It seems that the broker just listed all the countries where payment providers are based.

What can you trade with a Vestle broker?

Vestle is a broker that provides a high range of trading assets. Clients can trade with currency pairs, commodities, indices, shares, cryptocurrencies, and ETFs. There are over 900 assets available.

All the trades are executed on the web trader of a broker called FXnet. This type of trading platform is always riskier than trading with MT4 or MT5. Every experienced trader prefers MetaTrader in the first place because of security reasons, but also because it has more features. Unfortunately, the broker does not have a Demo account, so we couldn’t test the web trader and decide if it’s good or bad. Besides the web trader, the broker also offers Vestle mobile, its own app for Android and iOS devices. 

When it comes to leverage, it’s limited by CySEC rules. The highest leverage is 1:30 for currency pairs.



Deposit and Withdrawal Methods

When we talk about funding the account, there are several methods available. The client can deposit using debit/credit card, wire transfer, and few E-wallets. For card deposits, funds are visible instantly, while for wire transfers and E-wallets takes up to 5 business days. The same methods are available for withdrawals; only it takes up to 10 business days for the money to appear on the client’s account.

As per our Vestle review, it seems that the broker has issues with double charging. Many clients of this company complained that they see the double transaction in their bank statement. 

When it comes to the deposit amount, Vestle keeps it hidden. Nowhere on the website, you cannot find the list of account types and deposits necessary. It seems that after you get a call from their support, they will evaluate your financial situation and require a certain amount of money from you.

The same thing can be said about commissions and fees the broker is charging. We were unable to find this list anywhere. This looks bad for the Vestle broker. As a CySEC regulated broker, it should be very transparent when it comes to money.

Conclusion about Vestle

Based on everything in our Vestle review, we can say next. The broker shows a low level of transparency about fees and costs. The trades are executed on the web trader, easy to manipulate and change market prices. Even though the company is in the CySEC register since 2015, on the website of Vestle, there is a claim that they are operating for over 15 years. Now, it opens two questions: were they working unregulated or misleading clients to believe they are joining a long-lasting company. Whatever the answer is, a broker should not be proud to publish it.

After saying all this, we will leave it to you to decide if Vestle is a good broker or yet another CySEC scam.

 Source : Plato

Continue Reading


New method of investment: Copy trading, or copy trading as it was originally called




These are busy days for those who have a certain level of savings in the economy. Because already sharp movements occur in the Turkish lira because of their very high rates of investment to translate the uncertainties in Turkey in recent times with a certain amount of savings. This enables people to turn to different investment methods.

If you are looking for a dynamic investment method and still do not know where to start, we will have a profitable suggestion for you. A type of investment, originally called “Forex copy trading”, and another name that can be translated as copy investment in Turkish is social investment. It can be a good entry-level choice for those who do not know exactly how and how to invest in investment vehicles.

The basic logic of copy trading is to imitate the investments of successful investors in the exchange you want to enter. It’s that simple. Anyway, the name of this investment concept is therefore determined as copy investment.

According to one of the studies conducted in recent years, this type of investment is increasingly taking up a place in the market. The copy investment market will reach an amount of € 70 billion by the end of 2025, according to researches.

To start copy trading, the first thing to do is to choose a reliable and profitable investment platform. At this point, the next step in choosing a reliable investment platform is  Forex Copy Trading

that is, to be able to follow reliable investors for copy investment. Therefore, the choice of platform is very important at this point.

A Close Look at Copy Investment

In short, it is important that copy investment or social investment platforms allow experienced investors to copy their investments directly. Here, when you find such an investment exchange, the investment made in this way is also called “auto investment” because you invest your own account directly into the account of the experienced investor.

You can invest in the form of copy investment in the BIST 100, crypto money exchanges and even foreign exchanges. It is a method that can be followed even for foreign currency deposits. However, it will require serious research at the stage of determining the investors you will follow in the first place.

How Exactly to Invest in Copy?

In fact, there are two popular ways to do this.

Following the Investors’ Strategies One to One

Whichever exchange you are investing in, you can learn the investments made by the really experienced names of that stock exchange with a good research and make these investments one by one.


Simple System: The investment you will make in this way will be a very simple and easy-to-use investment type. This is the reason why it is called auto investment as a type of investment that you can directly imitate the investments of expert investors in the field.

Flexibility: You can follow this type of investment from any digital device. It is a very flexible method as you will do the same no matter where you are, as soon as you hear about the direct investment of the person you follow, as there is no subject to think about.

Choosing a strategy is very easy: All you have to do is find the best in the field with the right research. Once you find it, it will be very easy to determine your strategy.

Transaction Fees: Most successful traders will charge you a certain fee to return their investments. These fee claims create an additional cost. However, you can manage your funds with the confidence that there will be no additional fees or expenses for the investment.

Let others follow your investment. For this, create an investment strategy.

Here you will be the one followed. Of course, this has certain advantages and disadvantages.

Your strategies will directly affect the market: Since you will be the person who will determine the strategy, whatever strategy you follow, the strategy you will follow will be a strategy that will affect the market completely.

You will also get the reward for your labor outside of profits: In this way, you will have to spend all your work on this work. However, you will get more than your followers for your efforts.

You will set the rules of the game: However, doing these operations will require both very serious experience and serious work.

Of course, it would be useful for you to carefully investigate whether there is a method to follow completely. However, it is possible to say that you can carry out such transactions with peace of mind with detailed analysis on the leading quality investment and stock exchange platforms such as AMarkets.



Continue Reading


Ethereum Price Smashed $2000, $3000 Incoming At Lightning Speed!




Ethereum Price (ETH) May Hit $10,000 This Cycle!

The Ethereum price that is known to maintain a stable price movement, finally broke the previous ATH to form a new one. It took more than a months time to regain its lost position above $2000, yet sustained successfully. 

Advertisement header-banner-ad

The price took more time than expected to break the $2000 barrier, yet $3000 may be approaching at rocket speed. As predicted by founder of Gokhstein Media, David Gokhstein, the next stop for the ETH price is around $3,900. 

With the continued bullish trend and intensified rally, the price is expected to surge to the highest levels. According to an analyst and Crypto Youtuber, Young and Investing, the Ethereum price may hit $10,000 within the current bull run.

With the accelerated bull run, many analysts believe Ethereum could lead the market instead of Bitcoin too. Therefore providing a huge opportunity for the altcoins to boom within the ETH bull rally. 

Is Altcoin-Season On the Cards?

Many altcoins normally pop-up with the surge in the price of the second dominant crypto Ethereum. Currently, ETH price is trading around its new all time high around $2152 and expected to fly high. Therefore, many small cap altcoins are expected to rise from ashes and pump more than 50x or even 100x also.

Many analysts believe the Altcoin Season of 2021 is on the way and is expected to be the greatest season ever. According to a popular analyst, XRPcryptowolf, the season will reach its peak during the summer.

Moreover, the coins which are believed to be dead or not performing are also expected to rise. One of the analysts, MC also has given a brief idea on which all coins might pump in the current AltSeason.

Collectively, the breakout of Ethereum price has led to initialization of the most awaited AltSeason of 2021. The ETH price rally is expected to intensify in the coming days, that might smash $10,000 soon.

Checkout PrimeXBT
Trade with the Official CFD Partners of AC Milan

Continue Reading
Esports4 days ago

Free Fire World Series APK Download for Android

Esports2 days ago

C9 White Keiti Blackmail Scandal Explains Sudden Dismissal

Esports2 days ago

Overwatch League 2021 Day 1 Recap

Esports4 days ago

Dota 2: Top Mid Heroes of Patch 7.29

Esports2 days ago

Fortnite: Epic Vaults Rocket Launchers, Cuddlefish & Explosive Bows From Competitive

Esports5 days ago

Position 5 Faceless Void is making waves in North American Dota 2 pubs after patch 7.29

Esports3 days ago

Don’t Miss Out on the Rogue Energy x Esports Talk Giveaway!

Esports5 days ago

Fortnite Leak Teases Aloy Skin From Horizon Zero Dawn

Esports4 days ago

Capcom Reveals Ransomware Hack Came from Old VPN

Esports5 days ago

League of Legends’ Patch 11.8 introduces Gwen, champion updates and new Skins

Esports3 days ago

Fortnite: DreamHack Cash Cup Extra Europe & NA East Results

Esports2 days ago

Gamers Club and Riot Games Organize Women’s Valorant Circuit in Latin America

Blockchain5 days ago

COPA verklagt Craig Wright wegen Bitcoin-Copyright

Esports5 days ago

shroud explains why bottom fragging in Valorant is no big deal

Fintech5 days ago

Software-based facial recognition in payments industry to dominate by 2025

Esports4 days ago

PSA: CSGO Fans Beware, Unfixed Steam Invite Hack Could Take Over Your PC.

Blockchain3 days ago

CoinSmart Appoints Joe Tosti as Chief Compliance Officer

Fintech4 days ago

FinSS and Salt Edge partner for CDR Compliance solution in Australia

Esports5 days ago

FunPlus Phoenix Set to Face RNG in the 2021 LPL Spring Split Finals!

Esports5 days ago

Ludwig breaks Ninja’s Twitch sub record