-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed a couple of bugs, added code examples
- Loading branch information
Showing
14 changed files
with
84 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
~ (this is a comment) | ||
~ (programm 'hello_world') | ||
|
||
@|(Hello, World!)(-!) ~ (the `@` character indicates that the data being operated on is a character) | ||
~ (the `|` character sequentially fills the array with characters in parentheses) | ||
~ (command `-!` displays the contents of the array on the screen) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
~ (saol is focused on array processing, so it has tools for navigating arrays) | ||
|
||
:123 ~ (initially, the array element pointer is set to 0 element, so this string initializes the 0 cell with the value 123) | ||
>:456 ~ (command `>` moves the pointer 1 forward) | ||
< ~ (similarly, the command ` > ' moves the pointer back 1) | ||
^45 ~ (the ` ^ ' command sets the pointer to a specific position, here in cell 45) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
~ (here we will look at displaying values on the screen) | ||
~ (only values from the array are displayed) | ||
~ (for example let's display the following text: "The answer is: 42") | ||
|
||
|(The answer is: 42) ~ (first, enter the text in the array using `|`) | ||
@ ~ (now we will specify that it is necessary to output the text, but not the number) | ||
(-!) ~ (actually output the values from the array) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
~ (let's study the application of mathematics in saol, for this we calculate the value of the expression (2+5*6-4)/7) | ||
~ (in saol, all mathematical operations have equal execution priority, so we will calculate (5*6+2-4)/7) | ||
|
||
;:5^2047:6[0]1* ~ (in the zero element we write 5, and in the 2047 element we write 6, because all the numbers are added / subtracted / multiplied and divided by the value of the 2047 element) | ||
^0:2+:4' ~ (write 2 in the zero cell produce addition, write 4 in the zero cell, subtract) | ||
:7/^2047(_!) ~ (the result is divided by 7 and printed on the screen) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
~ (in past lessons, you may have noticed constructions like `[0]2`, so let's talk about them) | ||
~ (initially, the commands are applied to all 2048 elements of the array, but to limit the range of action, a construction of the form is used: [<from>]<to>) | ||
~ (for example) | ||
|
||
@|abcdefg [0]3 (-!) ~ (displays characters from 0 to 3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
~ (sometimes you need to fill an array, or part of it, with the same characters / numbers, using the `#`command) | ||
~ (for example) | ||
|
||
[0]3 @ #Q (-!) ~ (filling elements from 0 to 3 with `Q ' characters, output to the screen) | ||
; #6 (-!) ~ (filling the same gap with numbers 6) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
~ (if you want to copy a value from one cell to another, use the commands `:-` & `!-`) | ||
~ (for example) | ||
|
||
:789 (:-) 1 > (_!) ~ (copy the value 789 from the 0th element to the 1st element) | ||
^3:10@(_!)^1; ~ (jump to a new line) | ||
< (!-) 2 >> (_!) ~ (copying the inverted value 789 from element 0 to element 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
~ (in saol, logical operations are also available, namely, & - AND, \ - OR) | ||
~ (for example) | ||
|
||
|1 0 [0]2 & ^2047 (_!) ~ (calculating the conjunction 1 and 0) | ||
^3:10@(_!);^2047 ~ (jump to a new line) | ||
\ (_!) ~ (calculating disjunction 1 and 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
~ (branches based on predicative execution are available in saol) | ||
~ (it works like this: if the result of the previous operation (that is, the condition) is not zero, then the subsequent operations are executed, but they will not be executed if the result is 0) | ||
~ (for example) | ||
|
||
:6 ^2047 :12 [0]1 ' ~ (condition 12 - 6) | ||
(?~) ^0 [0]2048 |(true) @ (-!) ~ (after the command `?~` is the code that must be executed if the condition is true) | ||
(?!) ^0 [0]2048 |(false) @ (-!) ~ (after the command `?!'this is the code that must be executed if the condition is false) | ||
~ (in this case, the condition is true and `true` is output, but if you replace 6 with 12, the condition becomes false and `false`is output) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
~ (the iterator allows you to run the same code for each element of an array or span) | ||
~ (the iterator command looks like this: ( | ~ ) after it, in brackets is the code that will have to be executed for each element sequentially, but most importantly at the end, before closing the bracket, put a space!) | ||
~ (for example) | ||
|
||
@|(i am text!) ~ (write the string `i am text`to the array) | ||
(|~)(_! ) ~ (iteratively display the characters on the screen, by the way this is the implementation of the command `-!`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
~ (if you need to swap the values of 2 elements, use the command `<->`) | ||
~ (for example) | ||
|
||
:678 >> : 123 (<->) 0 (_!) << (_!) ~ (write 678 in the 0-th element, 123 in the 2-th and change their places) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,7 @@ int main(int argc, char *argv[]) { | |
|
||
fclose(src); | ||
fclose(dst); | ||
|
||
return 0; | ||
} | ||
|
||
|