I searched in repl'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
printf "Hello World"
!Remember theprintfdoesn't use()like C !
The output will be Hello World.
For the next example I will use System.Console.WriteLine().
System.Console.WriteLine("Hello World")
The output will be Hello World. Same with the first one.
Comments
The line comment is same as JS and Java like this:
//This is line comment
But the block comment is not same!
(*
The first line of block comment
The second line of the block comment
*)
The comments go inside (* and *)!
Variables
F# use let keyword to define variables.
let one = 1
That is a variable named one and containing the integer 1.
Functions
For defining functions F# use let keyword too.
let say str =
printf str
say "Hello"
That is the basic printing function. !Remember defining functions in F# doesn't need()for parameters and{}for the function code block!
Lists
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.
let aToc = ["a"; "b"; "c"]
!Remember F# use;in lists between elements instead of,!
Arrays
Arrays are fixed-size, zero-based, mutable collections of consecutive data elements in F#. F# use let keyword to define arrays.
let aTod = [|"a"; "b"; "c"; "d"|]
!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 theprintfis weaker thanSystem.Console.WriteLine().
Here I will show you why. You can see that I can't print a list usingprintf.
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! ^<^
Basic F#
I searched in repl'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.Comments
The line comment is same as JS and Java like this:
But the block comment is not same!
The comments go inside
(*
and*)
!Variables
F# use
let
keyword to define variables.That is a variable named
one
and containing the integer1
.Functions
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!Lists
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 from0
like other languages.!Remember F# use
;
in lists between elements instead of,
!Arrays
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 ofSystem.Console.WriteLine()
because theprintf
is shorter!"Yeah I decided like that when I started learning F#. But the
printf
is weaker thanSystem.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
andSystem.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!
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