summaryrefslogtreecommitdiffhomepage
path: root/fsharp.html.markdown
diff options
context:
space:
mode:
authorBoris Verkhovskiy <boris.verk@gmail.com>2024-04-03 04:31:13 -0700
committerGitHub <noreply@github.com>2024-04-03 04:31:13 -0700
commitfbf132752b743d0f43c3395da0699bee53da22df (patch)
tree56da43c86e1aebd24e3913b405e21d6f2812e9a3 /fsharp.html.markdown
parent247dc6e86c1421fa031e4b61c42c05ca6e09bfb0 (diff)
parentc166f2acb295627c5ae305a6dd517a27ca8fece6 (diff)
Merge branch 'master' into patch-1
Diffstat (limited to 'fsharp.html.markdown')
-rw-r--r--fsharp.html.markdown15
1 files changed, 15 insertions, 0 deletions
diff --git a/fsharp.html.markdown b/fsharp.html.markdown
index c140d6b1..f1f8e95d 100644
--- a/fsharp.html.markdown
+++ b/fsharp.html.markdown
@@ -33,6 +33,21 @@ let myInt = 5
let myFloat = 3.14
let myString = "hello" // note that no types needed
+// Mutable variables
+let mutable a=3
+a <- 4 // a is now 4.
+
+// Somewhat mutable variables
+// Reference cells are storage locations that enable you to create mutable values with reference semantics.
+// See https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/reference-cells
+let xRef = ref 10
+printfn "%d" xRef.Value // 10
+xRef.Value <- 11
+printfn "%d" xRef.Value // 11
+
+let a=[ref 0; ref 1] // somewhat mutable list
+a[0].Value <- 2
+
// ------ Lists ------
let twoToFive = [2; 3; 4; 5] // Square brackets create a list with
// semicolon delimiters.