Added visual representation of 'boxes' with a clearer explanation

This commit is contained in:
qarnax801
2022-08-26 19:30:49 +01:00
parent 4a603c0cca
commit 39426826a9
2 changed files with 18 additions and 1 deletions

View File

@@ -42,7 +42,7 @@ The instructions are pretty straightforward, so anyone can follow them. Of cours
Lets look at the example here below:
![ maze with a series of blocks oriented cleanly in a North East South West direction. Point 'A' is right next to a subway station 'A', while point 'B' is right next to a subway station 'B'.](./mapTwo.png)
![A maze with a series of blocks oriented cleanly in a North East South West direction. Point 'A' is right next to a subway station 'A', while point 'B' is right next to a subway station 'B'.](./mapTwo.png)
Here we can do one of two algorithms to get from point A to point B:
@@ -116,6 +116,23 @@ A variable can be initially considered as a box to keep things in. And since the
So, for any value that needs to be used, we can ask the computer to create a unique **variable** and **assign** our value to that variable so that we're able to use it throughout the code.
To illustrate how that works, let's look at this visual representation of how addition between two values happens:
![Visual representation of how adding two values happens in an algorithm with the help of variables](./variables.png)
If we want to be even more specific on what happens inside the computer, we could re-write the algorithm like this:
```elixir
START
- Take the number 1 and put it in a box called Box1
- Take the number 2 and put it in a box called Box2
- Add them together and put that value in a box called Box3
- Display the value of Box3 on the screen
END
```
You will notice in our illustration that there's a block that says "A function that displays values", but ignore that for the moment because we'll get to what functions are in a few.
> A more extensive explanation on how computers store and handle variables can be found [here](https://unicorn-utterances.com/posts/how-computers-speak).
Now that we've established how values are stored, comes the part where the computer handles the different instructions given, with the help of what we can call "**Operators**"

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB