mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 23:33:00 +03:00
Fixes typos in many different English articles
Signed-off-by: Marcel Ribeiro-Dantas <mribeirodantas@seqera.io>
This commit is contained in:
parent
354fe6fe7d
commit
bba9f7df21
@ -44,7 +44,7 @@ for, which provides an excellent UI.
|
|||||||
#### Cons
|
#### Cons
|
||||||
|
|
||||||
* It is an agent-less tool - every agent consumes up to 16MB ram - in some
|
* It is an agent-less tool - every agent consumes up to 16MB ram - in some
|
||||||
environments, it may be noticable amount.
|
environments, it may be noticeable amount.
|
||||||
* It is agent-less - you have to verify your environment consistency
|
* It is agent-less - you have to verify your environment consistency
|
||||||
'on-demand' - there is no built-in mechanism that would warn you about some
|
'on-demand' - there is no built-in mechanism that would warn you about some
|
||||||
change automatically (this can be achieved with reasonable effort)
|
change automatically (this can be achieved with reasonable effort)
|
||||||
@ -691,7 +691,7 @@ to specify the username.
|
|||||||
|
|
||||||
Note: You may like to execute Ansible with `--ask-sudo-pass` or add the user to
|
Note: You may like to execute Ansible with `--ask-sudo-pass` or add the user to
|
||||||
sudoers file in order to allow non-supervised execution if you require 'admin'
|
sudoers file in order to allow non-supervised execution if you require 'admin'
|
||||||
privilages.
|
privileges.
|
||||||
|
|
||||||
[Read more](http://docs.ansible.com/ansible/latest/become.html)
|
[Read more](http://docs.ansible.com/ansible/latest/become.html)
|
||||||
|
|
||||||
|
@ -256,7 +256,7 @@ int main (int argc, char** argv)
|
|||||||
|
|
||||||
// Floating-point numbers are defined by IEEE 754, thus cannot store perfectly
|
// Floating-point numbers are defined by IEEE 754, thus cannot store perfectly
|
||||||
// exact values. For instance, the following does not produce expected results
|
// exact values. For instance, the following does not produce expected results
|
||||||
// because 0.1 might actually be 0.099999999999 insided the computer, and 0.3
|
// because 0.1 might actually be 0.099999999999 inside the computer, and 0.3
|
||||||
// might be stored as 0.300000000001.
|
// might be stored as 0.300000000001.
|
||||||
(0.1 + 0.1 + 0.1) != 0.3; // => 1 (true)
|
(0.1 + 0.1 + 0.1) != 0.3; // => 1 (true)
|
||||||
// and it is NOT associative due to reasons mentioned above.
|
// and it is NOT associative due to reasons mentioned above.
|
||||||
|
@ -68,7 +68,7 @@ False not. # True
|
|||||||
###########################################
|
###########################################
|
||||||
|
|
||||||
# You may assign values to the current scope:
|
# You may assign values to the current scope:
|
||||||
var name is value. # assignes `value` into `name`
|
var name is value. # assigns `value` into `name`
|
||||||
|
|
||||||
# You may also assign values into the current object's namespace
|
# You may also assign values into the current object's namespace
|
||||||
my name is value. # assigns `value` into the current object's `name` property
|
my name is value. # assigns `value` into the current object's `name` property
|
||||||
@ -146,7 +146,7 @@ add(3, 5). # 8
|
|||||||
|
|
||||||
3 `add` 5. # 8
|
3 `add` 5. # 8
|
||||||
# This call binds as such: add[(3), 5]
|
# This call binds as such: add[(3), 5]
|
||||||
# because the default fixity is left, and the default precedance is 1
|
# because the default fixity is left, and the default precedence is 1
|
||||||
|
|
||||||
# You may change the precedence/fixity of this operator with a pragma
|
# You may change the precedence/fixity of this operator with a pragma
|
||||||
#:declare infixr 1 add
|
#:declare infixr 1 add
|
||||||
|
@ -12,7 +12,7 @@ all began with Direct, such as Direct3D, DirectDraw, DirectMusic, DirectPlay, Di
|
|||||||
Direct3D (the 3D graphics API within DirectX) is widely used in the development of video games for Microsoft
|
Direct3D (the 3D graphics API within DirectX) is widely used in the development of video games for Microsoft
|
||||||
Windows and the Xbox line of consoles.<sup>[1]</sup>
|
Windows and the Xbox line of consoles.<sup>[1]</sup>
|
||||||
|
|
||||||
In this tutorial we will be focusing on DirectX 9, which is not as low-level as it's sucessors, which are aimed at programmers very familiar with how graphics hardware works. It makes a great starting point for learning Direct3D. In this tutorial I will be using the Win32-API for window handling and the DirectX 2010 SDK.
|
In this tutorial we will be focusing on DirectX 9, which is not as low-level as it's successors, which are aimed at programmers very familiar with how graphics hardware works. It makes a great starting point for learning Direct3D. In this tutorial I will be using the Win32-API for window handling and the DirectX 2010 SDK.
|
||||||
|
|
||||||
## Window creation
|
## Window creation
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ bool InitD3D(HWND hWnd) {
|
|||||||
pp.hDeviceWindow = hWnd; // associated window handle
|
pp.hDeviceWindow = hWnd; // associated window handle
|
||||||
pp.Windowed = true; // display in window mode
|
pp.Windowed = true; // display in window mode
|
||||||
pp.Flags = 0; // no special flags
|
pp.Flags = 0; // no special flags
|
||||||
// Variable to store results of methods to check if everything succeded.
|
// Variable to store results of methods to check if everything succeeded.
|
||||||
HRESULT result{ };
|
HRESULT result{ };
|
||||||
result = _d3d->CreateDevice(D3DADAPTER_DEFAULT, // use default graphics card
|
result = _d3d->CreateDevice(D3DADAPTER_DEFAULT, // use default graphics card
|
||||||
D3DDEVTYPE_HAL, // use hardware acceleration
|
D3DDEVTYPE_HAL, // use hardware acceleration
|
||||||
@ -144,7 +144,7 @@ bool InitD3D(HWND hWnd) {
|
|||||||
viewport.Y = 0; // ..
|
viewport.Y = 0; // ..
|
||||||
viewport.Width = clientRect.right; // use the entire window
|
viewport.Width = clientRect.right; // use the entire window
|
||||||
viewport.Height = clientRect.bottom; // ..
|
viewport.Height = clientRect.bottom; // ..
|
||||||
viewport.MinZ = 0.0f; // minimun view distance
|
viewport.MinZ = 0.0f; // minimum view distance
|
||||||
viewport.MaxZ = 100.0f; // maximum view distance
|
viewport.MaxZ = 100.0f; // maximum view distance
|
||||||
// Apply the created viewport.
|
// Apply the created viewport.
|
||||||
result = _device->SetViewport(&viewport);
|
result = _device->SetViewport(&viewport);
|
||||||
@ -157,7 +157,7 @@ bool InitD3D(HWND hWnd) {
|
|||||||
// ...
|
// ...
|
||||||
// Back in our WinMain function we call our initialization function.
|
// Back in our WinMain function we call our initialization function.
|
||||||
// ...
|
// ...
|
||||||
// Check if Direct3D initialization succeded, else exit the application.
|
// Check if Direct3D initialization succeeded, else exit the application.
|
||||||
if (!InitD3D(hWnd))
|
if (!InitD3D(hWnd))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ Let's create a vertex buffer to store the vertices for our triangle
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
// First we declare a new ComPtr holding a vertex buffer.
|
// First we declare a new ComPtr holding a vertex buffer.
|
||||||
ComPtr<IDirect3DVertexBuffer9> _vertexBuffer{ };
|
ComPtr<IDirect3DVertexBuffer9> _vertexBuffer{ };
|
||||||
// Lets define a funtion to calculate the byte size of a std::vector
|
// Lets define a function to calculate the byte size of a std::vector
|
||||||
template <typename T>
|
template <typename T>
|
||||||
unsigned int GetByteSize(const std::vector<T>& vec) {
|
unsigned int GetByteSize(const std::vector<T>& vec) {
|
||||||
return sizeof(vec[0]) * vec.size();
|
return sizeof(vec[0]) * vec.size();
|
||||||
@ -253,7 +253,7 @@ if (!InitD3D(hWnd))
|
|||||||
return -1;
|
return -1;
|
||||||
// Define the vertices we need to draw a triangle.
|
// Define the vertices we need to draw a triangle.
|
||||||
// Values are declared in a clockwise direction else Direct3D would cull them.
|
// Values are declared in a clockwise direction else Direct3D would cull them.
|
||||||
// If you want to diable culling just call:
|
// If you want to disable culling just call:
|
||||||
// _device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
|
// _device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
|
||||||
std::vector<VStruct> vertices {
|
std::vector<VStruct> vertices {
|
||||||
// Bottom left
|
// Bottom left
|
||||||
@ -274,7 +274,7 @@ if (!(_vertexBuffer = CreateBuffer(vertices)))
|
|||||||
Before we can use the vertex buffer to draw our primitives, we first need to set up the matrices.
|
Before we can use the vertex buffer to draw our primitives, we first need to set up the matrices.
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
// Lets create a new funtions for the matrix transformations.
|
// Lets create a new functions for the matrix transformations.
|
||||||
bool SetupTransform() {
|
bool SetupTransform() {
|
||||||
// Create a view matrix that transforms world space to
|
// Create a view matrix that transforms world space to
|
||||||
// view space.
|
// view space.
|
||||||
@ -338,7 +338,7 @@ if (FAILED(result))
|
|||||||
// Create a world transformation matrix and set it to an identity matrix.
|
// Create a world transformation matrix and set it to an identity matrix.
|
||||||
D3DXMATRIX world{ };
|
D3DXMATRIX world{ };
|
||||||
D3DXMatrixIdentity(&world);
|
D3DXMatrixIdentity(&world);
|
||||||
// Create a scalation matrix scaling our primitve by 10 in the x,
|
// Create a scalation matrix scaling our primitive by 10 in the x,
|
||||||
// 10 in the y and keeping the z direction.
|
// 10 in the y and keeping the z direction.
|
||||||
D3DXMATRIX scaling{ };
|
D3DXMATRIX scaling{ };
|
||||||
D3DXMatrixScaling(&scaling, // matrix to scale
|
D3DXMatrixScaling(&scaling, // matrix to scale
|
||||||
@ -499,7 +499,7 @@ std::vector<D3DVERTEXELEMENT9> vertexDeclDesc {
|
|||||||
0, // byte offset from the struct beginning
|
0, // byte offset from the struct beginning
|
||||||
D3DDECLTYPE_FLOAT3, // data type (3d float vector)
|
D3DDECLTYPE_FLOAT3, // data type (3d float vector)
|
||||||
D3DDECLMETHOD_DEFAULT, // tessellator operation
|
D3DDECLMETHOD_DEFAULT, // tessellator operation
|
||||||
D3DDECLUSAGE_POSTION, // usage of the data
|
D3DDECLUSAGE_POSITION, // usage of the data
|
||||||
0 }, // index (multiples usage of the same type)
|
0 }, // index (multiples usage of the same type)
|
||||||
{ 0,
|
{ 0,
|
||||||
12, // byte offset (3 * sizeof(float) bytes)
|
12, // byte offset (3 * sizeof(float) bytes)
|
||||||
|
@ -254,7 +254,7 @@ $docker build <path-to-dockerfile>
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Push your image to DockerHub
|
## Push your image to DockerHub
|
||||||
If you want your application's Docker image to be made publically available for
|
If you want your application's Docker image to be made publicly available for
|
||||||
any Docker user, you might wanna push it to the [Docker Hub](https://hub.docker.com/) which is a
|
any Docker user, you might wanna push it to the [Docker Hub](https://hub.docker.com/) which is a
|
||||||
registry of Docker images. Make sure you have an account with a username and
|
registry of Docker images. Make sure you have an account with a username and
|
||||||
password on Docker Hub.
|
password on Docker Hub.
|
||||||
|
@ -12,7 +12,7 @@ It is used by circuit designers to simulate circuits and logic prior to wiring a
|
|||||||
HDL allows circuit designers to simulate circuits at a high level without being connected to specific components.
|
HDL allows circuit designers to simulate circuits at a high level without being connected to specific components.
|
||||||
|
|
||||||
## Basic building blocks & introduction to the language---
|
## Basic building blocks & introduction to the language---
|
||||||
This programming language is built by simulating hardware chips and wiring. Normal programming functions are replaced with specialized chips that are added to the current wiring desing. Every base chip must be written as it's own file and imported to be used in the current chip, though they may be reused as often as desired.
|
This programming language is built by simulating hardware chips and wiring. Normal programming functions are replaced with specialized chips that are added to the current wiring design. Every base chip must be written as it's own file and imported to be used in the current chip, though they may be reused as often as desired.
|
||||||
|
|
||||||
```verilog
|
```verilog
|
||||||
// Single line comments start with two forward slashes.
|
// Single line comments start with two forward slashes.
|
||||||
@ -79,7 +79,7 @@ foo(in=a[0..7], out=c); // C is now a 2 bit internal bus
|
|||||||
|
|
||||||
|
|
||||||
// Note that internally defined busses cannot be subbussed!
|
// Note that internally defined busses cannot be subbussed!
|
||||||
// To access these elements, output or input them seperately:
|
// To access these elements, output or input them separately:
|
||||||
foo(in[0]=false, in[1..7]=a[0..6], out[0]=out1, out[1]=out2);
|
foo(in[0]=false, in[1..7]=a[0..6], out[0]=out1, out[1]=out2);
|
||||||
// out1 and out2 can then be passed into other circuits within the design.
|
// out1 and out2 can then be passed into other circuits within the design.
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ Let's take a look at examples to see the key syntax differences!
|
|||||||
Oh wait.. there is! It's called Hjson.
|
Oh wait.. there is! It's called Hjson.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
# Backslashes are interpretted as an escape character ONLY in quoted strings
|
# Backslashes are interpreted as an escape character ONLY in quoted strings
|
||||||
slash: This will not have a new line\n
|
slash: This will not have a new line\n
|
||||||
slash-quoted: "This will definitely have a new line\n"
|
slash-quoted: "This will definitely have a new line\n"
|
||||||
|
|
||||||
|
@ -620,7 +620,7 @@ function isEven(number) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// I put the word "equivalent" in double quotes because a function defined
|
// I put the word "equivalent" in double quotes because a function defined
|
||||||
// using the lambda syntax cannnot be called before the definition.
|
// using the lambda syntax cannot be called before the definition.
|
||||||
// The following is an example of invalid usage:
|
// The following is an example of invalid usage:
|
||||||
|
|
||||||
add(1, 8);
|
add(1, 8);
|
||||||
|
@ -131,7 +131,7 @@ assert obj5 == {};
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Further Reading
|
## Further Reading
|
||||||
There are a few but important concepts that are not touched in this exmaple, including:
|
There are a few but important concepts that are not touched in this example, including:
|
||||||
|
|
||||||
- Passing variables from command line: [Parameterize Entire Config](https://jsonnet.org/learning/tutorial.html#parameterize-entire-config)
|
- Passing variables from command line: [Parameterize Entire Config](https://jsonnet.org/learning/tutorial.html#parameterize-entire-config)
|
||||||
- Import other jsonnet libraries/files: [Imports](https://jsonnet.org/learning/tutorial.html#imports)
|
- Import other jsonnet libraries/files: [Imports](https://jsonnet.org/learning/tutorial.html#imports)
|
||||||
|
@ -560,7 +560,7 @@ select avg height by sex from t
|
|||||||
/ => f | 160
|
/ => f | 160
|
||||||
/ => m | 177.5
|
/ => m | 177.5
|
||||||
|
|
||||||
/ If no aggreation function is specified, last is assumed
|
/ If no aggregation function is specified, last is assumed
|
||||||
select by sex from t
|
select by sex from t
|
||||||
/ => sex| name age height
|
/ => sex| name age height
|
||||||
/ => ---| -----------------
|
/ => ---| -----------------
|
||||||
|
@ -41,7 +41,7 @@ Evaluation is done via
|
|||||||
which is essentially lexically-scoped substitution.
|
which is essentially lexically-scoped substitution.
|
||||||
|
|
||||||
When evaluating the
|
When evaluating the
|
||||||
expression `(λx.x)a`, we replace all occurences of "x" in the function's body
|
expression `(λx.x)a`, we replace all occurrences of "x" in the function's body
|
||||||
with "a".
|
with "a".
|
||||||
|
|
||||||
- `(λx.x)a` evaluates to: `a`
|
- `(λx.x)a` evaluates to: `a`
|
||||||
|
@ -193,7 +193,7 @@ while condition[0]:
|
|||||||
for i in 0 to 10 do:
|
for i in 0 to 10 do:
|
||||||
vector[i] = i
|
vector[i] = i
|
||||||
|
|
||||||
; stanza also supports named labels which can functin as break or return
|
; stanza also supports named labels which can function as break or return
|
||||||
; statements
|
; statements
|
||||||
defn another-fn ():
|
defn another-fn ():
|
||||||
label<False> return:
|
label<False> return:
|
||||||
@ -218,7 +218,7 @@ for (x in xs, y in ys, z in zs) do :
|
|||||||
println("x:%_, y:%_, z:%_" % [x, y, z])
|
println("x:%_, y:%_, z:%_" % [x, y, z])
|
||||||
|
|
||||||
|
|
||||||
;xs, ys, and zs are all "Seqable" meaing they are Seq types (sequences).
|
;xs, ys, and zs are all "Seqable" meaning they are Seq types (sequences).
|
||||||
; the `do` identifier is a special function that just applies the body of
|
; the `do` identifier is a special function that just applies the body of
|
||||||
; the for loop to each element of the sequence.
|
; the for loop to each element of the sequence.
|
||||||
;
|
;
|
||||||
|
@ -198,7 +198,7 @@ M has an execution stack. When all levels of the stack have returned, the progra
|
|||||||
With an argument: execute a block of code & add a level to the stack.
|
With an argument: execute a block of code & add a level to the stack.
|
||||||
|
|
||||||
```
|
```
|
||||||
d ^routine ;run a routine from the begining.
|
d ^routine ;run a routine from the beginning.
|
||||||
; ;routines are identified by a caret.
|
; ;routines are identified by a caret.
|
||||||
d tag ;run a tag in the current routine
|
d tag ;run a tag in the current routine
|
||||||
d tag^routine ;run a tag in different routine
|
d tag^routine ;run a tag in different routine
|
||||||
|
@ -298,7 +298,7 @@ omitted though.)
|
|||||||
- [Subchapter <h3 />](#subchapter-h3-)
|
- [Subchapter <h3 />](#subchapter-h3-)
|
||||||
```
|
```
|
||||||
|
|
||||||
Nontheless, this is a feature that might not be working in all Markdown
|
Nonetheless, this is a feature that might not be working in all Markdown
|
||||||
implementations the same way.
|
implementations the same way.
|
||||||
|
|
||||||
## Images
|
## Images
|
||||||
|
@ -22,13 +22,13 @@ and/or directorie(s) over time.
|
|||||||
|
|
||||||
* Distributed Architecture - Traditionally version control systems such as CVS
|
* Distributed Architecture - Traditionally version control systems such as CVS
|
||||||
and Subversion are a client server architecture with a central server to
|
and Subversion are a client server architecture with a central server to
|
||||||
store the revsion history of a project. Mercurial however is a truly
|
store the revision history of a project. Mercurial however is a truly
|
||||||
distributed architecture, giving each devloper a full local copy of the
|
distributed architecture, giving each developer a full local copy of the
|
||||||
entire development history. It works independently of a central server.
|
entire development history. It works independently of a central server.
|
||||||
* Fast - Traditionally version control systems such as CVS and Subversion are a
|
* Fast - Traditionally version control systems such as CVS and Subversion are a
|
||||||
client server architecture with a central server to store the revsion history
|
client server architecture with a central server to store the revision history
|
||||||
of a project. Mercurial however is a truly distributed architecture, giving
|
of a project. Mercurial however is a truly distributed architecture, giving
|
||||||
each devloper a full local copy of the entire development history. It works
|
each developer a full local copy of the entire development history. It works
|
||||||
independently of a central server.
|
independently of a central server.
|
||||||
* Platform Independent - Mercurial was written to be highly platform
|
* Platform Independent - Mercurial was written to be highly platform
|
||||||
independent. Much of Mercurial is written in Python, with small performance
|
independent. Much of Mercurial is written in Python, with small performance
|
||||||
@ -56,7 +56,7 @@ any later version.
|
|||||||
| changeset | Set of changes saved as diffs |
|
| changeset | Set of changes saved as diffs |
|
||||||
| diff | Changes between file(s) |
|
| diff | Changes between file(s) |
|
||||||
| tag | A named named revision |
|
| tag | A named named revision |
|
||||||
| parent(s) | Immediate ancestor(s) of a revison |
|
| parent(s) | Immediate ancestor(s) of a revision |
|
||||||
| branch | A child of a revision |
|
| branch | A child of a revision |
|
||||||
| head | A head is a changeset with no child changesets |
|
| head | A head is a changeset with no child changesets |
|
||||||
| merge | The process of merging two HEADS |
|
| merge | The process of merging two HEADS |
|
||||||
@ -184,7 +184,7 @@ Commit changes to the given files into the repository.
|
|||||||
# Commit with a message
|
# Commit with a message
|
||||||
$ hg commit -m 'This is a commit message'
|
$ hg commit -m 'This is a commit message'
|
||||||
|
|
||||||
# Commit all added / removed files in the currrent tree
|
# Commit all added / removed files in the current tree
|
||||||
$ hg commit -A 'Adding and removing all existing files in the tree'
|
$ hg commit -A 'Adding and removing all existing files in the tree'
|
||||||
|
|
||||||
# amend the parent of the working directory with a new commit that contains the
|
# amend the parent of the working directory with a new commit that contains the
|
||||||
@ -341,7 +341,7 @@ $ hg revert -a
|
|||||||
Remove the specified files on the next commit.
|
Remove the specified files on the next commit.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Remove a spcific file
|
# Remove a specific file
|
||||||
$ hg remove go_away.txt
|
$ hg remove go_away.txt
|
||||||
|
|
||||||
# Remove a group of files by pattern
|
# Remove a group of files by pattern
|
||||||
|
@ -111,7 +111,7 @@ gateways and routers.
|
|||||||
sub $t2, $t0, $t1 # $t2 = $t0 - $t1
|
sub $t2, $t0, $t1 # $t2 = $t0 - $t1
|
||||||
mul $t2, $t0, $t1 # $t2 = $t0 * $t1
|
mul $t2, $t0, $t1 # $t2 = $t0 * $t1
|
||||||
div $t2, $t0, $t1 # $t2 = $t0 / $t1 (Might not be
|
div $t2, $t0, $t1 # $t2 = $t0 / $t1 (Might not be
|
||||||
# supported in some versons of MARS)
|
# supported in some versions of MARS)
|
||||||
div $t0, $t1 # Performs $t0 / $t1. Get the
|
div $t0, $t1 # Performs $t0 / $t1. Get the
|
||||||
# quotient using 'mflo' and
|
# quotient using 'mflo' and
|
||||||
# remainder using 'mfhi'
|
# remainder using 'mfhi'
|
||||||
|
@ -170,7 +170,7 @@ printseven
|
|||||||
/# currently, preprocessor statements can be used to make c++-style constants #/
|
/# currently, preprocessor statements can be used to make c++-style constants #/
|
||||||
|
|
||||||
&DEFINE LOOPSTR 20&
|
&DEFINE LOOPSTR 20&
|
||||||
/# must have & on either side with no spaces, 'DEFINE' is case sensative. #/
|
/# must have & on either side with no spaces, 'DEFINE' is case sensitive. #/
|
||||||
/# All statements are scanned and replaced before the program is run, regardless of where the statements are placed #/
|
/# All statements are scanned and replaced before the program is run, regardless of where the statements are placed #/
|
||||||
|
|
||||||
FOR LOOPSTR 7 PRINT . ENDFOR /# Prints '7' 20 times. At run, 'LOOPSTR' in source code is replaced with '20' #/
|
FOR LOOPSTR 7 PRINT . ENDFOR /# Prints '7' 20 times. At run, 'LOOPSTR' in source code is replaced with '20' #/
|
||||||
|
@ -35,7 +35,7 @@ int main() {
|
|||||||
context };
|
context };
|
||||||
window.setVerticalSyncEnabled(true);
|
window.setVerticalSyncEnabled(true);
|
||||||
window.setActive(true);
|
window.setActive(true);
|
||||||
// After that we initialise GLEW and check if an error occured.
|
// After that we initialise GLEW and check if an error occurred.
|
||||||
GLenum error;
|
GLenum error;
|
||||||
glewExperimental = GL_TRUE;
|
glewExperimental = GL_TRUE;
|
||||||
if ((err = glewInit()) != GLEW_OK)
|
if ((err = glewInit()) != GLEW_OK)
|
||||||
@ -140,7 +140,7 @@ if (logSize > 0) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
The same is possibile after <code>glLinkProgram()</code>, just replace <code>glGetShaderiv()</code> with <code>glGetProgramiv()</code>
|
The same is possible after <code>glLinkProgram()</code>, just replace <code>glGetShaderiv()</code> with <code>glGetProgramiv()</code>
|
||||||
and <code>glGetShaderInfoLog()</code> with <code>glGetProgramInfoLog()</code>.
|
and <code>glGetShaderInfoLog()</code> with <code>glGetProgramInfoLog()</code>.
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
@ -194,7 +194,7 @@ void main() {
|
|||||||
out vec4 outColor;
|
out vec4 outColor;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
// We simply set the ouput color to red.
|
// We simply set the output color to red.
|
||||||
// The parameters are red, green, blue and alpha.
|
// The parameters are red, green, blue and alpha.
|
||||||
outColor = vec4(1.0, 0.0, 0.0, 1.0);
|
outColor = vec4(1.0, 0.0, 0.0, 1.0);
|
||||||
}
|
}
|
||||||
@ -233,7 +233,7 @@ glBufferData(GL_ARRAY_BUFFER, // target buffer
|
|||||||
// After filling the VBO link it to the location 0 in our vertex shader,
|
// After filling the VBO link it to the location 0 in our vertex shader,
|
||||||
// which holds the vertex position.
|
// which holds the vertex position.
|
||||||
// ...
|
// ...
|
||||||
// To ask for the attibute location, if you haven't set it:
|
// To ask for the attribute location, if you haven't set it:
|
||||||
GLint posLocation = glGetAttribLocation(program, "position");
|
GLint posLocation = glGetAttribLocation(program, "position");
|
||||||
// ..
|
// ..
|
||||||
glEnableVertexAttribArray(0);
|
glEnableVertexAttribArray(0);
|
||||||
@ -463,7 +463,7 @@ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo);
|
|||||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(iboData[0]) * iboData.size(),
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(iboData[0]) * iboData.size(),
|
||||||
iboData.data(), GL_STATIC_DRAW);
|
iboData.data(), GL_STATIC_DRAW);
|
||||||
// Next in our render loop, we replace glDrawArrays() with:
|
// Next in our render loop, we replace glDrawArrays() with:
|
||||||
glDrawElements(GL_TRIANGLES, iboData.size(), GL_UNSINGED_INT, nullptr);
|
glDrawElements(GL_TRIANGLES, iboData.size(), GL_UNSIGNED_INT, nullptr);
|
||||||
// Remember to delete the allocated memory for the IBO.
|
// Remember to delete the allocated memory for the IBO.
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -535,7 +535,7 @@ glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 0, nullptr);
|
|||||||
// ...
|
// ...
|
||||||
glBindVertexArray(vao);
|
glBindVertexArray(vao);
|
||||||
glBindTexture(GL_TEXTURE_2D, texture);
|
glBindTexture(GL_TEXTURE_2D, texture);
|
||||||
glDrawElements(GL_TRIANGLES, iboData.size(), GL_UNSINGED_INT, nullptr);
|
glDrawElements(GL_TRIANGLES, iboData.size(), GL_UNSIGNED_INT, nullptr);
|
||||||
// ...
|
// ...
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -673,7 +673,7 @@ glUniformMatrix4fv(modelLocation, 1, GL_FALSE,
|
|||||||
|
|
||||||
## Geometry Shader
|
## Geometry Shader
|
||||||
|
|
||||||
Gemoetry shaders were introduced in OpenGL 3.2, they can produce vertices
|
Geometry shaders were introduced in OpenGL 3.2, they can produce vertices
|
||||||
that are send to the rasterizer. They can also change the primitive type e.g.
|
that are send to the rasterizer. They can also change the primitive type e.g.
|
||||||
they can take a point as an input and output other primitives.
|
they can take a point as an input and output other primitives.
|
||||||
Geometry shaders are inbetween the vertex and the fragment shader.
|
Geometry shaders are inbetween the vertex and the fragment shader.
|
||||||
|
@ -29,11 +29,11 @@ function setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function draw() {
|
function draw() {
|
||||||
ellipse(10, 10, 50, 50); // creates a ellipse at the 10px from the left and 10px from the top with width adn height as 50 each, so its basically a circle.
|
ellipse(10, 10, 50, 50); // creates a ellipse at the 10px from the left and 10px from the top with width and height as 50 each, so its basically a circle.
|
||||||
//remember in p5.js the origin is at the top-left corner of the canvas
|
//remember in p5.js the origin is at the top-left corner of the canvas
|
||||||
|
|
||||||
if (mouseIsPressed) {
|
if (mouseIsPressed) {
|
||||||
// mouseIsPressed is a boolean variable that changes to true if the mouse buttton is pressed down at that instant
|
// mouseIsPressed is a boolean variable that changes to true if the mouse button is pressed down at that instant
|
||||||
|
|
||||||
fill(0); // fill refers to the innner color or filling color of whatever shape you are going to draw next
|
fill(0); // fill refers to the innner color or filling color of whatever shape you are going to draw next
|
||||||
} else {
|
} else {
|
||||||
|
@ -131,7 +131,7 @@ Begin
|
|||||||
str := 'apple';
|
str := 'apple';
|
||||||
bool := true;
|
bool := true;
|
||||||
//pascal is not a case-sensitive language
|
//pascal is not a case-sensitive language
|
||||||
//arithmethic operation
|
//arithmetic operation
|
||||||
int := 1 + 1; // int = 2 overwriting the previous assignment
|
int := 1 + 1; // int = 2 overwriting the previous assignment
|
||||||
int := int + 1; // int = 2 + 1 = 3;
|
int := int + 1; // int = 2 + 1 = 3;
|
||||||
int := 4 div 2; //int = 2 division operation where result will be floored
|
int := 4 div 2; //int = 2 division operation where result will be floored
|
||||||
|
@ -443,7 +443,7 @@ $bar('C'); // Prints "A - B - C"
|
|||||||
// You can call named functions using strings
|
// You can call named functions using strings
|
||||||
$function_name = 'add';
|
$function_name = 'add';
|
||||||
echo $function_name(1, 2); // => 3
|
echo $function_name(1, 2); // => 3
|
||||||
// Useful for programatically determining which function to run.
|
// Useful for programmatically determining which function to run.
|
||||||
// Or, use call_user_func(callable $callback [, $parameter [, ... ]]);
|
// Or, use call_user_func(callable $callback [, $parameter [, ... ]]);
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
language: processing
|
language: processing
|
||||||
filename: learnprocessing.pde
|
filename: learnprocessing.pde
|
||||||
contributors:
|
contributors:
|
||||||
- ["Phone Thant Ko", "http://github.com/phonethantko"]
|
- ["Phone Than Ko", "http://github.com/phonethantko"]
|
||||||
- ["Divay Prakash", "https://github.com/divayprakash"]
|
- ["Divay Prakash", "https://github.com/divayprakash"]
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -256,7 +256,7 @@ line(x1, y1, z1, x2, y2, z2); // In 3D space
|
|||||||
|
|
||||||
// Triangle
|
// Triangle
|
||||||
triangle(x1, y1, x2, y2, x3, y3);
|
triangle(x1, y1, x2, y2, x3, y3);
|
||||||
// Draws a triangle connecting three points defined by coordinate paramters.
|
// Draws a triangle connecting three points defined by coordinate parameters.
|
||||||
|
|
||||||
// Rectangle
|
// Rectangle
|
||||||
rect(a, b, c, d, [r]); // With optional parameter defining the radius of all corners
|
rect(a, b, c, d, [r]); // With optional parameter defining the radius of all corners
|
||||||
@ -375,7 +375,7 @@ texture(image); // PImage can be passed into arguments for texture-mapping the s
|
|||||||
|
|
||||||
If you want to take things further, there are more things Processing is powered
|
If you want to take things further, there are more things Processing is powered
|
||||||
for. Rendering models, shaders and whatnot. There's too much to cover in a
|
for. Rendering models, shaders and whatnot. There's too much to cover in a
|
||||||
short documentation, so I will leave them out here. Shoud you be interested,
|
short documentation, so I will leave them out here. Should you be interested,
|
||||||
please check out the references.
|
please check out the references.
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -59,9 +59,9 @@ compare 3 2 -- GT
|
|||||||
true && (9 >= 19 || 1 < 2) -- true
|
true && (9 >= 19 || 1 < 2) -- true
|
||||||
|
|
||||||
-- Strings
|
-- Strings
|
||||||
"Hellow" :: String -- "Hellow"
|
"Hello" :: String -- "Hello"
|
||||||
-- Multiline string without newlines, to run in PSCi use "paste" mode.
|
-- Multiline string without newlines, to run in PSCi use "paste" mode.
|
||||||
"Hellow\
|
"Hello\
|
||||||
\orld" -- "Helloworld"
|
\orld" -- "Helloworld"
|
||||||
-- Multiline string with newlines
|
-- Multiline string with newlines
|
||||||
"""Hello
|
"""Hello
|
||||||
|
@ -193,7 +193,7 @@ are C<print>, C<put> and C<say>.
|
|||||||
### Comments
|
### Comments
|
||||||
|
|
||||||
Although Pod blocks are ignored by the Rakudo Raku compiler, everything
|
Although Pod blocks are ignored by the Rakudo Raku compiler, everything
|
||||||
indentified as a Pod block will be read and interpreted by Pod renderers. In
|
identified as a Pod block will be read and interpreted by Pod renderers. In
|
||||||
order to prevent Pod blocks from being rendered by any renderer, use the
|
order to prevent Pod blocks from being rendered by any renderer, use the
|
||||||
`=comment` directive.
|
`=comment` directive.
|
||||||
|
|
||||||
|
@ -688,7 +688,7 @@ say (0 or False); # OUTPUT: «False».
|
|||||||
my ($a, $b, $c, $d, $e) = 1, 0, False, True, 'pi';
|
my ($a, $b, $c, $d, $e) = 1, 0, False, True, 'pi';
|
||||||
say $a && $b && $c; # OUTPUT: «0», the first falsey value
|
say $a && $b && $c; # OUTPUT: «0», the first falsey value
|
||||||
say $a && $b && $c; # OUTPUT: «False», the first falsey value
|
say $a && $b && $c; # OUTPUT: «False», the first falsey value
|
||||||
say $a && $d && $e; # OUTPUT: «pi», last operand since everthing before is truthy
|
say $a && $d && $e; # OUTPUT: «pi», last operand since everything before is truthy
|
||||||
|
|
||||||
# `||` returns the first argument that evaluates to `True`.
|
# `||` returns the first argument that evaluates to `True`.
|
||||||
say $b || $a || $d; # OUTPUT: «1»
|
say $b || $a || $d; # OUTPUT: «1»
|
||||||
@ -1965,7 +1965,7 @@ say so 'abbbbc' ~~ / a b* c /; # OUTPUT: «True»
|
|||||||
say so 'aec' ~~ / a b* c /; # OUTPUT: «False», "b"(s) are optional, not replaceable.
|
say so 'aec' ~~ / a b* c /; # OUTPUT: «False», "b"(s) are optional, not replaceable.
|
||||||
|
|
||||||
# `**` - (Unbound) Quantifier
|
# `**` - (Unbound) Quantifier
|
||||||
# If you squint hard enough, you might understand why exponentation is used
|
# If you squint hard enough, you might understand why exponentiation is used
|
||||||
# for quantity.
|
# for quantity.
|
||||||
say so 'abc' ~~ / a b**1 c /; # OUTPUT: «True», exactly one time
|
say so 'abc' ~~ / a b**1 c /; # OUTPUT: «True», exactly one time
|
||||||
say so 'abc' ~~ / a b**1..3 c /; # OUTPUT: «True», one to three times
|
say so 'abc' ~~ / a b**1..3 c /; # OUTPUT: «True», one to three times
|
||||||
|
@ -302,7 +302,7 @@ do {
|
|||||||
// Recursion is the idiomatic way of repeating an action in Scala (as in most
|
// Recursion is the idiomatic way of repeating an action in Scala (as in most
|
||||||
// other functional languages).
|
// other functional languages).
|
||||||
// Recursive functions need an explicit return type, the compiler can't infer it.
|
// Recursive functions need an explicit return type, the compiler can't infer it.
|
||||||
// Here it's Unit, which is analagous to a `void` return type in Java
|
// Here it's Unit, which is analogous to a `void` return type in Java
|
||||||
def showNumbersInRange(a: Int, b: Int): Unit = {
|
def showNumbersInRange(a: Int, b: Int): Unit = {
|
||||||
print(a)
|
print(a)
|
||||||
if (a < b)
|
if (a < b)
|
||||||
|
@ -154,7 +154,7 @@ fn learnTypes() void
|
|||||||
sys.validate(dyna_array.size() == 1);
|
sys.validate(dyna_array.size() == 1);
|
||||||
|
|
||||||
// a map that associates a number to a string.
|
// a map that associates a number to a string.
|
||||||
// "map(x)..." reads "map with key of type x and vaue of type..."
|
// "map(x)..." reads "map with key of type x and value of type..."
|
||||||
var a_map map(string)i32;
|
var a_map map(string)i32;
|
||||||
|
|
||||||
a_map.insert("one", 1);
|
a_map.insert("one", 1);
|
||||||
|
@ -60,7 +60,7 @@ doSomethingWith: argumentObject
|
|||||||
|
|
||||||
Everything here except the `^` involves sending more messages. Event the `ifTrue:` that you might think is a language control structure is just Smalltalk code.
|
Everything here except the `^` involves sending more messages. Event the `ifTrue:` that you might think is a language control structure is just Smalltalk code.
|
||||||
|
|
||||||
We start by sending `size` to `self`. `self` is the object currently running the code - so in this case it is the myObject we started with. `size` is a very common message that we might anticipate tells us something about how big an object is; you could look it up with the Smalltalk tools very simply. The result we get is then sent the message `>` with the plain old integer 4 (which is an object too; no strange primitive types to pollute the system here) and nobody should be surprised the `>` is a comparison that answers true or false. That boolean (which is actually a Boolean object in Smalltalk) is sent the message `ifTrue:` with the block of code between the `[]` as its argument; obvioulsy a true boolean might be expected to run that block of code and a false to ignore it.
|
We start by sending `size` to `self`. `self` is the object currently running the code - so in this case it is the myObject we started with. `size` is a very common message that we might anticipate tells us something about how big an object is; you could look it up with the Smalltalk tools very simply. The result we get is then sent the message `>` with the plain old integer 4 (which is an object too; no strange primitive types to pollute the system here) and nobody should be surprised the `>` is a comparison that answers true or false. That boolean (which is actually a Boolean object in Smalltalk) is sent the message `ifTrue:` with the block of code between the `[]` as its argument; obviously a true boolean might be expected to run that block of code and a false to ignore it.
|
||||||
|
|
||||||
If the block is run then we do some more message sending to the argument object and noting the `^` we return the answer back to our starting point and it gets assigned to `result`. If the block is ignored we seem to run out of code and so `self` is returned and assigned to `result`.
|
If the block is run then we do some more message sending to the argument object and noting the `^` we return the answer back to our starting point and it gets assigned to `result`. If the block is ignored we seem to run out of code and so `self` is returned and assigned to `result`.
|
||||||
|
|
||||||
|
@ -713,7 +713,7 @@ end
|
|||||||
#### About [T]CSH:
|
#### About [T]CSH:
|
||||||
# * CSH is notorious about its bugs;
|
# * CSH is notorious about its bugs;
|
||||||
# * It was also famous about its advanced interactive mode.
|
# * It was also famous about its advanced interactive mode.
|
||||||
# * TCSH is famous that have the most advanced completition subsystem.
|
# * TCSH is famous that have the most advanced completion subsystem.
|
||||||
# * TCSH is famous that have the most advanced aliases subsystem; aliases
|
# * TCSH is famous that have the most advanced aliases subsystem; aliases
|
||||||
# can take parameters and often used as functions!
|
# can take parameters and often used as functions!
|
||||||
# * TCSH is well known that preferred by people (me too) because of better
|
# * TCSH is well known that preferred by people (me too) because of better
|
||||||
|
@ -165,11 +165,11 @@ but again, they use different HTML markup and thus the distinction.
|
|||||||
|
|
||||||
###. Superscripts and Subscripts use carats and tildes:
|
###. Superscripts and Subscripts use carats and tildes:
|
||||||
|
|
||||||
Superscripts are 2 ^nd^ to none, but subscripts are CO ~2~ L too.
|
Superscripts are 2 ^and^ to none, but subscripts are CO ~2~ L too.
|
||||||
Note the spaces around the superscripts and subscripts.
|
Note the spaces around the superscripts and subscripts.
|
||||||
|
|
||||||
To avoid the spaces, add square brackets around them:
|
To avoid the spaces, add square brackets around them:
|
||||||
2[^nd^] and CO[~2~]L
|
2[^and^] and CO[~2~]L
|
||||||
|
|
||||||
###. Insertions and deletions are indicated using -/+ symbols:
|
###. Insertions and deletions are indicated using -/+ symbols:
|
||||||
This is -deleted- text and this is +inserted+ text.
|
This is -deleted- text and this is +inserted+ text.
|
||||||
@ -375,7 +375,7 @@ table(tableclass).
|
|||||||
|a|classy|table|
|
|a|classy|table|
|
||||||
|a|classy|table|
|
|a|classy|table|
|
||||||
|
|
||||||
###. Spanning rows and colums:
|
###. Spanning rows and columns:
|
||||||
A backslash \ is used for a column span:
|
A backslash \ is used for a column span:
|
||||||
|
|
||||||
|\2. spans two cols |
|
|\2. spans two cols |
|
||||||
|
@ -183,7 +183,7 @@ bind a send-prefix
|
|||||||
### Theme
|
### Theme
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
|
||||||
# Statusbar Color Palatte
|
# Statusbar Color Palette
|
||||||
set-option -g status-justify left
|
set-option -g status-justify left
|
||||||
set-option -g status-bg black
|
set-option -g status-bg black
|
||||||
set-option -g status-fg white
|
set-option -g status-fg white
|
||||||
|
@ -486,7 +486,7 @@ int more = 57;
|
|||||||
int* more_pointer = &more; // & = address-of
|
int* more_pointer = &more; // & = address-of
|
||||||
int indirection_demo = more_pointer*; // indirection
|
int indirection_demo = more_pointer*; // indirection
|
||||||
|
|
||||||
// Profiles: affect which Vala features are avaliable and which libraries the
|
// Profiles: affect which Vala features are available and which libraries the
|
||||||
// C-code will use.
|
// C-code will use.
|
||||||
// - gobject (default)
|
// - gobject (default)
|
||||||
// posix
|
// posix
|
||||||
|
@ -27,7 +27,7 @@ specific points in the file, and for fast editing.
|
|||||||
:wq # Save file and quit vim
|
:wq # Save file and quit vim
|
||||||
ZZ # Save file and quit vim
|
ZZ # Save file and quit vim
|
||||||
:q! # Quit vim without saving file
|
:q! # Quit vim without saving file
|
||||||
# ! *forces* :q to execute, hence quiting vim without saving
|
# ! *forces* :q to execute, hence quitting vim without saving
|
||||||
ZQ # Quit vim without saving file
|
ZQ # Quit vim without saving file
|
||||||
:x # Save file(only when the file is modified) and quit vim
|
:x # Save file(only when the file is modified) and quit vim
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ echo 'Hello' | echo 'world!'
|
|||||||
" Putting a comment after a command usually works
|
" Putting a comment after a command usually works
|
||||||
pwd " Displays the current working directory
|
pwd " Displays the current working directory
|
||||||
|
|
||||||
" Except for some commands it does not; use the command delemiter before the
|
" Except for some commands it does not; use the command delimiter before the
|
||||||
" comment (echo assumes that the quotation mark begins a string)
|
" comment (echo assumes that the quotation mark begins a string)
|
||||||
echo 'Hello world!' | " Displays a message
|
echo 'Hello world!' | " Displays a message
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ echo v:false | " Evaluates to 0 or the string 'v:false'
|
|||||||
" Boolean values can result from comparison of two objects.
|
" Boolean values can result from comparison of two objects.
|
||||||
|
|
||||||
echo x == y | " Equality by value
|
echo x == y | " Equality by value
|
||||||
echo x != y | " Unequality
|
echo x != y | " Inequality
|
||||||
echo x > y | " Greater than
|
echo x > y | " Greater than
|
||||||
echo x >= y | " Greater than or equal
|
echo x >= y | " Greater than or equal
|
||||||
echo x < y | " Smaller than
|
echo x < y | " Smaller than
|
||||||
@ -110,7 +110,7 @@ echo x isnot y | " Instance non-identity (lists and dictionaries)
|
|||||||
" echo 'a' < 'b'. Case sensitivity depends on the setting of 'ignorecase'
|
" echo 'a' < 'b'. Case sensitivity depends on the setting of 'ignorecase'
|
||||||
"
|
"
|
||||||
" Explicit case-sensitivity is specified by appending '#' (match case) or '?'
|
" Explicit case-sensitivity is specified by appending '#' (match case) or '?'
|
||||||
" (ignore case) to the operator. Prefer explicity case sensitivity when writing
|
" (ignore case) to the operator. Prefer explicitly case sensitivity when writing
|
||||||
" portable scripts.
|
" portable scripts.
|
||||||
|
|
||||||
echo 'a' < 'B' | " True or false depending on 'ignorecase'
|
echo 'a' < 'B' | " True or false depending on 'ignorecase'
|
||||||
@ -315,7 +315,7 @@ let s:isNumber = {x -> type(x) == type(0)} | " Local: any name allowed
|
|||||||
" Assign values of list to multiple variables (number of items must match)
|
" Assign values of list to multiple variables (number of items must match)
|
||||||
let [x, y] = [1, 2]
|
let [x, y] = [1, 2]
|
||||||
|
|
||||||
" Assign the remainer to a rest variable (note the semicolon)
|
" Assign the remainder to a rest variable (note the semicolon)
|
||||||
let [mother, father; children] = ['Alice', 'Bob', 'Carol', 'Dennis', 'Emily']
|
let [mother, father; children] = ['Alice', 'Bob', 'Carol', 'Dennis', 'Emily']
|
||||||
|
|
||||||
|
|
||||||
@ -610,7 +610,7 @@ echo exists(':Make') | " Command
|
|||||||
echo exists("#CursorHold") | " Auto-command defined for event
|
echo exists("#CursorHold") | " Auto-command defined for event
|
||||||
echo exists("#BufReadPre#*.gz") | " Event and pattern
|
echo exists("#BufReadPre#*.gz") | " Event and pattern
|
||||||
echo exists("#filetypeindent") | " Auto-command group
|
echo exists("#filetypeindent") | " Auto-command group
|
||||||
echo exists("##ColorScheme") | " Auto-commnand supported for event
|
echo exists("##ColorScheme") | " Auto-command supported for event
|
||||||
|
|
||||||
" Various dynamic values (see |expand()|)
|
" Various dynamic values (see |expand()|)
|
||||||
echo expand('%') | " Current file name
|
echo expand('%') | " Current file name
|
||||||
|
@ -181,7 +181,7 @@ def _changeTaskStatus( \
|
|||||||
_status: uint256, \
|
_status: uint256, \
|
||||||
):
|
):
|
||||||
# backslashes (\) allow for multi-line code
|
# backslashes (\) allow for multi-line code
|
||||||
# Natspec comments are particularly helpful for documentation and readibility
|
# Natspec comments are particularly helpful for documentation and readability
|
||||||
# Natspec can be included using familiar Pythonic docstring syntax
|
# Natspec can be included using familiar Pythonic docstring syntax
|
||||||
"""
|
"""
|
||||||
@notice
|
@notice
|
||||||
@ -429,16 +429,16 @@ struct Struct:
|
|||||||
owner: address
|
owner: address
|
||||||
_balance: uint256 # balance is a reserved keyword, is a member for addresses
|
_balance: uint256 # balance is a reserved keyword, is a member for addresses
|
||||||
|
|
||||||
exampleStuct: Struct
|
exampleStruct: Struct
|
||||||
|
|
||||||
@public
|
@public
|
||||||
def foo() -> uint256:
|
def foo() -> uint256:
|
||||||
self.exampleStuct = Struct({owner: msg.sender, _balance: 5})
|
self.exampleStruct = Struct({owner: msg.sender, _balance: 5})
|
||||||
self.exampleStuct._balance = 10
|
self.exampleStruct._balance = 10
|
||||||
self.exampleStuct._balance = 5 # set to new value
|
self.exampleStruct._balance = 5 # set to new value
|
||||||
clear(self.exampleStuct._balance)
|
clear(self.exampleStruct._balance)
|
||||||
clear(self.exampleStuct)
|
clear(self.exampleStruct)
|
||||||
return self.exampleStuct._balance
|
return self.exampleStruct._balance
|
||||||
|
|
||||||
|
|
||||||
# Data locations: Memory vs. storage vs. calldata - all complex types (arrays,
|
# Data locations: Memory vs. storage vs. calldata - all complex types (arrays,
|
||||||
@ -510,7 +510,7 @@ def increment(x: uint256, y: uint256) -> (uint256, uint256):
|
|||||||
y += 1
|
y += 1
|
||||||
return (x, y)
|
return (x, y)
|
||||||
|
|
||||||
# Call previous functon
|
# Call previous function
|
||||||
@public
|
@public
|
||||||
@constant
|
@constant
|
||||||
def willCall() -> (uint256, uint256):
|
def willCall() -> (uint256, uint256):
|
||||||
@ -679,7 +679,7 @@ sha3(concat("ab", "cd")) # returns bytes32
|
|||||||
|
|
||||||
# Step 1. Commit
|
# Step 1. Commit
|
||||||
# Place a commitment by sending output of `sha3()`
|
# Place a commitment by sending output of `sha3()`
|
||||||
sha3("a secret"); # btyes32 commit
|
sha3("a secret"); # bytes32 commit
|
||||||
sha3(concat("secret", "other secret", "salt")); # commit multiple things
|
sha3(concat("secret", "other secret", "salt")); # commit multiple things
|
||||||
# The `sha3()` calculation should occur off-chain, only the bytes32
|
# The `sha3()` calculation should occur off-chain, only the bytes32
|
||||||
# output should be inputted into some `commit()` function
|
# output should be inputted into some `commit()` function
|
||||||
|
@ -204,7 +204,7 @@ python_complex_number: !!python/complex 1+2j
|
|||||||
# Strings and numbers aren't the only scalars that YAML can understand.
|
# Strings and numbers aren't the only scalars that YAML can understand.
|
||||||
# ISO-formatted date and datetime literals are also parsed.
|
# ISO-formatted date and datetime literals are also parsed.
|
||||||
datetime_canonical: 2001-12-15T02:59:43.1Z
|
datetime_canonical: 2001-12-15T02:59:43.1Z
|
||||||
datetime_space_seperated_with_time_zone: 2001-12-14 21:59:43.10 -5
|
datetime_space_separated_with_time_zone: 2001-12-14 21:59:43.10 -5
|
||||||
date_implicit: 2002-12-14
|
date_implicit: 2002-12-14
|
||||||
date_explicit: !!timestamp 2002-12-14
|
date_explicit: !!timestamp 2002-12-14
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ pub fn main() void {
|
|||||||
### Booleans, integers and float.
|
### Booleans, integers and float.
|
||||||
```zig
|
```zig
|
||||||
// Booleans.
|
// Booleans.
|
||||||
// Keywords are prefered to operators for boolean operations.
|
// Keywords are preferred to operators for boolean operations.
|
||||||
print("{}\n{}\n{}\n", .{
|
print("{}\n{}\n{}\n", .{
|
||||||
true and false,
|
true and false,
|
||||||
true or false,
|
true or false,
|
||||||
@ -138,7 +138,7 @@ var some_integers: [10]i32 = undefined;
|
|||||||
|
|
||||||
some_integers[0] = 30; // first element of the array is now 30
|
some_integers[0] = 30; // first element of the array is now 30
|
||||||
|
|
||||||
var x = some_integers[0]; // "x" now equals to 30, its type is infered.
|
var x = some_integers[0]; // "x" now equals to 30, its type is inferred.
|
||||||
var y = some_integers[1]; // Second element of the array isn't defined.
|
var y = some_integers[1]; // Second element of the array isn't defined.
|
||||||
// "y" got a stack garbage value (no runtime error).
|
// "y" got a stack garbage value (no runtime error).
|
||||||
|
|
||||||
@ -707,8 +707,8 @@ However, here are some examples, to get an idea of what you can expect:
|
|||||||
Use a fixed buffer to get its memory, don't ask memory to the kernel.
|
Use a fixed buffer to get its memory, don't ask memory to the kernel.
|
||||||
Very simple, limited and wasteful (can't deallocate), but very fast.
|
Very simple, limited and wasteful (can't deallocate), but very fast.
|
||||||
- ArenaAllocator.
|
- ArenaAllocator.
|
||||||
Allow to free all allocted memory at once.
|
Allow to free all allocated memory at once.
|
||||||
To use in combinaison with another allocator.
|
To use in combinations with another allocator.
|
||||||
Very simple way of avoiding leaks.
|
Very simple way of avoiding leaks.
|
||||||
|
|
||||||
A first example.
|
A first example.
|
||||||
@ -825,7 +825,7 @@ fn arena_allocator_fn() !void {
|
|||||||
|
|
||||||
|
|
||||||
// Combining the general purpose and arena allocators. Both are very useful,
|
// Combining the general purpose and arena allocators. Both are very useful,
|
||||||
// and their combinaison should be in everyone's favorite cookbook.
|
// and their combinations should be in everyone's favorite cookbook.
|
||||||
fn gpa_arena_allocator_fn() !void {
|
fn gpa_arena_allocator_fn() !void {
|
||||||
const config = .{.safety = true};
|
const config = .{.safety = true};
|
||||||
var gpa = std.heap.GeneralPurposeAllocator(config){};
|
var gpa = std.heap.GeneralPurposeAllocator(config){};
|
||||||
@ -925,7 +925,7 @@ test "returns true" {
|
|||||||
The compiler has special functions called "built-ins", starting with an "@".
|
The compiler has special functions called "built-ins", starting with an "@".
|
||||||
There are more than a hundred built-ins, allowing very low-level stuff:
|
There are more than a hundred built-ins, allowing very low-level stuff:
|
||||||
- compile-time errors, logging, verifications
|
- compile-time errors, logging, verifications
|
||||||
- type coercion and convertion, even in an unsafe way
|
- type coercion and conversion, even in an unsafe way
|
||||||
- alignment management
|
- alignment management
|
||||||
- memory tricks (such as getting the byte offset of a field in a struct)
|
- memory tricks (such as getting the byte offset of a field in a struct)
|
||||||
- calling functions at compile-time
|
- calling functions at compile-time
|
||||||
@ -956,7 +956,7 @@ if (@enumToInt(Value.blah) == 2) { ... }
|
|||||||
Unions cannot be reinterpreted (in an union with an integer and a float, one cannot take a value for another by accident).
|
Unions cannot be reinterpreted (in an union with an integer and a float, one cannot take a value for another by accident).
|
||||||
Etc.
|
Etc.
|
||||||
- Removing most of the C undefined behaviors (UBs), and when the compiler encounters one, it stops.
|
- Removing most of the C undefined behaviors (UBs), and when the compiler encounters one, it stops.
|
||||||
- Slice and Array structures are prefered to pointers.
|
- Slice and Array structures are preferred to pointers.
|
||||||
Types enforced by the compiler are less prone to errors than pointer manipulations.
|
Types enforced by the compiler are less prone to errors than pointer manipulations.
|
||||||
- Numerical overflows produce an error, unless explicitly accepted using wrapping operators.
|
- Numerical overflows produce an error, unless explicitly accepted using wrapping operators.
|
||||||
- Try and catch mechanism.
|
- Try and catch mechanism.
|
||||||
@ -964,7 +964,7 @@ if (@enumToInt(Value.blah) == 2) { ... }
|
|||||||
- Unused variables are considered as errors by the compiler.
|
- Unused variables are considered as errors by the compiler.
|
||||||
- Many pointer types exist in order to represent what is pointed.
|
- Many pointer types exist in order to represent what is pointed.
|
||||||
Example: is this a single value or an array, is the length known, etc.
|
Example: is this a single value or an array, is the length known, etc.
|
||||||
- Structures need a value for their attributes, and it still is possible to give an undefined value (stack garbage), but at least it is explicitely undefined.
|
- Structures need a value for their attributes, and it still is possible to give an undefined value (stack garbage), but at least it is explicitly undefined.
|
||||||
|
|
||||||
|
|
||||||
## Further Reading
|
## Further Reading
|
||||||
|
Loading…
Reference in New Issue
Block a user