Skip to content
This repository was archived by the owner on Nov 5, 2024. It is now read-only.

Commit 5744277

Browse files
authored
Added variables
1 parent 706d728 commit 5744277

File tree

4 files changed

+48
-3
lines changed

4 files changed

+48
-3
lines changed

src/css/main.css

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ code {
7373
.multiCode p {
7474
margin: 0;
7575
align-self: flex-start;
76-
color: #D63384
76+
color: #D63384;
77+
font-family: monospace;
7778
}
7879

7980
code {
@@ -93,6 +94,7 @@ code {
9394
code p {
9495
margin: 0;
9596
align-self: flex-start;
97+
font-family: monospace;
9698
}
9799

98100
samp {
@@ -108,3 +110,9 @@ samp {
108110
flex-direction: column;
109111
margin: 0;
110112
}
113+
114+
.highlight {
115+
color: rgb(61, 61, 61);
116+
font-size: 12px;
117+
118+
}

src/getting-started.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
<li><a href="getting-started.html#pint-first-time">Running pint for the first time</a></li>
2828
<li><a href="getting-started.html#first-program">Your very first P program!</a></li>
2929
</ul>
30+
<li><a href="variables.html">Variables</a></li>
31+
<li><a href="functions.html">Function</a></li>
3032
</ul>
3133
</div>
3234
<div class="page-content">

src/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<li><a href="getting-started.html#first-program">Your very first P program!</a></li>
4141
</ul>
4242
<li><a href="variables.html">Variables</a></li>
43-
<li><a href="functions.html">Function/a></li>
43+
<li><a href="functions.html">Function</a></li>
4444
</ul>
4545
</div>
4646
<div class="page-content">

src/variables.html

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,56 @@
2020
alt="P Icon"
2121
/></a>
2222
<ul>
23-
<li><a class="current" href="index.html">Introduction</a></li>
23+
<li><a href="index.html">Introduction</a></li>
2424
<li><a href="getting-started.html">Getting Started</a></li>
2525
<ul>
2626
<li><a href="getting-started.html#installing">Installing</a></li>
2727
<li><a href="getting-started.html#pint-first-time">Running pint for the first time</a></li>
2828
<li><a href="getting-started.html#first-program">Your very first P program!</a></li>
2929
</ul>
3030
<li><a class="current" href="variables.html">Variables</a></li>
31+
<ul>
32+
<li><a href="variables.html#defining-variables">Defining Variables</a></li>
33+
</ul>
3134
<li><a href="functions.html">Function</a></li>
3235
</ul>
3336
</div>
3437
<div class="page-content">
3538
<h1 class="page-title">Variables</h1>
39+
<p>Simple introduction to understanding how variables work and how you define them and how you use them</p>
40+
<h2 id="defining-variables">Defining Variables</h2>
41+
<p>You can define a variable like this:</p>
42+
<code>*mut type name = value</code>
43+
<p class="highlight">(* = optional)</p>
44+
<p><strong><i>type</i></strong> can be any of these: <strong>string, int, float, bool</strong> but also custom types (more on them <a href="custom-types.html">here</a>)<br><strong><i>name</i></strong> can be any letters, numbers but not any "-" or " " in them<br><strong><i>mut</i></strong> is used to say if the variable is modifiable, basically saying if you can change the value or not. To make a variable editable you do: <code>mut type name = value</code> if not its just <code>type name = value</code></p>
45+
<p>An example of defining a variable called name with the value "Kevin":<code>string name = "Kevin"</code></p>
46+
<br>
47+
<h2 id="using-variables">Using Variables</h2>
48+
<p>To use a variable you can simple just call its name, example:
49+
<pre class="multiCode">
50+
use writeln from @std.io
51+
52+
string name = "Kevin"
53+
writeln(name)</pre>
54+
<br>
55+
Output:
56+
<samp>Kevin</samp>
57+
</p>
58+
<p>To define a editable variable you can do: <pre class="multiCode">
59+
use writeln from @std.io
3660

61+
mut age = 18
62+
writeln("I am %{age}")
63+
++age
64+
writeln("I am %{age}")
65+
</pre>
66+
<br>
67+
Output:
68+
<samp>I am 18
69+
I am 19</samp>
70+
</p>
3771
</div>
3872
</div>
73+
<footer class="webfooter">&copy; Plang 2023</footer>
3974
</body>
4075
</html>

0 commit comments

Comments
 (0)