Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
D7050E_2020
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Söderberg
D7050E_2020
Commits
d8385e3a
Commit
d8385e3a
authored
Nov 18, 2020
by
David Söderberg
Browse files
Options
Downloads
Patches
Plain Diff
Update HOME_EXAM.md
parent
6cb8d388
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
HOME_EXAM.md
+21
-11
21 additions, 11 deletions
HOME_EXAM.md
with
21 additions
and
11 deletions
HOME_EXAM.md
+
21
−
11
View file @
d8385e3a
...
@@ -199,6 +199,9 @@ Showcase of EBNF:
...
@@ -199,6 +199,9 @@ Showcase of EBNF:
if
(
c
>
0
)
{
if
(
c
>
0
)
{
true
true
}
}
else
{
false
}
}
}
fn
main
()
{
fn
main
()
{
...
@@ -374,7 +377,7 @@ let a = 2;
...
@@ -374,7 +377,7 @@ let a = 2;
### Assign expression
### Assign expression
```
math
```
math
\frac{<e, σ> → n}{<
mv =
e,σ> → σ'[mv=n]}
\frac{<e, σ> → n}{<e,
σ> → σ'[mv=n]}
```
```
Where the expression also can be a boolean or function.
Where the expression also can be a boolean or function.
...
@@ -408,7 +411,7 @@ else {
...
@@ -408,7 +411,7 @@ else {
```
```
```
rust
```
rust
let
a
=
0
;
let
mut
a
=
0
;
while
a
<
10
{
while
a
<
10
{
// something that should loop 10 times
// something that should loop 10 times
a
=
a
+
1
;
a
=
a
+
1
;
...
@@ -435,6 +438,9 @@ fn func(x:i32, y:i32) -> i32 {
...
@@ -435,6 +438,9 @@ fn func(x:i32, y:i32) -> i32 {
if
(
c
>
0
)
{
if
(
c
>
0
)
{
true
true
}
}
else
{
false
}
}
}
fn
main
()
{
fn
main
()
{
...
@@ -454,6 +460,7 @@ fn func(x:i32, y:i32) -> i32 {
...
@@ -454,6 +460,7 @@ fn func(x:i32, y:i32) -> i32 {
-
→, evaluates
-
→, evaluates
-
c, command
-
c, command
-
v, variable
-
v, variable
-
mv, mutable variable
-
e, expression
-
e, expression
-
t, type
-
t, type
...
@@ -518,7 +525,7 @@ false < 2; // Type missmatch
...
@@ -518,7 +525,7 @@ false < 2; // Type missmatch
```
```
```
math
```
math
\frac{<e,σ> → \&text{mut } t}{<*e,σ> → \text{mut} t}
\frac{<e,σ> → \&
\
text{mut } t}{<*e,σ> → \text{mut} t}
```
```
```
math
```
math
...
@@ -537,20 +544,23 @@ let d:bool = *b; // <-- Type missmatch
...
@@ -537,20 +544,23 @@ let d:bool = *b; // <-- Type missmatch
\frac{<f(e), σ> → t}{<f, σ> → \text{ret } t}
\frac{<f(e), σ> → t}{<f, σ> → \text{ret } t}
```
```
```
math
\frac{<e_1, σ> → <t_1, σ^1> ... <e_n, σ^{n-1}> → <t_n, σ^n> <f_{call}, σ^n[p_1=t_1, ..., p_n=t_n]> → <t_{res}, σ'>}{<f(e_1, ..., e_n), σ> → <f_t, σ'>}
```
```
rust
```
rust
fn
func
()
->
i32
{
fn
example1
()
->
i32
{
1
+
3
1
+
3
// This is okay return type
}
}
fn
main
()
{
fn
example2
()
->
i32
{
let
a
=
func
();
true
// This is a type missmatch with what type is expected to return
let
b
:
bool
=
a
();
// Type missmatch
}
}
```
```
### Let expression
### Let expression
```
math
```
math
\frac{<e, σ> → t
, σ'}{<
v
:
= e,σ> →
σ'[v:=n]
}
\frac{<e, σ> → t
}{<{/text{let }
v = e,σ> →
<(), σ[v=t]>
}
```
```
```
rust
```
rust
let
a
:
i32
=
1
;
let
a
:
i32
=
1
;
...
@@ -598,13 +608,13 @@ else {
...
@@ -598,13 +608,13 @@ else {
```
```
```
rust
```
rust
let
a
=
0
;
let
mut
a
=
0
;
while
a
<
10
{
while
a
<
10
{
// something that should loop 10 times
// something that should loop 10 times
a
=
a
+
1
;
a
=
a
+
1
;
}
}
let
a
=
0
;
let
mut
a
=
0
;
while
a
*
10
{
// Type missmatch
while
a
*
10
{
// Type missmatch
// something that should loop 10 times
// something that should loop 10 times
a
=
a
+
1
;
a
=
a
+
1
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment