Learn to Code via Tutorials on Repl.it!

← Back to all posts
Basic F#

I searched in replit's Tutorials page for the F# but there weren't any Tutorial.
So I present you the basic of F#.

What is F# ?

F# is a functional-first, general purpose, strongly typed, multi-paradigm programming language that encompasses functional, imperative, and object-oriented programming methods. F# is most often used as a cross-platform Common Language Infrastructure (CLI) language on .NET Core, but it can also generate JavaScript and graphics processing unit (GPU) code.
Copied form Wikipedia

Basic of the Basic The Hello World program

You can use:

  • printf
  • System.Console.WriteLine()
    to print string in console.

For the first example I will use printf

!Remember the printf doesn't use () like C !

The output will be Hello World.

For the next example I will use System.Console.WriteLine().

The output will be Hello World. Same with the first one.


The line comment is same as JS and Java like this:

But the block comment is not same!

The comments go inside (* and *)!


F# use let keyword to define variables.

That is a variable named one and containing the integer 1.


For defining functions F# use let keyword too.

That is the basic printing function.
!Remember defining functions in F# doesn't need () for parameters and {} for the function code block!


A list is an immutable collection of elements of the same type in F#. F# use let keyword to define lists. The list indexing start from 0 like other languages.

!Remember F# use ; in lists between elements instead of , !


Arrays are fixed-size, zero-based, mutable collections of consecutive data elements in F#. F# use let keyword to define arrays.

!Remember F# use ; in arrays between elements instead of , ! And F# use [| at the start of an array and |] at the end of an array! If you don't put | beside [ and ] than it will be list!

More about printing

You would think "Hom, I will use printf instead of System.Console.WriteLine() because the printf is shorter!"
Yeah I decided like that when I started learning F#. But the printf is weaker than System.Console.WriteLine().

Here I will show you why.

You can see that I can't print a list using printf.

But with System.Console.WriteLine()

You can see that the program perfectly run.
And next one that difference between the printf and System.Console.WriteLine(). Just look at the end of the program! ^<^

Learning More About F# .

Cheat Sheet

fsharp-cheatsheet-HTML form
fssharp-cheatsheet-PDf form If you click the link, it will automatically download the pdf file!

F# docs

Learning F#

F# version 3.0
Posted on Jan-2021

Thank you for reading!


TYSM this will be very helpful!


@programmeruser @Bookie0 I have edit my tutorial. I saw a difference between printf and System.Console.WriteLine() when I was writing Basic F# program. Check it out!


F# looks like a interesting .NET based functional language. I'll try it later.


@programmeruser Yeah F# is an interesting and easy language! But not easier than Python!


Pretty nice! What about including some extra things in the tutorial like some small program as examples? :)


@Bookie0 Thank you. I will add! :)


cool! :D @AndrewAung11