diff --git a/sheets/_fsharp/function b/sheets/_fsharp/function new file mode 100644 index 0000000..2747b7e --- /dev/null +++ b/sheets/_fsharp/function @@ -0,0 +1,8 @@ +// simple function + +// functions in F# are created with `let` keyword as functions are just regular bindings + +// sum two values a and b +let myFunction a b = + // the last value in scope is returned + a + b \ No newline at end of file diff --git a/sheets/_fsharp/hello b/sheets/_fsharp/hello new file mode 100644 index 0000000..efbd601 --- /dev/null +++ b/sheets/_fsharp/hello @@ -0,0 +1,3 @@ +// hello world + +printfn "Hello World!" \ No newline at end of file diff --git a/sheets/_fsharp/module b/sheets/_fsharp/module new file mode 100644 index 0000000..d3048a6 --- /dev/null +++ b/sheets/_fsharp/module @@ -0,0 +1,15 @@ +// in F# module help you to organize your code, like in python or js, a bit like static classes in C# or Java + +module MyModule = + + // bindings in modules are by default public + let SOME_CONST = 5 + + // same for function bindings + let someFun a = + a + SOME_CONST + + + +// you can access your module somewhere else in your code as such +let result = MyModule.someFun 3 \ No newline at end of file diff --git a/sheets/_fsharp/open b/sheets/_fsharp/open new file mode 100644 index 0000000..81ef20f --- /dev/null +++ b/sheets/_fsharp/open @@ -0,0 +1,7 @@ +// you can open namespaces with the open keyword +// a bit like importing packages in other languages +open System + + +// for example, now wait for a key press and read it, from the System package, Console `module` or static class +let k = Console.ReadKey() \ No newline at end of file diff --git a/sheets/_fsharp/rnuget b/sheets/_fsharp/rnuget new file mode 100644 index 0000000..e6e698e --- /dev/null +++ b/sheets/_fsharp/rnuget @@ -0,0 +1,4 @@ +// reference a nuget package in interactive mode! and open its declaring namespace + +#r "nuget: FSharp.Data" +open FSharp.Data \ No newline at end of file