add fsharp samples

pull/190/head
jkone27 4 months ago
parent aca8ca5f54
commit 4aac1852a4

@ -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

@ -0,0 +1,3 @@
// hello world
printfn "Hello World!"

@ -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

@ -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()

@ -0,0 +1,4 @@
// reference a nuget package in interactive mode! and open its declaring namespace
#r "nuget: FSharp.Data"
open FSharp.Data
Loading…
Cancel
Save