summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--git.html.markdown4
-rw-r--r--jsonnet.html.markdown139
-rw-r--r--matlab.html.markdown2
-rw-r--r--nl-nl/json-nl.html.markdown13
-rw-r--r--rst.html.markdown6
-rw-r--r--set-theory.html.markdown162
-rw-r--r--smalltalk.html.markdown2
7 files changed, 316 insertions, 12 deletions
diff --git a/git.html.markdown b/git.html.markdown
index aa96c90a..a40ef01b 100644
--- a/git.html.markdown
+++ b/git.html.markdown
@@ -82,12 +82,12 @@ pushed to other repositories, or not!
### Branch
A branch is essentially a pointer to the last commit you made. As you go on
-committing, this pointer will automatically update to point the latest commit.
+committing, this pointer will automatically update to point to the latest commit.
### Tag
A tag is a mark on specific point in history. Typically people use this
-functionality to mark release points (v1.0, and so on)
+functionality to mark release points (v1.0, and so on).
### HEAD and head (component of .git dir)
diff --git a/jsonnet.html.markdown b/jsonnet.html.markdown
new file mode 100644
index 00000000..175642d4
--- /dev/null
+++ b/jsonnet.html.markdown
@@ -0,0 +1,139 @@
+---
+language: jsonnet
+filename: learnjsonnet.jsonnet
+contributors:
+ - ["Huan Wang", "https://github.com/fredwangwang"]
+---
+
+Jsonnet is a powerful templating language for JSON. Any valid JSON
+document is a valid Jsonnet object. For an interactive demo/tutorial,
+click [here](https://jsonnet.org/learning/tutorial.html)
+
+```python
+// single line comment
+
+/*
+ multiline comment
+*/
+
+// as well as python style comment
+
+# define a variable.
+# Variables have no effect in the generated JSON without being used.
+local num1 = 1;
+local num2 = 1 + 1;
+local num3 = 5 - 2;
+local num4 = 9 % 5;
+local num5 = 10 / 2.0;
+# jsonnet is a lazy language, if a variable is not used, it is not evaluated.
+local num_runtime_error = 1 / 0;
+
+# fields are valid identifiers without quotes
+local obj1 = { a: 'letter a', B: 'letter B' };
+
+local arr1 = ['a', 'b', 'c'];
+
+# string literals use " or '.
+local str1 = 'a' + 'B';
+# multiline text literal in between |||
+# Each line must start with a white space.
+local str_multiline = |||
+ this is a
+ multiline string
+|||;
+# Python-compatible string formatting is available via %
+# When combined with ||| this can be used for templating text files.
+local str_templating = |||
+ %(f1)0.3f
+||| % { f1: 1.2345678 };
+assert str_templating == '1.235\n';
+
+# if b then e else e. The else branch is optional and defaults to null
+local var1 = if 3 < 2 then "YES";
+assert var1 == null;
+
+local obj2 = {
+ # variable defined inside the object ends with ','
+ local var_in_obj = 0,
+
+ local vowels = ['a', 'e', 'i', 'o', 'u'],
+ local numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
+
+ # [num] to look up an array element
+ first_vowel: vowels[0],
+ # can also slice the array like in Python
+ even_numbers: numbers[1::2],
+
+ # python-style list and object comprehensions are also supported
+ double_numbers: [x * 2 for x in numbers],
+ even_numbers_map: {
+ # [ ] syntax in field name is to compute the field name dynamically
+ [x + '_is_even']: true for x in numbers if x % 2 == 0
+ },
+
+ nested: {
+ nested_field1: 'some-value',
+ # self refers to the current object
+ # ["field-name"] or .field-name can be used to look up a field
+ nested_field2: self.nested_field1,
+ nested_field3: self.nested_field1,
+ # $ refers to outer-most object
+ nested_field4: $.first_vowel,
+
+ assert self.nested_field1 == self.nested_field2,
+ assert self.nested_field1 == self.nested_field3,
+ },
+
+ special_field: 'EVERYTHING FEELS BAD',
+};
+
+local obj3 = {
+ local var_in_obj = 1.234,
+ local var_in_obj2 = { a: { b: 'c' } },
+
+ concat_array: [1, 2, 3] + [4],
+ # strings can be concat with +,
+ # which implicitly converts one operand to string if needed.
+ concat_string: '123' + 4,
+
+ # == tests deep equality
+ equals: { a: { b: 'c', d: {} } } == var_in_obj2,
+
+ special_field: 'this feels good',
+};
+
+# objects can be merged with + where the right-hand side wins field conflicts
+local obj4 = obj2 + obj3;
+assert obj4.special_field == 'this feels good';
+
+# define a function
+# functions have positional parameters, named parameters, and default arguments
+local my_function(x, y, z=1) = x + y - z;
+local num6 = my_function(7, 8, 9);
+local num7 = my_function(8, z=10, y=9);
+local num8 = my_function(4, 5);
+# inline anonymous function
+local num9 = (function(x) x * x)(3);
+
+local obj5 = {
+ # define a method
+ # fields defined with :: are hidden, which does not apper in generated JSON
+ # function cannot be serialized so need to be hidden
+ # if the object is used in the generated JSON.
+ is_odd(x):: x % 2 == 1,
+};
+assert obj5 == {};
+
+# a jsonnet doucment have to evaluate to something
+# be it an object, list, number or just string literal
+"FIN"
+
+```
+
+## Further Reading
+There are a few but important concepts that are not touched in this exmaple, including:
+
+- 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)
+- In depth example of OOP aspect of Jsonnet: [Object-Orientation](https://jsonnet.org/learning/tutorial.html#Object-Orientation)
+- Useful standard library: [Stdlib](https://jsonnet.org/ref/stdlib.html)
diff --git a/matlab.html.markdown b/matlab.html.markdown
index 5790bcc6..4ca31857 100644
--- a/matlab.html.markdown
+++ b/matlab.html.markdown
@@ -234,7 +234,7 @@ A' % Concise version of complex transpose
% On their own, the arithmetic operators act on whole matrices. When preceded
% by a period, they act on each element instead. For example:
A * B % Matrix multiplication
-A .* B % Multiple each element in A by its corresponding element in B
+A .* B % Multiply each element in A by its corresponding element in B
% There are several pairs of functions, where one acts on each element, and
% the other (whose name ends in m) acts on the whole matrix.
diff --git a/nl-nl/json-nl.html.markdown b/nl-nl/json-nl.html.markdown
index 906112ff..d243802d 100644
--- a/nl-nl/json-nl.html.markdown
+++ b/nl-nl/json-nl.html.markdown
@@ -5,26 +5,27 @@ contributors:
- ["Anna Harren", "https://github.com/iirelu"]
- ["Marco Scannadinari", "https://github.com/marcoms"]
- ["himanshu", "https://github.com/himanshu81494"]
+ - ["Maarten Jacobs", "https://github.com/maartenJacobs"]
translators:
- ["Niels van Velzen", "https://nielsvanvelzen.me"]
lang: nl-nl
---
-Gezien JSON een zeer eenvouding formaat heeft zal dit een van de simpelste
+Gezien JSON een zeer eenvouding formaat heeft zal dit één van de simpelste
Learn X in Y Minutes ooit zijn.
-JSON heeft volgens de specificaties geen commentaar, ondanks dat hebben de
+JSON heeft volgens de specificaties geen commentaar. Ondanks dat hebben de
meeste parsers support voor C-stijl (`//`, `/* */`) commentaar.
Sommige parsers staan zelfs trailing komma's toe.
-(Een komma na het laatste element in een array of ahter de laatste eigenshap van een object).
-Het is wel beter om dit soort dingen te vermijden omdat het niet overal zal werken.
+(Een komma na het laatste element in een array of achter de laatste eigenschap van een object).
+Het is wel beter om dit soort dingen te vermijden omdat het niet in elke parser zal werken.
In het voorbeeld zal alleen 100% geldige JSON gebruikt worden.
Data types gesupport door JSON zijn: nummers, strings, booleans, arrays, objecten en null.
Gesupporte browsers zijn: Firefox(Mozilla) 3.5, Internet Explorer 8, Chrome, Opera 10, Safari 4.
-De extensie voor JSON bestanden is ".json". De MIME type is "application/json"
-Enkele nadelen van JSON zijn het gebrek een type definities en een manier van DTD.
+De extensie voor JSON bestanden is ".json". De MIME type is "application/json".
+Enkele nadelen van JSON zijn het gebrek aan type definities en een manier van DTD.
```json
{
diff --git a/rst.html.markdown b/rst.html.markdown
index 2423622e..bdc73c7a 100644
--- a/rst.html.markdown
+++ b/rst.html.markdown
@@ -49,9 +49,11 @@ Subtitles with dashes
You can put text in *italic* or in **bold**, you can "mark" text as code with double backquote ``print()``.
+Special characters can be escaped using a backslash, e.g. \\ or \*.
+
Lists are similar to Markdown, but a little more involved.
-Remember to line up list symbols (like - or *) with the left edge of the previous text block, and remember to use blank lines to separate new lists from parent lists:
+Remember to line up list symbols (like - or \*) with the left edge of the previous text block, and remember to use blank lines to separate new lists from parent lists:
- First item
- Second item
@@ -86,7 +88,7 @@ There are multiple ways to make links:
- By typing a full comprehensible URL : https://github.com/ (will be automatically converted to a link)
- By making a more Markdown-like link: `Github <https://github.com/>`_ .
-.. _Github https://github.com/
+.. _Github: https://github.com/
```
diff --git a/set-theory.html.markdown b/set-theory.html.markdown
new file mode 100644
index 00000000..c6bc39c5
--- /dev/null
+++ b/set-theory.html.markdown
@@ -0,0 +1,162 @@
+---
+category: Algorithms & Data Structures
+name: Set theory
+contributors:
+---
+The set theory is a study for sets, their operations, and their properties. It is the basis of the whole mathematical system.
+
+* A set is a collection of definite distinct items.
+
+## Basic operators
+These operators don't require a lot of text to describe.
+
+* `∨` means or.
+* `∧` means and.
+* `,` separates the filters that determine the items in the set.
+
+## A brief history of the set theory
+### Naive set theory
+* Cantor invented the naive set theory.
+* It has lots of paradoxes and initiated the third mathematical crisis.
+
+### Axiomatic set theory
+* It uses axioms to define the set theory.
+* It prevents paradoxes from happening.
+
+## Built-in sets
+* `∅`, the set of no items.
+* `N`, the set of all natural numbers. `{0,1,2,3,…}`
+* `Z`, the set of all integers. `{…,-2,-1,0,1,2,…}`
+* `Q`, the set of all rational numbers.
+* `R`, the set of all real numbers.
+
+### The empty set
+* The set containing no items is called the empty set. Representation: `∅`
+* The empty set can be described as `∅ = {x|x ≠ x}`
+* The empty set is always unique.
+* The empty set is the subset of all sets.
+
+```
+A = {x|x∈N,x < 0}
+A = ∅
+∅ = {} (Sometimes)
+
+|∅| = 0
+|{∅}| = 1
+```
+
+## Representing sets
+### Enumeration
+* List all items of the set, e.g. `A = {a,b,c,d}`
+* List some of the items of the set. Ignored items are represented with `…`. E.g. `B = {2,4,6,8,10,…}`
+
+### Description
+* Describes the features of all items in the set. Syntax: `{body|condtion}`
+
+```
+A = {x|x is a vowel}
+B = {x|x ∈ N, x < 10l}
+C = {x|x = 2k, k ∈ N}
+C = {2x|x ∈ N}
+```
+
+## Relations between sets
+### Belongs to
+* If the value `a` is one of the items of the set `A`, `a` belongs to `A`. Representation: `a∈A`
+* If the value `a` is not one of the items of the set `A`, `a` does not belong to `A`. Representation: `a∉A`
+
+### Equals
+* If all items in a set are exactly the same to another set, they are equal. Representation: `a=b`
+* Items in a set are not order sensitive. `{1,2,3,4}={2,3,1,4}`
+* Items in a set are unique. `{1,2,2,3,4,3,4,2}={1,2,3,4}`
+* Two sets are equal if and only if all of their items are exactly equal to each other. Representation: `A=B`. Otherwise, they are not equal. Representation: `A≠B`.
+* `A=B` if `A ⊆ B` and `B ⊆ A`
+
+### Belongs to
+* If the set A contains an item `x`, `x` belongs to A (`x∈A`).
+* Otherwise, `x` does not belong to A (`x∉A`).
+
+### Subsets
+* If all items in a set `B` are items of set `A`, we say that `B` is a subset of `A` (`B⊆A`).
+* If B is not a subset of A, the representation is `B⊈A`.
+
+### Proper subsets
+* If `B ⊆ A` and `B ≠ A`, B is a proper subset of A (`B ⊂ A`). Otherwise, B is not a proper subset of A (`B ⊄ A`).
+
+## Set operations
+### Base number
+* The number of items in a set is called the base number of that set. Representation: `|A|`
+* If the base number of the set is finite, this set is a finite set.
+* If the base number of the set is infinite, this set is an infinite set.
+
+```
+A = {A,B,C}
+|A| = 3
+B = {a,{b,c}}
+|B| = 2
+|∅| = 0 (it has no items)
+```
+
+### Powerset
+* Let `A` be any set. The set that contains all possible subsets of `A` is called a powerset (written as `P(A)`).
+
+```
+P(A) = {x|x ⊆ A}
+
+|A| = N, |P(A)| = 2^N
+```
+
+## Set operations among two sets
+### Union
+Given two sets `A` and `B`, the union of the two sets are the items that appear in either `A` or `B`, written as `A ∪ B`.
+
+```
+A ∪ B = {x|x∈A∨x∈B}
+```
+
+### Intersection
+Given two sets `A` and `B`, the intersection of the two sets are the items that appear in both `A` and `B`, written as `A ∩ B`.
+
+```
+A ∩ B = {x|x∈A,x∈B}
+```
+
+### Difference
+Given two sets `A` and `B`, the set difference of `A` with `B` is every item in `A` that does not belong to `B`.
+
+```
+A \ B = {x|x∈A,x∉B}
+```
+
+### Symmetrical difference
+Given two sets `A` and `B`, the symmetrical difference is all items among `A` and `B` that doesn't appear in their intersections.
+
+```
+A △ B = {x|(x∈A∧x∉B)∨(x∈B∧x∉A)}
+
+A △ B = (A \ B) ∪ (B \ A)
+```
+
+### Cartesian product
+Given two sets `A` and `B`, the cartesian product between `A` and `B` consists of a set containing all combinations of items of `A` and `B`.
+
+```
+A × B = { {x, y} | x ∈ A, y ∈ B }
+```
+
+## "Generalized" operations
+### General union
+Better known as "flattening" of a set of sets.
+
+```
+∪A = {x|X∈A,x∈X}
+∪A={a,b,c,d,e,f}
+∪B={a}
+∪C=a∪{c,d}
+```
+
+### General intersection
+
+```
+∩ A = A1 ∩ A2 ∩ … ∩ An
+```
diff --git a/smalltalk.html.markdown b/smalltalk.html.markdown
index d6d369cc..58dccae4 100644
--- a/smalltalk.html.markdown
+++ b/smalltalk.html.markdown
@@ -388,7 +388,7 @@ y := $A max: $B.
```smalltalk
| b x y |
x := #Hello. "symbol assignment"
-y := 'String', 'Concatenation'. "symbol concatenation (result is string)"
+y := #Symbol, #Concatenation. "symbol concatenation (result is string)"
b := x isEmpty. "test if symbol is empty"
y := x size. "string size"
y := x at: 2. "char at location"