Debian Codegraph @

examples/prism-fsharp.html

raw symbols SCIP
1 <h2>Comments</h2>
2 <pre><code>// Single line comment
3 (* Multi-line
4 comment *)</code></pre>
5
6 <h2>Strings</h2>
7 <pre><code>"foo \"bar\" baz"
8 @"Verbatim strings"
9 """Alternate "verbatim" strings"""
10 </code></pre>
11
12 <h2>Numbers</h2>
13 <pre><code>//8 bit Int
14 86y
15 0b00000101y
16 //Unsigned 8 bit Int
17 86uy
18 0b00000101uy
19 //16 bit Int
20 86s
21 //Unsigned 16 bit Int
22 86us
23 //Int
24 86
25 86l
26 0b10000
27 0x2A6
28 //Unsigned Int
29 86u
30 86ul
31 //unativeint
32 0x00002D3Fun
33 //Long
34 86L
35 //Unsigned Long
36 86UL
37 //Float
38 4.14F
39 4.14f
40 4.f
41 4.F
42 0x0000000000000000lf
43 //Double
44 4.14
45 2.3E+32
46 2.3e+32
47 2.3e-32
48 2.3e32
49 0x0000000000000000LF
50 //BigInt
51 9999999999999999999999999999I
52 //Decimal
53 0.7833M
54 0.7833m
55 3.m
56 3.M
57 </code></pre>
58
59 <h2>Full example</h2>
60 <pre><code>// The declaration creates a constructor that takes two values, name and age.
61 type Person(name:string, age:int) =
62 // A Person object's age can be changed. The mutable keyword in the
63 // declaration makes that possible.
64 let mutable internalAge = age
65
66 // Declare a second constructor that takes only one argument, a name.
67 // This constructor calls the constructor that requires two arguments,
68 // sending 0 as the value for age.
69 new(name:string) = Person(name, 0)
70
71 // A read-only property.
72 member this.Name = name
73 // A read/write property.
74 member this.Age
75 with get() = internalAge
76 and set(value) = internalAge &lt;- value
77
78 // Instance methods.
79 // Increment the person's age.
80 member this.HasABirthday () = internalAge &lt;- internalAge + 1
81
82 // Check current age against some threshold.
83 member this.IsOfAge targetAge = internalAge &gt;= targetAge
84
85 // Display the person's name and age.
86 override this.ToString () =
87 "Name: " + name + "\n" + "Age: " + (string)internalAge
88 </code></pre>