mirror of
https://github.com/LukeHagar/unicorn-utterances.git
synced 2025-12-09 21:07:49 +00:00
Added visual representation of 'boxes' with a clearer explanation
This commit is contained in:
@@ -42,7 +42,7 @@ The instructions are pretty straightforward, so anyone can follow them. Of cours
|
||||
|
||||
Let’s look at the example here below:
|
||||
|
||||

|
||||

|
||||
|
||||
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:
|
||||
|
||||

|
||||
|
||||
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**"
|
||||
|
||||
BIN
content/blog/what-is-an-algorithm/variables.png
Normal file
BIN
content/blog/what-is-an-algorithm/variables.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 31 KiB |
Reference in New Issue
Block a user