minor fix so I don't need to fix ssg parser
This commit is contained in:
parent
8e35a4e6af
commit
90e5303125
1 changed files with 4 additions and 4 deletions
|
|
@ -12,10 +12,10 @@ No this isn't comprehensive, so no you won't be able to immediately go start mak
|
|||
If you didn't notice the asterisk in the title next to every, now you know there is one. The reason for that asterisk is that this blog only covers stuff that is common(as built in language features) in procedural programming. If you don't know what "procedural" means don't worry about it and pretend that this covers every programming language.
|
||||
|
||||
## The Data
|
||||
Fundamentally programming is about the manipulation of data for varying purposes. On occasion a programmer will want data to be displayed which can be accomplished in many ways. For the purposes of this blog `DISPLAY(some_data)` indicates that whatever `some_data` is should be displayed. Now that data can be displayed, what data can we have? There are a few different types of data we can have<sup>[[1]](#1)</sup>. For now I'll only specify 3. Those 3 are strings, numbers and booleans. First there are strings, more commonly known as text. In many programming languages, including our pseudocode, we can create a string in our program by surrounding some text with quotes `"like this"`. Our second type is numbers which hold numbers. We can of course add, subtract, multiply, divide and raise to a power all of these numbers with the notation of `number1 + number2`, `number1 - number2`, `number1 * number2`, `number1 / number2` and `number1 ^ number2` respectively. Last but not least we have booleans which can hold the values of `true` and `false`. Just like how we can apply different operations onto different number we also have some operations we can apply to booleans. First we have `NOT` which will take a boolean and give back the opposite boolean e.g. true → false and false → true. Second we have `OR` which takes 2 booleans and gives back true if either of them are true and false otherwise. Third we have `AND` which takes 2 booleans and gives back true only if both of them are true and false otherwise. Finally we have `XOR` which will only give back true if only 1 of it's inputs is true eg `true XOR true` → false and `false XOR false` → false but `true XOR false` → true.
|
||||
Fundamentally programming is about the manipulation of data for varying purposes. On occasion a programmer will want data to be displayed which can be accomplished in many ways. For the purposes of this blog `DISPLAY(some_data)` indicates that whatever `some_data` is should be displayed. Now that data can be displayed, what data can we have? There are a few different types of data we can have<sup>[1](#1)</sup>. For now I'll only specify 3. Those 3 are strings, numbers and booleans. First there are strings, more commonly known as text. In many programming languages, including our pseudocode, we can create a string in our program by surrounding some text with quotes `"like this"`. Our second type is numbers which hold numbers. We can of course add, subtract, multiply, divide and raise to a power all of these numbers with the notation of `number1 + number2`, `number1 - number2`, `number1 * number2`, `number1 / number2` and `number1 ^ number2` respectively. Last but not least we have booleans which can hold the values of `true` and `false`. Just like how we can apply different operations onto different number we also have some operations we can apply to booleans. First we have `NOT` which will take a boolean and give back the opposite boolean e.g. true → false and false → true. Second we have `OR` which takes 2 booleans and gives back true if either of them are true and false otherwise. Third we have `AND` which takes 2 booleans and gives back true only if both of them are true and false otherwise. Finally we have `XOR` which will only give back true if only 1 of it's inputs is true eg `true XOR true` → false and `false XOR false` → false but `true XOR false` → true.
|
||||
|
||||
## Variables
|
||||
Variables allow for the storage of data in named<sup>[[2]](#2)</sup> buckets which is very useful especially when taking input that can change at runtime. We can put a value into a variable like so `someVar ← "a string"` which would set the variable someVar to the string value of "a string".
|
||||
Variables allow for the storage of data in named<sup>[2](#2)</sup> buckets which is very useful especially when taking input that can change at runtime. We can put a value into a variable like so `someVar ← "a string"` which would set the variable someVar to the string value of "a string".
|
||||
|
||||
|
||||
## Conditionals
|
||||
|
|
@ -45,7 +45,7 @@ PROC helloProcedure (name) {
|
|||
helloProcedure("World")
|
||||
```
|
||||
## Lists
|
||||
lists are a methodology of storing multiple data values within a single variable<sup>[[4]](#4)</sup>. When you want to store or retrieve a value from a list you need to specify at what position in the list you want to retrieve the value from via a number with the indexing of that list commonly starting from 0 with certain very special languages which choose to start or allow the programmer to start lists from indices other than 0. When declaring a list in our pseudocode I'll use square brackets surrounded comma separated values of the list, the size of the list will not be set in stone for convenience but it should be noted that in most programming languages you need to be explicit when making a list larger. An example of creating and using a list is shown below
|
||||
lists are a methodology of storing multiple data values within a single variable<sup>[4](#4)</sup>. When you want to store or retrieve a value from a list you need to specify at what position in the list you want to retrieve the value from via a number with the indexing of that list commonly starting from 0 with certain very special languages which choose to start or allow the programmer to start lists from indices other than 0. When declaring a list in our pseudocode I'll use square brackets surrounded comma separated values of the list, the size of the list will not be set in stone for convenience but it should be noted that in most programming languages you need to be explicit when making a list larger. An example of creating and using a list is shown below
|
||||
```
|
||||
someList <- ["First item", "Second item", "meh item"]
|
||||
someList[2] <- "Third item"
|
||||
|
|
@ -53,7 +53,7 @@ someList[2] <- "Third item"
|
|||
DISPLAY(someList[0])
|
||||
```
|
||||
## Loops
|
||||
loops are kinda self explanatory as they loop running code repeatedly. Commonly there are 2 types of loop in programming languages and when there are more they can be easily described in relation to these 2. These 2 types of loop are called a `WHILE` loop and a `FOREACH`<sup>[[3]](#3)</sup> loop. A `WHILE` loop will repeatedly run whatever code is inside of them as long as a condition is met, a foreach loop will go through each item in a collection of items such as a list and run some code using that item. Both loops make working with lists much easier because we don't need to write out the code for every single list entry and if the list we may be dealing with will have a size that cannot be known at the time of writing the program might, with the combination of some methodology of retrieving the length of the list, be the only option. the syntax for `FOREACH` loops will borrow from the syntax for assignment with the variable which will go through each value in our list being assigned to and the loop values are being pulled from being used as the value to assign from
|
||||
loops are kinda self explanatory as they loop running code repeatedly. Commonly there are 2 types of loop in programming languages and when there are more they can be easily described in relation to these 2. These 2 types of loop are called a `WHILE` loop and a `FOREACH`<sup>[3](#3)</sup> loop. A `WHILE` loop will repeatedly run whatever code is inside of them as long as a condition is met, a foreach loop will go through each item in a collection of items such as a list and run some code using that item. Both loops make working with lists much easier because we don't need to write out the code for every single list entry and if the list we may be dealing with will have a size that cannot be known at the time of writing the program might, with the combination of some methodology of retrieving the length of the list, be the only option. the syntax for `FOREACH` loops will borrow from the syntax for assignment with the variable which will go through each value in our list being assigned to and the loop values are being pulled from being used as the value to assign from
|
||||
```
|
||||
i <- 0
|
||||
"initializing an empty list which will be filled with the while loop below"
|
||||
|
|
|
|||
Loading…
Reference in a new issue