From 62c6f95e9d161967cfffa43a3f9b3f8d73e2ef5f Mon Sep 17 00:00:00 2001 From: Sean Corrales Date: Mon, 5 Oct 2015 10:51:27 -0500 Subject: Initial work on learn Sass file. --- sass.html.markdown | 234 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 234 insertions(+) create mode 100644 sass.html.markdown diff --git a/sass.html.markdown b/sass.html.markdown new file mode 100644 index 00000000..35af1e67 --- /dev/null +++ b/sass.html.markdown @@ -0,0 +1,234 @@ +--- +language: sass +contributors: + - ["Sean Corrales", "https://github.com/droidenator"] +filename: learnsass.scss +--- + +Sass is a CSS pre-processor. It adds several features that plain +CSS lacks such as variables, mixins, basic math, and inheritance. + +Initially, Sass was written using spacing and indention instead +of brackets and semi-colons; these files use the extension '.sass'. +Sass was later revised to use brackets and semi-colons and become +a superset of CSS3. This new version uses the extension ".scss". +Using ".scss" means that any valid CSS3 file can be converted to +Sass by simply changing the file extension to '.scss'. + +If you're already familiar with CSS3, you'll be able to pick up Sass +relatively quickly. It does not provide any new styling options but rather +the tools to write your CSS more efficiently and make maintenance much +easier. + +Sass files must be compiled into CSS. You can use any number of commandline +tools to compile Sass into CSS. Many IDEs also offer Sass compilation, as well. + + +```sass +/* Like CSS, Sass uses slash-asterisk to denote comments */ + +/* #################### + ## VARIABLES + #################### */ + +/* Sass allows you to define variables that can be used throughout + your stylesheets. Variables are defined by placing a '$' in front + of a string. Many users like to keep their variables in a single file */ +$primary-color: #0000ff; +$headline-size: 24px; + +/* Variables can be used in any CSS declaration. This allows you to change + a single value in one place. */ +a { + color: $primary-color; +} + +h1 { + color: $primary-color; + font-size: $headline-size; +} + +/* After compiling the Sass files into CSS, you'll have the following code + in your generated CSS file */ + +a { + color: #0000ff; +} + +h1 { + color: #0000ff; + font-size: 24px; +} + +/* #################### + ## NESTING + #################### */ + +/* Nesting allows you to easily group together statements and nest them + in a way that indicates their hierarchy */ +article { + font-size: 14px; + + a { + text-decoration: underline; + } + + ul { + list-style-type: disc; + + li { + text-indent: 3em; + } + } + + pre, img { + display: inline-block; + float: left; + } +} + +/* The above will compile into the following CSS */ +article { + font-size: 14px; +} + +article a { + text-decoration: underline; +} + +article ul { + list-style-type: disc; +} + +article ul li { + text-indent: 3em; +} + +article pre, +article img { + display: inline-block; + float: left; +} + +/* It is recommended to not nest too deeply as this can cause issues with + specificity and make your CSS harder to work with and maintain. Best practices + recommend going no more than 3 levels deep when nesting. */ + +/* #################### + ## MIXINS + #################### */ +/* Mixins allow you to define reusable chunks of CSS. They can take one or more + arguments to allow you to make reusable pieces of styling. */ +@mixin form-button($color, $size, $border-radius) { + color: $color; + font-size: $size; + border-radius: $border-radius; +} + +/* Mixins are invoked within a CSS declaration. */ +.user-form .submit { + @include form-button(#0000ff, 16px, 4px); + margin: 10px; +} + +/* The above mixin will compile into the following css */ +.user-form .submit { + color: #0000ff; + font-size: 16px; + border-radius: 4px; + margin: 10px; +} + +/* #################### + ## EXTEND/INHERITANCE + #################### */ + +/* #################### + ## MATH OPERATIONS + #################### */ + +``` + +## Usage + +Save any CSS you want in a file with extension `.css`. + +```xml + + + + + + + +
+
+ +``` + +## Precedence + +As you noticed an element may be targetted by more than one selector. +and may have a property set on it in more than one. +In these cases, one of the rules takes precedence over others. + +Given the following CSS: + +```css +/*A*/ +p.class1[attr='value'] + +/*B*/ +p.class1 {} + +/*C*/ +p.class2 {} + +/*D*/ +p {} + +/*E*/ +p { property: value !important; } + +``` + +and the following markup: + +```xml +

+

+``` + +The precedence of style is as followed: +Remember, the precedence is for each **property**, not for the entire block. + +* `E` has the highest precedence because of the keyword `!important`. + It is recommended to avoid this unless it is strictly necessary to use. +* `F` is next, because it is inline style. +* `A` is next, because it is more "specific" than anything else. + more specific = more specifiers. here 3 specifiers: 1 tagname `p` + + class name `class1` + 1 attribute `attr='value'` +* `C` is next. although it has the same specificness as `B` + but it appears last. +* Then is `B` +* and lastly is `D`. + +## Compatibility + +Most of the features in CSS2 (and gradually in CSS3) are compatible across +all browsers and devices. But it's always vital to have in mind the compatibility +of what you use in CSS with your target browsers. + +[QuirksMode CSS](http://www.quirksmode.org/css/) is one of the best sources for this. + +To run a quick compatibility check, [CanIUse](http://caniuse.com) is a great resource. + +## Further Reading + +* [Understanding Style Precedence in CSS: Specificity, Inheritance, and the Cascade](http://www.vanseodesign.com/css/css-specificity-inheritance-cascaade/) +* [QuirksMode CSS](http://www.quirksmode.org/css/) +* [Z-Index - The stacking context](https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Understanding_z_index/The_stacking_context) -- cgit v1.2.3 From 1bc457737577a01af47a8be5879904dd23bcc410 Mon Sep 17 00:00:00 2001 From: Sean Corrales Date: Mon, 5 Oct 2015 13:52:53 -0500 Subject: Finishing up documentation for additional Sass functionality. Removing CSS specific instructions from usage, compatibility, and further reading sections. --- sass.html.markdown | 300 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 232 insertions(+), 68 deletions(-) diff --git a/sass.html.markdown b/sass.html.markdown index 35af1e67..d1e0721f 100644 --- a/sass.html.markdown +++ b/sass.html.markdown @@ -25,7 +25,11 @@ tools to compile Sass into CSS. Many IDEs also offer Sass compilation, as well. ```sass -/* Like CSS, Sass uses slash-asterisk to denote comments */ +/* Like CSS, Sass uses slash-asterisk to denote comments. Slash-asterisk comments + can span multiple lines. These comments will appear in your compiled CSS */ + +// Sass also supports single line comments that use double slashes. These comments will +// not be rendered in your compiled CSS /* #################### ## VARIABLES @@ -113,12 +117,52 @@ article img { /* It is recommended to not nest too deeply as this can cause issues with specificity and make your CSS harder to work with and maintain. Best practices recommend going no more than 3 levels deep when nesting. */ + +/* ############################### + ## REFERENCE PARENT SELECTORS + ############################### */ + +/* Reference parent selectors are used when you're nesting statements and want to + reference the parent selector from within the nested statements. You can reference + a parent using & */ + +a { + text-decoration: none; + color: #ff0000; + + &:hover { + text-decoration: underline; + } + + body.noLinks & { + display: none; + } +} + +/* The above Sass will compile into the CSS below */ + +a { + text-decoration: none; + color: #ff0000; +} + +a:hover { + text-decoration: underline; +} + +body.noLinks a { + display: none; +} + /* #################### ## MIXINS #################### */ + /* Mixins allow you to define reusable chunks of CSS. They can take one or more - arguments to allow you to make reusable pieces of styling. */ + arguments to allow you to make reusable pieces of styling. Mixins can also + be very helpful when dealing with vendor prefixes. */ + @mixin form-button($color, $size, $border-radius) { color: $color; font-size: $size; @@ -126,109 +170,229 @@ article img { } /* Mixins are invoked within a CSS declaration. */ + .user-form .submit { @include form-button(#0000ff, 16px, 4px); - margin: 10px; } /* The above mixin will compile into the following css */ + .user-form .submit { color: #0000ff; font-size: 16px; border-radius: 4px; - margin: 10px; } /* #################### - ## EXTEND/INHERITANCE + ## FUNCTIONS #################### */ - + +/* Sass provides functions that can be used to accomplish a variety of tasks. Consider the following */ + +body { + width: round(10.25px); +} + +.footer { + background-color: fade_out(#000000, 0.25) +} + +/* The above Sass will compile into the following CSS */ + +body { + width: 10px; +} + +.footer { + background-color: rgba(0, 0, 0, 0.75); +} + +/* You may also define your own functions. Functions are very similar to mixins. When trying to choose between + a function or a mixin, remember that functions are best for returning values while mixins are best for + generating CSS while functions are better for logic that might be used throughout your Sass code. The + examples in the Math Operators' section are ideal candidates for becoming a reusable function. */ + +/* This function will take a target size and the parent size and calculate and return the percentage */ + +@function calculate-percentage($target-size, $parent-size) { + @return $target-size / $parent-size * 100%; +} + +/* Functions can be invoked by using their name and passing in the required arguments */ + +$main-content: calculate-percentage(600px, 960px); + +.main-content { + width: $main-content; +} + +.sidebar { + width: calculate-percentage(300px, 960px); +} + +/* The above Sass will compile into the following CSS */ + +.main-content { + width: 62.5%; +} + +.sidebar { + width: 31.25%; +} + /* #################### - ## MATH OPERATIONS - #################### */ + ## EXTEND/INHERITANCE + #################### */ -``` +/* Sass allows you to extend an existing CSS statement. This makes it + very easy to write CSS that does not violate DRY principles. Any + CSS statement can be extended */ + +.content-window { + font-size: 14px; + padding: 10px; + color: #000; + border-radius: 4px; +} -## Usage +.message-window { + @extend .content-window; + background-color: #0000ff; +} -Save any CSS you want in a file with extension `.css`. +.notification-window { + @extend .content-window; + background-color: #ff0000; +} -```xml - - +.settings-window { + @extend .content-window; + background-color: #ccc; +} - - +/* The above Sass will be compile into the following CSS */ - -
-
+.content-window, +.message-window, +.notification-window, +.settings-window { + font-size: 14px; + padding: 10px; + color: #000; + border-radius: 4px; +} -``` +.message-window { + background-color: #0000ff; +} + +.notification-window { + background-color: #ff0000; +} + +.settings-window { + background-color: #ccc; +} + +/* Extending a CSS statement is preferable to creating a mixin + because of the way it groups together the classes that all share + the same base styling. If this was done with a mixin, the font-size, + padding, color, and border-radius would be duplicated for each statement + that called the mixin. While it won't affect your workflow, it will + add unnecessary bloat to the files created by the Sass compiler. */ + +/* ######################### + ## PLACEHOLDER SELECTORS + ######################### */ + +/* Placeholders are useful when creating a CSS statement to extend. If you wanted to create + a CSS statement that was exclusively used with @extend, you can do so using a placeholder. + Placeholders begin with a '%' instead of '.' or '#'. Placeholders will not appear in the + compiled CSS. */ + +%content-window { + font-size: 14px; + padding: 10px; + color: #000; + border-radius: 4px; +} + +.message-window { + @extend %content-window; + background-color: #0000ff; +} -## Precedence +/* The above Sass would compile to the following CSS */ -As you noticed an element may be targetted by more than one selector. -and may have a property set on it in more than one. -In these cases, one of the rules takes precedence over others. +.message-window { + font-size: 14px; + padding: 10px; + color: #000; + border-radius: 4px; +} -Given the following CSS: +.message-window { + background-color: #0000ff; +} + +/* #################### + ## MATH OPERATIONS + #################### */ + +/* Sass provides the following operators: +, -, *, /, and %. These can + be useful for calculating values directly in your Sass files instead + of using values that you've already calculated by hand. Below is an example + of a setting up a simple two column design. */ + +$content-area: 960px; +$main-content: 600px; +$sidebar-content: 300px; -```css -/*A*/ -p.class1[attr='value'] +$main-size: $main-content / $content-area * 100%; +$sidebar-size: $sidebar-content / $content-area * 100%; +$gutter: 100% - ($main-size + $sidebar-size); -/*B*/ -p.class1 {} +body { + width: 100%; +} -/*C*/ -p.class2 {} +.main-content { + width: $main-size; +} -/*D*/ -p {} +.sidebar { + width: $sidebar-size; +} -/*E*/ -p { property: value !important; } +.gutter { + width: $gutter; +} -``` +/* The above Sass would compile to the CSS below */ -and the following markup: +body { + width: 100%; +} -```xml -

-

-``` +.main-content { + width: 62.5%; +} -The precedence of style is as followed: -Remember, the precedence is for each **property**, not for the entire block. +.sidebar { + width: 31.25%; +} -* `E` has the highest precedence because of the keyword `!important`. - It is recommended to avoid this unless it is strictly necessary to use. -* `F` is next, because it is inline style. -* `A` is next, because it is more "specific" than anything else. - more specific = more specifiers. here 3 specifiers: 1 tagname `p` + - class name `class1` + 1 attribute `attr='value'` -* `C` is next. although it has the same specificness as `B` - but it appears last. -* Then is `B` -* and lastly is `D`. +.gutter { + width: 6.25%; +} + +``` -## Compatibility +## Usage -Most of the features in CSS2 (and gradually in CSS3) are compatible across -all browsers and devices. But it's always vital to have in mind the compatibility -of what you use in CSS with your target browsers. -[QuirksMode CSS](http://www.quirksmode.org/css/) is one of the best sources for this. -To run a quick compatibility check, [CanIUse](http://caniuse.com) is a great resource. +## Compatibility -## Further Reading -* [Understanding Style Precedence in CSS: Specificity, Inheritance, and the Cascade](http://www.vanseodesign.com/css/css-specificity-inheritance-cascaade/) -* [QuirksMode CSS](http://www.quirksmode.org/css/) -* [Z-Index - The stacking context](https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Understanding_z_index/The_stacking_context) +## Further Reading -- cgit v1.2.3 From 25d5d07dd342dc57831785032b813b3c2b3a5a9e Mon Sep 17 00:00:00 2001 From: Sean Corrales Date: Thu, 8 Oct 2015 15:37:54 -0500 Subject: Updating function instructions. --- sass.html.markdown | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/sass.html.markdown b/sass.html.markdown index d1e0721f..9bc72478 100644 --- a/sass.html.markdown +++ b/sass.html.markdown @@ -188,7 +188,8 @@ body.noLinks a { #################### */ /* Sass provides functions that can be used to accomplish a variety of tasks. Consider the following */ - + +/* Functions can be invoked by using their name and passing in the required arguments */ body { width: round(10.25px); } @@ -207,19 +208,19 @@ body { background-color: rgba(0, 0, 0, 0.75); } -/* You may also define your own functions. Functions are very similar to mixins. When trying to choose between - a function or a mixin, remember that functions are best for returning values while mixins are best for - generating CSS while functions are better for logic that might be used throughout your Sass code. The - examples in the Math Operators' section are ideal candidates for becoming a reusable function. */ - -/* This function will take a target size and the parent size and calculate and return the percentage */ +/* You may also define your own functions. Functions are very similar to mixins. When trying + to choose between a function or a mixin, remember that functions are best for returning + values while mixins are best for generating CSS while functions are better for logic that + might be used throughout your Sass code. The examples in the Math Operators' section are + ideal candidates for becoming a reusable function. */ + +/* This function will take a target size and the parent size and calculate and return + the percentage */ @function calculate-percentage($target-size, $parent-size) { @return $target-size / $parent-size * 100%; } -/* Functions can be invoked by using their name and passing in the required arguments */ - $main-content: calculate-percentage(600px, 960px); .main-content { -- cgit v1.2.3 From e418849d7696bd91a144ccdff451025899ac10e0 Mon Sep 17 00:00:00 2001 From: Zachary Ferguson Date: Fri, 9 Oct 2015 11:52:08 -0400 Subject: [c/en] Added a section for header files. Added a section for header files. Included a discussion of what belongs in a header file and what does not. --- c.html.markdown | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/c.html.markdown b/c.html.markdown index db2ac930..f1201eac 100644 --- a/c.html.markdown +++ b/c.html.markdown @@ -6,7 +6,7 @@ contributors: - ["Árpád Goretity", "http://twitter.com/H2CO3_iOS"] - ["Jakub Trzebiatowski", "http://cbs.stgn.pl"] - ["Marco Scannadinari", "https://marcoms.github.io"] - + - ["Zachary Ferguson", "https://github.io/zfergus2"] --- Ah, C. Still **the** language of modern high-performance computing. @@ -630,6 +630,54 @@ typedef void (*my_fnp_type)(char *); ``` +Header files are an important part of c as they allow for the connection of c +source files and can simplify code and definitions by seperating them into +seperate files. + +Header files are syntaxtically similar to c source files but reside in ".h" +files. They can be included in your c source file by using the precompiler +command #include "example.h", given that example.h exists in the same directory +as the c file. + +```c +/* A safe guard to prevent the header from being defined too many times. This */ +/* happens in the case of circle dependency, the contents of the header is */ +/* already defined. */ +#ifndef EXAMPLE_H /* if EXAMPLE_H is not yet defined. */ +#define EXAMPLE_H /* Define the macro EXAMPLE_H. */ + +/* Other headers can be included in headers and therefore transitively */ +/* included into files that include this header. */ +#include + +/* Like c source files macros can be defined in headers and used in files */ +/* that include this header file. */ +#define EXAMPLE_NAME "Dennis Ritchie" +/* Function macros can also be defined. */ +#define ADD(a, b) (a + b) + +/* Structs and typedefs can be used for consistency between files. */ +typedef struct node +{ + int val; + struct node *next; +} Node; + +/* So can enumerations. */ +enum traffic_light_state {GREEN, YELLOW, RED}; + +/* Function prototypes can also be defined here for use in multiple files, */ +/* but it is bad practice to define the function in the header. Definitions */ +/* should instead be put in a c file. */ +Node createLinkedList(int *vals, int len); + +/* Beyond the above elements, other definitions should be left to a c source */ +/* file. Excessive includeds or definitions should, also not be contained in */ +/* a header file but instead put into separate headers or a c file. */ + +#endif /* End of the if precompiler directive. */ + +``` ## Further Reading Best to find yourself a copy of [K&R, aka "The C Programming Language"](https://en.wikipedia.org/wiki/The_C_Programming_Language) -- cgit v1.2.3 From 622d4485ab9efd265be83d16abbe8cb12da7934c Mon Sep 17 00:00:00 2001 From: Kara Kincaid Date: Sat, 10 Oct 2015 08:20:03 -0400 Subject: [css/en] Added more pseudo-classes and pseudo-elements examples --- css.html.markdown | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/css.html.markdown b/css.html.markdown index 811767e6..4c459f7f 100644 --- a/css.html.markdown +++ b/css.html.markdown @@ -119,6 +119,19 @@ selected:link {} /* or an input element which is focused */ selected:focus {} +/* any element that is the first child of its parent */ +selector:first-child {} + +/* any element that is the last child of its parent */ +selector:last-child {} + +/* Just like pseudo classes, pseudo elements allow you to style certain parts of a document */ + +/* matches a virtual first child of the selected element */ +selector::before {} + +/* matches a virtual last child of the selected element */ +selector::after {} /* #################### ## PROPERTIES -- cgit v1.2.3 From 831911843b0c83afc9742b43c45c27408e68fec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerson=20L=C3=A1zaro?= Date: Sat, 10 Oct 2015 21:37:38 -0500 Subject: [js/es] corrected typo in javascript doc --- es-es/javascript-es.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/es-es/javascript-es.html.markdown b/es-es/javascript-es.html.markdown index 036d7082..d475cf42 100644 --- a/es-es/javascript-es.html.markdown +++ b/es-es/javascript-es.html.markdown @@ -16,7 +16,7 @@ con Java para aplicaciones más complejas. Debido a su integracion estrecha con web y soporte por defecto de los navegadores modernos se ha vuelto mucho más común para front-end que Java. -JavaScript no sólo se limita a los navegadores web, aunque: Node.js, Un proyecto que proporciona un entorno de ejecución independiente para el motor V8 de Google Chrome, se está volviendo más y más popular. +Aunque JavaScript no sólo se limita a los navegadores web: Node.js, Un proyecto que proporciona un entorno de ejecución independiente para el motor V8 de Google Chrome, se está volviendo más y más popular. ¡La retroalimentación es bienvenida! Puedes encontrarme en: [@adambrenecki](https://twitter.com/adambrenecki), o @@ -124,7 +124,7 @@ undefined; // usado para indicar que un valor no está presente actualmente // (aunque undefined es un valor en sí mismo) // false, null, undefined, NaN, 0 y "" es false; todo lo demás es true. -// Note que 0 is false y "0" es true, a pesar de que 0 == "0". +// Note que 0 es false y "0" es true, a pesar de que 0 == "0". // Aunque 0 === "0" sí es false. /////////////////////////////////// -- cgit v1.2.3 From 9ee3a687204cbe6caaa11b9fd28470651a70ae2b Mon Sep 17 00:00:00 2001 From: Ankit Aggarwal Date: Sun, 11 Oct 2015 19:51:43 +0530 Subject: Added input operations in learn Python 2.7 doc --- python.html.markdown | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/python.html.markdown b/python.html.markdown index 6cfb5dca..95146ca8 100644 --- a/python.html.markdown +++ b/python.html.markdown @@ -4,6 +4,7 @@ contributors: - ["Louie Dinh", "http://ldinh.ca"] - ["Amin Bandali", "http://aminbandali.com"] - ["Andre Polykanine", "https://github.com/Oire"] + - ["Ankit Aggarwal", "http://ankitaggarwal.me"] filename: learnpython.py --- @@ -144,6 +145,10 @@ bool("") # => False # Python has a print statement print "I'm Python. Nice to meet you!" +# Simple way to get input data from console +input_string_var = raw_input("Enter some data: ") # Data is stored as a string +input_number_var = input("Enter a number: ") # Data is stored as a number + # No need to declare variables before assigning to them. some_var = 5 # Convention is to use lower_case_with_underscores some_var # => 5 -- cgit v1.2.3 From ed716a3a9534a1c58a3b6d085825a5144bcb9bba Mon Sep 17 00:00:00 2001 From: Elton Viana Date: Mon, 12 Oct 2015 11:10:27 -0300 Subject: Some translation fixes --- pt-br/c-pt.html.markdown | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pt-br/c-pt.html.markdown b/pt-br/c-pt.html.markdown index 451df4f3..f775f8b0 100644 --- a/pt-br/c-pt.html.markdown +++ b/pt-br/c-pt.html.markdown @@ -6,6 +6,7 @@ contributors: - ["Árpád Goretity", "http://twitter.com/H2CO3_iOS"] translators: - ["João Farias", "https://github.com/JoaoGFarias"] + - ["Elton Viana", "https://github.com/eltonvs"] lang: pt-br filename: c-pt.el --- @@ -139,13 +140,13 @@ int main() { int var_length_array[size]; // declara o VLA printf("sizeof array = %zu\n", sizeof var_length_array); - //Uma possível saída para esse programa seria: - // > Entre o tamanho do array:: 10 + // Uma possível saída para esse programa seria: + // > Entre o tamanho do array: 10 // > sizeof array = 40 // String são apenas arrays de caracteres terminados por um - // byte NUL (0x00), representado em string pelo caracter especial '\0'. - // (Não precisamos incluir o byte NUL em literais de string; o compilador + // byte nulo (0x00), representado em string pelo caracter especial '\0'. + // (Não precisamos incluir o byte nulo em literais de string; o compilador // o insere ao final do array para nós.) char uma_string[20] = "Isto é uma string"; // Observe que 'é' não está na tabela ASCII @@ -153,8 +154,8 @@ int main() { // Porém, comentários podem conter acentos printf("%s\n", uma_string); // %s formata a string - printf("%d\n", uma_string[16]); // => 0 - // i.e., byte #17 é 0 (assim como 18, 19, e 20) + printf("%d\n", uma_string[17]); // => 0 + // i.e., byte #18 é 0 (assim como o 19°, 20°, 21°...) // Se temos caracteres entre aspas simples, temos um caracter literal. // Seu tipo é `int`, *não* `char` (por razões históricas). -- cgit v1.2.3 From 253d0d9281c519ed6bceabccef7033e1fad58e01 Mon Sep 17 00:00:00 2001 From: Elton Viana Date: Mon, 12 Oct 2015 11:17:18 -0300 Subject: Added some extra information --- pt-br/c-pt.html.markdown | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pt-br/c-pt.html.markdown b/pt-br/c-pt.html.markdown index f775f8b0..43688724 100644 --- a/pt-br/c-pt.html.markdown +++ b/pt-br/c-pt.html.markdown @@ -221,11 +221,11 @@ int main() { 0 || 1; // => 1 (Ou lógico) 0 || 0; // => 0 - //Expressão condicional ( ? : ) + //Expressão condicional ternária ( ? : ) int a = 5; int b = 10; int z; - z = (a > b) ? a : b; // => 10 "se a > b retorne a, senão retorne b." + z = (a > b) ? a : b; // => 10 "se a > b retorne a, senão retorne b." //Operadores de incremento e decremento: char *s = "iLoveC"; @@ -291,6 +291,8 @@ int main() { for (i = 0; i <= 5; i++) { ; // Use ponto e vírgula para agir como um corpo (declaração nula) } + // Ou + for (i = 0; i <= 5; i++); // Criando branchs com escolhas múltiplas: switch() switch (alguma_expressao_integral) { -- cgit v1.2.3 From 9958252cc3990c930fe11441f456387fe0512ec8 Mon Sep 17 00:00:00 2001 From: Elton Viana Date: Mon, 12 Oct 2015 11:36:45 -0300 Subject: Added "Python para Zumbis" link --- pt-br/python-pt.html.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/pt-br/python-pt.html.markdown b/pt-br/python-pt.html.markdown index 5afd46d0..ac07e1ae 100644 --- a/pt-br/python-pt.html.markdown +++ b/pt-br/python-pt.html.markdown @@ -500,6 +500,7 @@ dir(math) * [The Official Docs](http://docs.python.org/2.6/) * [Hitchhiker's Guide to Python](http://docs.python-guide.org/en/latest/) * [Python Module of the Week](http://pymotw.com/2/) +* [Python para Zumbis](http://pycursos.com/python-para-zumbis/) ### Livros impressos -- cgit v1.2.3 From a62d99a393b583ffe480c057aa1578d0b137d775 Mon Sep 17 00:00:00 2001 From: Elton Viana Date: Mon, 12 Oct 2015 11:38:01 -0300 Subject: Unset --- pt-br/python-pt.html.markdown | 1 - 1 file changed, 1 deletion(-) diff --git a/pt-br/python-pt.html.markdown b/pt-br/python-pt.html.markdown index ac07e1ae..5afd46d0 100644 --- a/pt-br/python-pt.html.markdown +++ b/pt-br/python-pt.html.markdown @@ -500,7 +500,6 @@ dir(math) * [The Official Docs](http://docs.python.org/2.6/) * [Hitchhiker's Guide to Python](http://docs.python-guide.org/en/latest/) * [Python Module of the Week](http://pymotw.com/2/) -* [Python para Zumbis](http://pycursos.com/python-para-zumbis/) ### Livros impressos -- cgit v1.2.3 From 9c267f14736f813c5f420d50d93f344faec261cb Mon Sep 17 00:00:00 2001 From: Sean Corrales Date: Mon, 12 Oct 2015 17:21:03 -0500 Subject: Cleaning up formatting. Adding usage and compatibility text --- sass.html.markdown | 89 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 47 insertions(+), 42 deletions(-) diff --git a/sass.html.markdown b/sass.html.markdown index 9bc72478..77e82a09 100644 --- a/sass.html.markdown +++ b/sass.html.markdown @@ -20,16 +20,13 @@ relatively quickly. It does not provide any new styling options but rather the tools to write your CSS more efficiently and make maintenance much easier. -Sass files must be compiled into CSS. You can use any number of commandline -tools to compile Sass into CSS. Many IDEs also offer Sass compilation, as well. - - ```sass -/* Like CSS, Sass uses slash-asterisk to denote comments. Slash-asterisk comments - can span multiple lines. These comments will appear in your compiled CSS */ +/* Like CSS, Sass uses slash-asterisk to denote comments. Slash-asterisk + comments can span multiple lines. These comments will appear + in your compiled CSS */ -// Sass also supports single line comments that use double slashes. These comments will -// not be rendered in your compiled CSS +// Sass also supports single line comments that use double slashes. These +// comments will not be rendered in your compiled CSS /* #################### ## VARIABLES @@ -52,8 +49,7 @@ h1 { font-size: $headline-size; } -/* After compiling the Sass files into CSS, you'll have the following code - in your generated CSS file */ +/* Generated CSS result */ a { color: #0000ff; @@ -91,7 +87,7 @@ article { } } -/* The above will compile into the following CSS */ +/* Generated CSS result */ article { font-size: 14px; } @@ -115,16 +111,16 @@ article img { } /* It is recommended to not nest too deeply as this can cause issues with - specificity and make your CSS harder to work with and maintain. Best practices - recommend going no more than 3 levels deep when nesting. */ + specificity and make your CSS harder to work with and maintain. Best + practices recommend going no more than 3 levels deep when nesting. */ /* ############################### ## REFERENCE PARENT SELECTORS ############################### */ -/* Reference parent selectors are used when you're nesting statements and want to - reference the parent selector from within the nested statements. You can reference - a parent using & */ +/* Reference parent selectors are used when you're nesting statements and want + to reference the parent selector from within the nested statements. You can + reference a parent using & */ a { text-decoration: none; @@ -139,7 +135,7 @@ a { } } -/* The above Sass will compile into the CSS below */ +/* Generated CSS result */ a { text-decoration: none; @@ -160,8 +156,8 @@ body.noLinks a { #################### */ /* Mixins allow you to define reusable chunks of CSS. They can take one or more - arguments to allow you to make reusable pieces of styling. Mixins can also - be very helpful when dealing with vendor prefixes. */ + arguments to allow you to make reusable pieces of styling. Mixins very + helpful when dealing with vendor prefixes. */ @mixin form-button($color, $size, $border-radius) { color: $color; @@ -175,7 +171,7 @@ body.noLinks a { @include form-button(#0000ff, 16px, 4px); } -/* The above mixin will compile into the following css */ +/* Generated CSS result */ .user-form .submit { color: #0000ff; @@ -187,9 +183,11 @@ body.noLinks a { ## FUNCTIONS #################### */ -/* Sass provides functions that can be used to accomplish a variety of tasks. Consider the following */ +/* Sass provides functions that can be used to accomplish a variety of + tasks. Consider the following */ -/* Functions can be invoked by using their name and passing in the required arguments */ +/* Functions can be invoked by using their name and passing in the + required arguments */ body { width: round(10.25px); } @@ -198,7 +196,7 @@ body { background-color: fade_out(#000000, 0.25) } -/* The above Sass will compile into the following CSS */ +/* Generated CSS result */ body { width: 10px; @@ -208,14 +206,15 @@ body { background-color: rgba(0, 0, 0, 0.75); } -/* You may also define your own functions. Functions are very similar to mixins. When trying - to choose between a function or a mixin, remember that functions are best for returning - values while mixins are best for generating CSS while functions are better for logic that - might be used throughout your Sass code. The examples in the Math Operators' section are - ideal candidates for becoming a reusable function. */ - -/* This function will take a target size and the parent size and calculate and return - the percentage */ +/* You may also define your own functions. Functions are very similar to + mixins. When trying to choose between a function or a mixin, remember + that functions are best for returning values while mixins are best for + generating CSS while functions are better for logic that might be used + throughout your Sass code. The examples in the Math Operators' section + are ideal candidates for becoming a reusable function. */ + +/* This function will take a target size and the parent size and calculate + and return the percentage */ @function calculate-percentage($target-size, $parent-size) { @return $target-size / $parent-size * 100%; @@ -231,7 +230,7 @@ $main-content: calculate-percentage(600px, 960px); width: calculate-percentage(300px, 960px); } -/* The above Sass will compile into the following CSS */ +/* Generated CSS result */ .main-content { width: 62.5%; @@ -241,9 +240,9 @@ $main-content: calculate-percentage(600px, 960px); width: 31.25%; } -/* #################### +/* ##################### ## EXTEND/INHERITANCE - #################### */ + ##################### */ /* Sass allows you to extend an existing CSS statement. This makes it very easy to write CSS that does not violate DRY principles. Any @@ -271,7 +270,7 @@ $main-content: calculate-percentage(600px, 960px); background-color: #ccc; } -/* The above Sass will be compile into the following CSS */ +/* Generated CSS result */ .content-window, .message-window, @@ -306,10 +305,10 @@ $main-content: calculate-percentage(600px, 960px); ## PLACEHOLDER SELECTORS ######################### */ -/* Placeholders are useful when creating a CSS statement to extend. If you wanted to create - a CSS statement that was exclusively used with @extend, you can do so using a placeholder. - Placeholders begin with a '%' instead of '.' or '#'. Placeholders will not appear in the - compiled CSS. */ +/* Placeholders are useful when creating a CSS statement to extend. If you + wanted to create a CSS statement that was exclusively used with @extend, + you can do so using a placeholder. Placeholders begin with a '%' instead + of '.' or '#'. Placeholders will not appear in the compiled CSS. */ %content-window { font-size: 14px; @@ -323,7 +322,7 @@ $main-content: calculate-percentage(600px, 960px); background-color: #0000ff; } -/* The above Sass would compile to the following CSS */ +/* Generated CSS result */ .message-window { font-size: 14px; @@ -369,7 +368,7 @@ body { width: $gutter; } -/* The above Sass would compile to the CSS below */ +/* Generated CSS result */ body { width: 100%; @@ -391,9 +390,15 @@ body { ## Usage +Sass files must be compiled into CSS. You can use any number of commandline +tools to compile Sass into CSS. Many IDEs also offer Sass compilation, as well. +[Compass](http://compass-style.org/) is one of the more popular tools for Sass compilation. ## Compatibility +Sass can be used in any project as long as you have something to compile it +into CSS. You'll want to verify that the CSS you're using is compatible +with your target browsers. -## Further Reading +[QuirksMode CSS](http://www.quirksmode.org/css/) and [CanIUse](http://caniuse.com) great resources for checking compatibility. \ No newline at end of file -- cgit v1.2.3 From e44d7d47ec1fd01cb7ec8054fd59fc0ee3987476 Mon Sep 17 00:00:00 2001 From: thimoteus Date: Mon, 12 Oct 2015 16:18:22 -0700 Subject: updated purescript example for compiler version >= 0.7.4.1 --- purescript.html.markdown | 219 +++++++++++++++++++++++++---------------------- 1 file changed, 116 insertions(+), 103 deletions(-) diff --git a/purescript.html.markdown b/purescript.html.markdown index a006cdff..61287ceb 100644 --- a/purescript.html.markdown +++ b/purescript.html.markdown @@ -2,194 +2,207 @@ language: purescript contributors: - ["Fredrik Dyrkell", "http://www.lexicallyscoped.com"] + - ["Thimoteus", "https://github.com/Thimoteus"] --- PureScript is a small strongly, statically typed language compiling to Javascript. * Learn more at [http://www.purescript.org/](http://www.purescript.org/) -* Documentation: [http://docs.purescript.org/en/latest/](http://docs.purescript.org/en/latest/) +* Documentation: [http://pursuit.purescript.org/](http://pursuit.purescript.org/) * Book: Purescript by Example, [https://leanpub.com/purescript/](https://leanpub.com/purescript/) -```haskell +```purescript -- -- 1. Primitive datatypes that corresponds to their Javascript -- equivalents at runtime. +> import Prelude -- Numbers -1 + 7*5 :: Number -- 36 +> 1.0 + 7.2*5.5 :: Number -- 40.6 +-- Ints +> 1 + 2*5 :: Int -- 11 -- Types are inferred, so the following works fine -9 / 2.5 + 4.4 -- 8 +> 9.0/2.5 + 4.4 -- 8.0 +-- But Ints and Numbers don't mix, so the following won't +> 5/2 + 2.5 -- Expression 2.5 does not have type Int -- Hexadecimal literals -0xff + 1 -- 256 +> 0xff + 1 -- 256 -- Unary negation -6 * -3 -- -18 -6 * negate 3 -- -18 --- Modulus -3 % 2 -- 1 -4 % 2 -- 0 +> 6 * -3 -- -18 +> 6 * negate 3 -- -18 +-- Modulus, from purescript-math (Math) +> 3.0 % 2.0 -- 1.0 +> 4.0 % 2.0 -- 0.0 -- Inspect the type of an expression in psci -:t 9 / 2.5 + 4.4 -- Prim.Number +> :t 9.5/2.5 + 4.4 -- Prim.Number -- Booleans -true :: Boolean -- true -false :: Boolean -- false +> true :: Boolean -- true +> false :: Boolean -- false -- Negation -not true --false -23 == 23 -- true -1 /= 4 -- true -1 >= 4 -- false +> not true -- false +> 23 == 23 -- true +> 1 /= 4 -- true +> 1 >= 4 -- false -- Comparisions < <= > >= -- are defined in terms of compare -compare 1 2 -- LT -compare 2 2 -- EQ -compare 3 2 -- GT +> compare 1 2 -- LT +> compare 2 2 -- EQ +> compare 3 2 -- GT -- Conjunction and Disjunction -true && (9 >= 19 || 1 < 2) -- true +> true && (9 >= 19 || 1 < 2) -- true -- Strings -"Hellow" :: String -- "Hellow" --- Multiline string -"Hellow\ +> "Hellow" :: String -- "Hellow" +-- Multiline string without newlines, to run in psci use the --multi-line-mode flag +> "Hellow\ \orld" -- "Helloworld" +-- Multiline string with newlines +> """Hello +world""" -- "Hello\nworld" -- Concatenate -"such " ++ "amaze" -- "such amaze" +> "such " ++ "amaze" -- "such amaze" -- -- 2. Arrays are Javascript arrays, but must be homogeneous -[1,1,2,3,5,8] :: [Number] -- [1,1,2,3,5,8] -[true, true, false] :: [Boolean] -- [true,true,false] +> [1,1,2,3,5,8] :: Array Number -- [1,1,2,3,5,8] +> [true, true, false] :: Array Boolean -- [true,true,false] -- [1,2, true, "false"] won't work --- `Cannot unify Prim.Number with Prim.Boolean` +-- `Cannot unify Prim.Int with Prim.Boolean` -- Cons (prepend) -1 : [2,4,3] -- [1,2,4,3] +> 1 : [2,4,3] -- [1,2,4,3] -- Requires purescript-arrays (Data.Array) -- and purescript-maybe (Data.Maybe) -- Safe access return Maybe a -head [1,2,3] -- Just (1) -tail [3,2,1] -- Just ([2,1]) -init [1,2,3] -- Just ([1,2]) -last [3,2,1] -- Just (1) +> head [1,2,3] -- Just (1) +> tail [3,2,1] -- Just ([2,1]) +> init [1,2,3] -- Just ([1,2]) +> last [3,2,1] -- Just (1) -- Random access - indexing -[3,4,5,6,7] !! 2 -- Just (5) +> [3,4,5,6,7] !! 2 -- Just (5) -- Range -1..5 -- [1,2,3,4,5] -length [2,2,2] -- 3 -drop 3 [5,4,3,2,1] -- [2,1] -take 3 [5,4,3,2,1] -- [5,4,3] -append [1,2,3] [4,5,6] -- [1,2,3,4,5,6] +> 1..5 -- [1,2,3,4,5] +> length [2,2,2] -- 3 +> drop 3 [5,4,3,2,1] -- [2,1] +> take 3 [5,4,3,2,1] -- [5,4,3] +> append [1,2,3] [4,5,6] -- [1,2,3,4,5,6] -- -- 3. Records are Javascript objects, with zero or more fields, which --- can have different types -let book = {title: "Foucault's pendulum", author: "Umberto Eco"} +-- can have different types. +-- In psci you have to write `let` in front of the function to get a +-- top level binding. +> let book = {title: "Foucault's pendulum", author: "Umberto Eco"} -- Access properties -book.title -- "Foucault's pendulum" +> book.title -- "Foucault's pendulum" -getTitle b = b.title +> let getTitle b = b.title -- Works on all records with a title (but doesn't require any other field) -getTitle book -- "Foucault's pendulum" -getTitle {title: "Weekend in Monaco", artist: "The Rippingtons"} -- "Weekend in Monaco" +> getTitle book -- "Foucault's pendulum" +> getTitle {title: "Weekend in Monaco", artist: "The Rippingtons"} -- "Weekend in Monaco" +-- Can use underscores as shorthand +> _.title book -- "Foucault's pendulum" -- Update a record -changeTitle b t = b {title = t} -changeTitle book "Ill nome della rosa" -- {title: "Ill nome della - -- rosa", author: "Umberto Eco"} +> let changeTitle b t = b {title = t} +> getTitle (changeTitle book "Ill nome della rosa") -- "Ill nome della rosa" -- -- 4. Functions -sumOfSquares x y = x*x+y*y -sumOfSquares 3 4 -- 25 --- In psci you have to write `let` in front of the function to get a --- top level binding -mod x y = x % y -mod 3 2 -- 1 +-- In psci's multiline mode +> let sumOfSquares :: Int -> Int -> Int + sumOfSquares x y = x*x + y*y +> sumOfSquares 3 4 -- 25 +> let myMod x y = x % y +> myMod 3.0 2.0 -- 1.0 -- Infix application of function -3 `mod` 2 -- 1 +> 3 `mod` 2 -- 1 --- function application have higher precedence than all other +-- function application has higher precedence than all other -- operators -sumOfSquares 3 4 * sumOfSquares 4 5 -- 1025 +> sumOfSquares 3 4 * sumOfSquares 4 5 -- 1025 -- Conditional -abs' n = if n>=0 then n else -n -abs' (-3) -- 3 +> let abs' n = if n>=0 then n else -n +> abs' (-3) -- 3 -- Guarded equations -abs n | n >= 0 = n - | otherwise = -n +> let abs'' n | n >= 0 = n + | otherwise = -n -- Pattern matching --- Note the type signature, input is an array of numbers The pattern --- matching destructures and binds the array into parts -first :: [Number] -> Number -first (x:_) = x -first [3,4,5] -- 3 -second :: [Number] -> Number -second (_:y:_) = y -second [3,4,5] -- 4 -sumTwo :: [Number] -> [Number] -sumTwo (x:y:rest) = (x+y) : rest -sumTwo [2,3,4,5,6] -- [5,4,5,6] - --- sumTwo doesn't handle when the array is empty or just have one --- element in which case you get an error +-- Note the type signature, input is a list of numbers. The pattern matching +-- destructures and binds the list into parts. +-- Requires purescript-lists (Data.List) +> let first :: forall a. List a -> a + first (Cons x _) = x +> first (toList [3,4,5]) -- 3 +> let second :: forall a. List a -> a + second (Cons _ (Cons y _)) = y +> second (toList [3,4,5]) -- 4 +> let sumTwo :: List Int -> List Int + sumTwo (Cons x (Cons y rest)) = x + y : rest +> fromList (sumTwo (toList [2,3,4,5,6])) :: Array Int -- [5,4,5,6] + +-- sumTwo doesn't handle when the list is empty or there's only one element in +-- which case you get an error. sumTwo [1] -- Failed pattern match -- Complementing patterns to match -- Good ol' Fibonacci -fib 1 = 1 -fib 2 = 2 -fib x = fib (x-1) + fib (x-2) -fib 10 -- 89 +> let fib 1 = 1 + fib 2 = 2 + fib x = fib (x-1) + fib (x-2) +> fib 10 -- 89 -- Use underscore to match any, where you don't care about the binding name -isZero 0 = true -isZero _ = false +> let isZero 0 = true + isZero _ = false -- Pattern matching on records -ecoTitle {author = "Umberto Eco", title = t} = Just t -ecoTitle _ = Nothing +> let ecoTitle {author = "Umberto Eco", title = t} = Just t + ecoTitle _ = Nothing -ecoTitle book -- Just ("Foucault's pendulum") -ecoTitle {title: "The Quantum Thief", author: "Hannu Rajaniemi"} -- Nothing +> ecoTitle book -- Just ("Foucault's pendulum") +> ecoTitle {title: "The Quantum Thief", author: "Hannu Rajaniemi"} -- Nothing -- ecoTitle requires both field to type check: -ecoTitle {title: "The Quantum Thief"} -- Object does not have property author +> ecoTitle {title: "The Quantum Thief"} -- Object lacks required property "author" -- Lambda expressions -(\x -> x*x) 3 -- 9 -(\x y -> x*x + y*y) 4 5 -- 41 -sqr = \x -> x*x +> (\x -> x*x) 3 -- 9 +> (\x y -> x*x + y*y) 4 5 -- 41 +> let sqr = \x -> x*x -- Currying -add x y = x + y -- is equivalent with -add = \x -> (\y -> x+y) -add3 = add 3 -:t add3 -- Prim.Number -> Prim.Number +> let myAdd x y = x + y -- is equivalent with +> let myAdd' = \x -> \y -> x + y +> let add3 = myAdd 3 +> :t add3 -- Prim.Int -> Prim.Int -- Forward and backward function composition -- drop 3 followed by taking 5 -(drop 3 >>> take 5) (1..20) -- [4,5,6,7,8] +> (drop 3 >>> take 5) (1..20) -- [4,5,6,7,8] -- take 5 followed by dropping 3 -(drop 3 <<< take 5) (1..20) -- [4,5] +> (drop 3 <<< take 5) (1..20) -- [4,5] -- Operations using higher order functions -even x = x % 2 == 0 -filter even (1..10) -- [2,4,6,8,10] -map (\x -> x+11) (1..5) -- [12,13,14,15,16] +> let even x = x `mod` 2 == 0 +> filter even (1..10) -- [2,4,6,8,10] +> map (\x -> x + 11) (1..5) -- [12,13,14,15,16] -- Requires purescript-foldable-traversabe (Data.Foldable) -foldr (+) 0 (1..10) -- 55 -sum (1..10) -- 55 -product (1..10) -- 3628800 +> foldr (+) 0 (1..10) -- 55 +> sum (1..10) -- 55 +> product (1..10) -- 3628800 -- Testing with predicate -any even [1,2,3] -- true -all even [1,2,3] -- false +> any even [1,2,3] -- true +> all even [1,2,3] -- false ``` -- cgit v1.2.3 From c2f15ffd87b116b17244fe6053f385d7cb4dabf0 Mon Sep 17 00:00:00 2001 From: thimoteus Date: Tue, 13 Oct 2015 01:25:56 -0700 Subject: readded haskell syntax highlighting, added line about running examples in psci, removed >'s --- purescript.html.markdown | 193 ++++++++++++++++++++++++----------------------- 1 file changed, 98 insertions(+), 95 deletions(-) diff --git a/purescript.html.markdown b/purescript.html.markdown index 61287ceb..6d8cfbb9 100644 --- a/purescript.html.markdown +++ b/purescript.html.markdown @@ -11,142 +11,145 @@ PureScript is a small strongly, statically typed language compiling to Javascrip * Documentation: [http://pursuit.purescript.org/](http://pursuit.purescript.org/) * Book: Purescript by Example, [https://leanpub.com/purescript/](https://leanpub.com/purescript/) -```purescript +All the noncommented lines of code can be run in the PSCI REPL, though some will +require the `--multi-line-mode` flag. + +```haskell -- -- 1. Primitive datatypes that corresponds to their Javascript -- equivalents at runtime. -> import Prelude +import Prelude -- Numbers -> 1.0 + 7.2*5.5 :: Number -- 40.6 +1.0 + 7.2*5.5 :: Number -- 40.6 -- Ints -> 1 + 2*5 :: Int -- 11 +1 + 2*5 :: Int -- 11 -- Types are inferred, so the following works fine -> 9.0/2.5 + 4.4 -- 8.0 +9.0/2.5 + 4.4 -- 8.0 -- But Ints and Numbers don't mix, so the following won't -> 5/2 + 2.5 -- Expression 2.5 does not have type Int +5/2 + 2.5 -- Expression 2.5 does not have type Int -- Hexadecimal literals -> 0xff + 1 -- 256 +0xff + 1 -- 256 -- Unary negation -> 6 * -3 -- -18 -> 6 * negate 3 -- -18 +6 * -3 -- -18 +6 * negate 3 -- -18 -- Modulus, from purescript-math (Math) -> 3.0 % 2.0 -- 1.0 -> 4.0 % 2.0 -- 0.0 +3.0 % 2.0 -- 1.0 +4.0 % 2.0 -- 0.0 -- Inspect the type of an expression in psci -> :t 9.5/2.5 + 4.4 -- Prim.Number +:t 9.5/2.5 + 4.4 -- Prim.Number -- Booleans -> true :: Boolean -- true -> false :: Boolean -- false +true :: Boolean -- true +false :: Boolean -- false -- Negation -> not true -- false -> 23 == 23 -- true -> 1 /= 4 -- true -> 1 >= 4 -- false +not true -- false +23 == 23 -- true +1 /= 4 -- true +1 >= 4 -- false -- Comparisions < <= > >= -- are defined in terms of compare -> compare 1 2 -- LT -> compare 2 2 -- EQ -> compare 3 2 -- GT +compare 1 2 -- LT +compare 2 2 -- EQ +compare 3 2 -- GT -- Conjunction and Disjunction -> true && (9 >= 19 || 1 < 2) -- true +true && (9 >= 19 || 1 < 2) -- true -- Strings -> "Hellow" :: String -- "Hellow" +"Hellow" :: String -- "Hellow" -- Multiline string without newlines, to run in psci use the --multi-line-mode flag -> "Hellow\ +"Hellow\ \orld" -- "Helloworld" -- Multiline string with newlines -> """Hello +"""Hello world""" -- "Hello\nworld" -- Concatenate -> "such " ++ "amaze" -- "such amaze" +"such " ++ "amaze" -- "such amaze" -- -- 2. Arrays are Javascript arrays, but must be homogeneous -> [1,1,2,3,5,8] :: Array Number -- [1,1,2,3,5,8] -> [true, true, false] :: Array Boolean -- [true,true,false] +[1,1,2,3,5,8] :: Array Number -- [1,1,2,3,5,8] +[true, true, false] :: Array Boolean -- [true,true,false] -- [1,2, true, "false"] won't work -- `Cannot unify Prim.Int with Prim.Boolean` -- Cons (prepend) -> 1 : [2,4,3] -- [1,2,4,3] +1 : [2,4,3] -- [1,2,4,3] -- Requires purescript-arrays (Data.Array) -- and purescript-maybe (Data.Maybe) -- Safe access return Maybe a -> head [1,2,3] -- Just (1) -> tail [3,2,1] -- Just ([2,1]) -> init [1,2,3] -- Just ([1,2]) -> last [3,2,1] -- Just (1) +head [1,2,3] -- Just (1) +tail [3,2,1] -- Just ([2,1]) +init [1,2,3] -- Just ([1,2]) +last [3,2,1] -- Just (1) -- Random access - indexing -> [3,4,5,6,7] !! 2 -- Just (5) +[3,4,5,6,7] !! 2 -- Just (5) -- Range -> 1..5 -- [1,2,3,4,5] -> length [2,2,2] -- 3 -> drop 3 [5,4,3,2,1] -- [2,1] -> take 3 [5,4,3,2,1] -- [5,4,3] -> append [1,2,3] [4,5,6] -- [1,2,3,4,5,6] +1..5 -- [1,2,3,4,5] +length [2,2,2] -- 3 +drop 3 [5,4,3,2,1] -- [2,1] +take 3 [5,4,3,2,1] -- [5,4,3] +append [1,2,3] [4,5,6] -- [1,2,3,4,5,6] -- -- 3. Records are Javascript objects, with zero or more fields, which -- can have different types. -- In psci you have to write `let` in front of the function to get a -- top level binding. -> let book = {title: "Foucault's pendulum", author: "Umberto Eco"} +let book = {title: "Foucault's pendulum", author: "Umberto Eco"} -- Access properties -> book.title -- "Foucault's pendulum" +book.title -- "Foucault's pendulum" -> let getTitle b = b.title +let getTitle b = b.title -- Works on all records with a title (but doesn't require any other field) -> getTitle book -- "Foucault's pendulum" -> getTitle {title: "Weekend in Monaco", artist: "The Rippingtons"} -- "Weekend in Monaco" +getTitle book -- "Foucault's pendulum" +getTitle {title: "Weekend in Monaco", artist: "The Rippingtons"} -- "Weekend in Monaco" -- Can use underscores as shorthand -> _.title book -- "Foucault's pendulum" +_.title book -- "Foucault's pendulum" -- Update a record -> let changeTitle b t = b {title = t} -> getTitle (changeTitle book "Ill nome della rosa") -- "Ill nome della rosa" +let changeTitle b t = b {title = t} +getTitle (changeTitle book "Ill nome della rosa") -- "Ill nome della rosa" -- -- 4. Functions -- In psci's multiline mode -> let sumOfSquares :: Int -> Int -> Int - sumOfSquares x y = x*x + y*y -> sumOfSquares 3 4 -- 25 -> let myMod x y = x % y -> myMod 3.0 2.0 -- 1.0 +let sumOfSquares :: Int -> Int -> Int + sumOfSquares x y = x*x + y*y +sumOfSquares 3 4 -- 25 +let myMod x y = x % y +myMod 3.0 2.0 -- 1.0 -- Infix application of function -> 3 `mod` 2 -- 1 +3 `mod` 2 -- 1 -- function application has higher precedence than all other -- operators -> sumOfSquares 3 4 * sumOfSquares 4 5 -- 1025 +sumOfSquares 3 4 * sumOfSquares 4 5 -- 1025 -- Conditional -> let abs' n = if n>=0 then n else -n -> abs' (-3) -- 3 +let abs' n = if n>=0 then n else -n +abs' (-3) -- 3 -- Guarded equations -> let abs'' n | n >= 0 = n - | otherwise = -n +let abs'' n | n >= 0 = n + | otherwise = -n -- Pattern matching -- Note the type signature, input is a list of numbers. The pattern matching -- destructures and binds the list into parts. -- Requires purescript-lists (Data.List) -> let first :: forall a. List a -> a - first (Cons x _) = x -> first (toList [3,4,5]) -- 3 -> let second :: forall a. List a -> a - second (Cons _ (Cons y _)) = y -> second (toList [3,4,5]) -- 4 -> let sumTwo :: List Int -> List Int - sumTwo (Cons x (Cons y rest)) = x + y : rest -> fromList (sumTwo (toList [2,3,4,5,6])) :: Array Int -- [5,4,5,6] +let first :: forall a. List a -> a + first (Cons x _) = x +first (toList [3,4,5]) -- 3 +let second :: forall a. List a -> a + second (Cons _ (Cons y _)) = y +second (toList [3,4,5]) -- 4 +let sumTwo :: List Int -> List Int + sumTwo (Cons x (Cons y rest)) = x + y : rest +fromList (sumTwo (toList [2,3,4,5,6])) :: Array Int -- [5,4,5,6] -- sumTwo doesn't handle when the list is empty or there's only one element in -- which case you get an error. @@ -154,55 +157,55 @@ sumTwo [1] -- Failed pattern match -- Complementing patterns to match -- Good ol' Fibonacci -> let fib 1 = 1 - fib 2 = 2 - fib x = fib (x-1) + fib (x-2) -> fib 10 -- 89 +let fib 1 = 1 + fib 2 = 2 + fib x = fib (x-1) + fib (x-2) +fib 10 -- 89 -- Use underscore to match any, where you don't care about the binding name -> let isZero 0 = true - isZero _ = false +let isZero 0 = true + isZero _ = false -- Pattern matching on records -> let ecoTitle {author = "Umberto Eco", title = t} = Just t - ecoTitle _ = Nothing +let ecoTitle {author = "Umberto Eco", title = t} = Just t + ecoTitle _ = Nothing -> ecoTitle book -- Just ("Foucault's pendulum") -> ecoTitle {title: "The Quantum Thief", author: "Hannu Rajaniemi"} -- Nothing +ecoTitle book -- Just ("Foucault's pendulum") +ecoTitle {title: "The Quantum Thief", author: "Hannu Rajaniemi"} -- Nothing -- ecoTitle requires both field to type check: -> ecoTitle {title: "The Quantum Thief"} -- Object lacks required property "author" +ecoTitle {title: "The Quantum Thief"} -- Object lacks required property "author" -- Lambda expressions -> (\x -> x*x) 3 -- 9 -> (\x y -> x*x + y*y) 4 5 -- 41 -> let sqr = \x -> x*x +(\x -> x*x) 3 -- 9 +(\x y -> x*x + y*y) 4 5 -- 41 +let sqr = \x -> x*x -- Currying -> let myAdd x y = x + y -- is equivalent with -> let myAdd' = \x -> \y -> x + y -> let add3 = myAdd 3 -> :t add3 -- Prim.Int -> Prim.Int +let myAdd x y = x + y -- is equivalent with +let myAdd' = \x -> \y -> x + y +let add3 = myAdd 3 +:t add3 -- Prim.Int -> Prim.Int -- Forward and backward function composition -- drop 3 followed by taking 5 -> (drop 3 >>> take 5) (1..20) -- [4,5,6,7,8] +(drop 3 >>> take 5) (1..20) -- [4,5,6,7,8] -- take 5 followed by dropping 3 -> (drop 3 <<< take 5) (1..20) -- [4,5] +(drop 3 <<< take 5) (1..20) -- [4,5] -- Operations using higher order functions -> let even x = x `mod` 2 == 0 -> filter even (1..10) -- [2,4,6,8,10] -> map (\x -> x + 11) (1..5) -- [12,13,14,15,16] +let even x = x `mod` 2 == 0 +filter even (1..10) -- [2,4,6,8,10] +map (\x -> x + 11) (1..5) -- [12,13,14,15,16] -- Requires purescript-foldable-traversabe (Data.Foldable) -> foldr (+) 0 (1..10) -- 55 -> sum (1..10) -- 55 -> product (1..10) -- 3628800 +foldr (+) 0 (1..10) -- 55 +sum (1..10) -- 55 +product (1..10) -- 3628800 -- Testing with predicate -> any even [1,2,3] -- true -> all even [1,2,3] -- false +any even [1,2,3] -- true +all even [1,2,3] -- false ``` -- cgit v1.2.3 From dff456bb6de20f6b0ab5d9c1d9abfe43449e2606 Mon Sep 17 00:00:00 2001 From: evuez Date: Tue, 13 Oct 2015 13:42:29 +0200 Subject: Add lang to header Header configuration was missing `lang` field. --- fr-fr/haml-fr.html.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/fr-fr/haml-fr.html.markdown b/fr-fr/haml-fr.html.markdown index 0267a380..24be8bf9 100644 --- a/fr-fr/haml-fr.html.markdown +++ b/fr-fr/haml-fr.html.markdown @@ -4,6 +4,7 @@ filename: learnhaml.haml contributors: - ["Simon Neveu", "https://github.com/sneveu"] - ["Thibault", "https://github.com/iTech-"] +lang: fr-fr --- Haml est un langage de balisage utilisé majoritairement avec Ruby, qui décrit de manière simple et propre le HTML de n'importe quelle page web sans l'utilisation des traditionnelles lignes de code. Le langage est une alternative très populaire au langage de templates Rails (.erb) et permet d'intégrer du code en Ruby dans votre balisage. -- cgit v1.2.3 From 93ced538e3e426b810bc2d4e621eae231c9515c4 Mon Sep 17 00:00:00 2001 From: Bruno Volcov Date: Tue, 13 Oct 2015 11:26:26 -0300 Subject: add documentation about git tags --- git.html.markdown | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/git.html.markdown b/git.html.markdown index 72079f6c..971d53e4 100644 --- a/git.html.markdown +++ b/git.html.markdown @@ -5,6 +5,7 @@ contributors: - ["Jake Prather", "http://github.com/JakeHP"] - ["Leo Rudberg" , "http://github.com/LOZORD"] - ["Betsy Lorton" , "http://github.com/schbetsy"] + - ["Bruno Volcov", "http://github.com/volcov"] filename: LearnGit.txt --- @@ -76,6 +77,11 @@ other repositories, or not! 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. +### 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) + ### HEAD and head (component of .git dir) HEAD is a pointer that points to the current branch. A repository only has 1 *active* HEAD. @@ -206,6 +212,28 @@ $ git branch -m myBranchName myNewBranchName $ git branch myBranchName --edit-description ``` +### tag + +Manage your tags + +```bash +# List tags +$ git tag +# Create a annotated tag +# The -m specifies a tagging message,which is stored with the tag. +# If you don’t specify a message for an annotated tag, +# Git launches your editor so you can type it in. +$ git tag -a v2.0 -m 'my version 2.0' +# Show info about tag +# That shows the tagger information, the date the commit was tagged, +# and the annotation message before showing the commit information. +$ git show v2.0 +# Push a single tag to remote +$ git push origin v2.0 +# Push a lot of tags to remote +$ git push origin --tags +``` + ### checkout Updates all files in the working tree to match the version in the index, or specified tree. -- cgit v1.2.3 From c357be714fe39c8c97e4d1ac12b3cdfb673d1e1e Mon Sep 17 00:00:00 2001 From: Sean Corrales Date: Tue, 13 Oct 2015 09:51:26 -0500 Subject: Fixing formatting. Writing section about imports and partials. --- sass.html.markdown | 74 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 58 insertions(+), 16 deletions(-) diff --git a/sass.html.markdown b/sass.html.markdown index 77e82a09..e03231ff 100644 --- a/sass.html.markdown +++ b/sass.html.markdown @@ -28,9 +28,9 @@ easier. // Sass also supports single line comments that use double slashes. These // comments will not be rendered in your compiled CSS -/* #################### +/* ############ ## VARIABLES - #################### */ + ############ */ /* Sass allows you to define variables that can be used throughout your stylesheets. Variables are defined by placing a '$' in front @@ -60,9 +60,9 @@ h1 { font-size: 24px; } -/* #################### +/* ########## ## NESTING - #################### */ + ########## */ /* Nesting allows you to easily group together statements and nest them in a way that indicates their hierarchy */ @@ -114,9 +114,9 @@ article img { specificity and make your CSS harder to work with and maintain. Best practices recommend going no more than 3 levels deep when nesting. */ -/* ############################### +/* ############################# ## REFERENCE PARENT SELECTORS - ############################### */ + ############################# */ /* Reference parent selectors are used when you're nesting statements and want to reference the parent selector from within the nested statements. You can @@ -151,9 +151,9 @@ body.noLinks a { } -/* #################### +/* ######### ## MIXINS - #################### */ + ######### */ /* Mixins allow you to define reusable chunks of CSS. They can take one or more arguments to allow you to make reusable pieces of styling. Mixins very @@ -179,9 +179,9 @@ body.noLinks a { border-radius: 4px; } -/* #################### +/* ############ ## FUNCTIONS - #################### */ + ############ */ /* Sass provides functions that can be used to accomplish a variety of tasks. Consider the following */ @@ -240,6 +240,48 @@ $main-content: calculate-percentage(600px, 960px); width: 31.25%; } +/* ####################### + ## PARTIALS AND IMPORTS + ####################### */ +/* Sass allows you to create partial files. This can help keep your Sass + code modularized. Partial files should begin with an '_', e.g. _reset.css. + Partials are not generated into CSS. */ + +/* Consider the following CSS which we'll put in a file called _reset.css */ + +html, +body, +ul, +ol { + margin: 0; + padding: 0; +} + +/* Sass offers @import which can be used to import partials into a file. + This differs from the traditional CSS @import statement which makes + another HTTP request to fetch the imported file. Sass takes the + imported file and combines it with the compiled code. */ + +@import 'reset'; + +body { + font-size: 16px; + font-family: Helvetica, Arial, Sans-serif; +} + +/* Generated CSS result */ + +html, body, ul, ol { + margin: 0; + padding: 0; +} + +body { + font-size: 16px; + font-family: Helvetica, Arial, Sans-serif; +} + + /* ##################### ## EXTEND/INHERITANCE ##################### */ @@ -301,9 +343,9 @@ $main-content: calculate-percentage(600px, 960px); that called the mixin. While it won't affect your workflow, it will add unnecessary bloat to the files created by the Sass compiler. */ -/* ######################### +/* ######################## ## PLACEHOLDER SELECTORS - ######################### */ + ######################## */ /* Placeholders are useful when creating a CSS statement to extend. If you wanted to create a CSS statement that was exclusively used with @extend, @@ -335,9 +377,9 @@ $main-content: calculate-percentage(600px, 960px); background-color: #0000ff; } -/* #################### +/* ################## ## MATH OPERATIONS - #################### */ + ################## */ /* Sass provides the following operators: +, -, *, /, and %. These can be useful for calculating values directly in your Sass files instead @@ -397,8 +439,8 @@ tools to compile Sass into CSS. Many IDEs also offer Sass compilation, as well. ## Compatibility -Sass can be used in any project as long as you have something to compile it +Sass can be used in any project as long as you have a program to compile it into CSS. You'll want to verify that the CSS you're using is compatible with your target browsers. -[QuirksMode CSS](http://www.quirksmode.org/css/) and [CanIUse](http://caniuse.com) great resources for checking compatibility. \ No newline at end of file +[QuirksMode CSS](http://www.quirksmode.org/css/) and [CanIUse](http://caniuse.com) are great resources for checking compatibility. \ No newline at end of file -- cgit v1.2.3 From 46ef132ce697f4c44bcdea5e9e4121f82ff53333 Mon Sep 17 00:00:00 2001 From: evuez Date: Tue, 13 Oct 2015 17:05:18 +0200 Subject: Add resources to the "Free Online" section These have been valuable resources to me, but I'm not sure whether it fits this section or not. --- python3.html.markdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python3.html.markdown b/python3.html.markdown index 87fa0b70..a54e7f13 100644 --- a/python3.html.markdown +++ b/python3.html.markdown @@ -715,6 +715,8 @@ print(say(say_please=True)) # Can you buy me a beer? Please! I am poor :( * [A Crash Course in Python for Scientists](http://nbviewer.ipython.org/5920182) * [Python Course](http://www.python-course.eu/index.php) * [First Steps With Python](https://realpython.com/learn/python-first-steps/) +* [A curated list of awesome Python frameworks, libraries and software](https://github.com/vinta/awesome-python) +* [30 Python Language Features and Tricks You May Not Know About](http://sahandsaba.com/thirty-python-language-features-and-tricks-you-may-not-know.html) ### Dead Tree -- cgit v1.2.3 From 79ced08e094e488eb21d026c882babc50d0ca168 Mon Sep 17 00:00:00 2001 From: Zachary Ferguson Date: Tue, 13 Oct 2015 11:05:20 -0400 Subject: Added Header title + Added a header file title * Changed ```c to ```h --- c.html.markdown | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/c.html.markdown b/c.html.markdown index f1201eac..0c4916ac 100644 --- a/c.html.markdown +++ b/c.html.markdown @@ -630,6 +630,8 @@ typedef void (*my_fnp_type)(char *); ``` +### Header Files + Header files are an important part of c as they allow for the connection of c source files and can simplify code and definitions by seperating them into seperate files. @@ -639,7 +641,7 @@ files. They can be included in your c source file by using the precompiler command #include "example.h", given that example.h exists in the same directory as the c file. -```c +```h /* A safe guard to prevent the header from being defined too many times. This */ /* happens in the case of circle dependency, the contents of the header is */ /* already defined. */ -- cgit v1.2.3 From 8166438016b7028149c00649a2a33480c6701306 Mon Sep 17 00:00:00 2001 From: evuez Date: Tue, 13 Oct 2015 17:11:40 +0200 Subject: Add PEP8 to "Free Online" --- python3.html.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/python3.html.markdown b/python3.html.markdown index a54e7f13..404f08cf 100644 --- a/python3.html.markdown +++ b/python3.html.markdown @@ -717,6 +717,7 @@ print(say(say_please=True)) # Can you buy me a beer? Please! I am poor :( * [First Steps With Python](https://realpython.com/learn/python-first-steps/) * [A curated list of awesome Python frameworks, libraries and software](https://github.com/vinta/awesome-python) * [30 Python Language Features and Tricks You May Not Know About](http://sahandsaba.com/thirty-python-language-features-and-tricks-you-may-not-know.html) +* [Official Style Guide for Python](https://www.python.org/dev/peps/pep-0008/) ### Dead Tree -- cgit v1.2.3 From a4d9115decdfaa0346c66994df372e529d343d37 Mon Sep 17 00:00:00 2001 From: Gautam Kotian Date: Tue, 13 Oct 2015 18:15:49 +0200 Subject: Clarify that not just two people develop D The present construction seems to imply that only Walter and Andrei and involved in the development of D. This is nowhere close to being true! --- d.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/d.html.markdown b/d.html.markdown index ba24b60f..7c23f2dd 100644 --- a/d.html.markdown +++ b/d.html.markdown @@ -23,8 +23,8 @@ about [D](http://dlang.org/). The D programming language is a modern, general-pu multi-paradigm language with support for everything from low-level features to expressive high-level abstractions. -D is actively developed by Walter Bright and Andrei Alexandrescu, two super smart, really cool -dudes. With all that out of the way, let's look at some examples! +D is actively developed by a large group of super-smart people and is spearheaded by Walter Bright +and Andrei Alexandrescu. With all that out of the way, let's look at some examples! ```c import std.stdio; -- cgit v1.2.3 From 064b82eab443fa1bc8c1dd0b061bedbc04b60e66 Mon Sep 17 00:00:00 2001 From: Gautam Kotian Date: Tue, 13 Oct 2015 18:16:30 +0200 Subject: Add wikipedia page links Link to the wikipedia pages of Walter Bright and Andrei Alexandrescu in an attempt to at least partially establish their credibility. --- d.html.markdown | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/d.html.markdown b/d.html.markdown index 7c23f2dd..d56e08a6 100644 --- a/d.html.markdown +++ b/d.html.markdown @@ -23,8 +23,10 @@ about [D](http://dlang.org/). The D programming language is a modern, general-pu multi-paradigm language with support for everything from low-level features to expressive high-level abstractions. -D is actively developed by a large group of super-smart people and is spearheaded by Walter Bright -and Andrei Alexandrescu. With all that out of the way, let's look at some examples! +D is actively developed by a large group of super-smart people and is spearheaded by +[Walter Bright](https://en.wikipedia.org/wiki/Walter_Bright) and +[Andrei Alexandrescu](https://en.wikipedia.org/wiki/Andrei_Alexandrescu). +With all that out of the way, let's look at some examples! ```c import std.stdio; -- cgit v1.2.3 From 4be1044a64e7ac1000a458087ee9131a9999d05f Mon Sep 17 00:00:00 2001 From: Gautam Kotian Date: Tue, 13 Oct 2015 18:17:11 +0200 Subject: Improve code comments --- d.html.markdown | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/d.html.markdown b/d.html.markdown index d56e08a6..88a83e41 100644 --- a/d.html.markdown +++ b/d.html.markdown @@ -38,9 +38,10 @@ void main() { writeln(i); } - auto n = 1; // use auto for type inferred variables + // 'auto' can be used for inferring types. + auto n = 1; - // Numeric literals can use _ as a digit seperator for clarity + // Numeric literals can use '_' as a digit separator for clarity. while(n < 10_000) { n += n; } @@ -49,13 +50,15 @@ void main() { n -= (n / 2); } while(n > 0); - // For and while are nice, but in D-land we prefer foreach - // The .. creates a continuous range, excluding the end + // For and while are nice, but in D-land we prefer 'foreach' loops. + // The '..' creates a continuous range, including the first value + // but excluding the last. foreach(i; 1..1_000_000) { if(n % 2 == 0) writeln(i); } + // There's also 'foreach_reverse' when you want to loop backwards. foreach_reverse(i; 1..int.max) { if(n % 2 == 1) { writeln(i); @@ -80,7 +83,7 @@ struct LinkedList(T) { class BinTree(T) { T data = null; - // If there is only one template parameter, we can omit parens + // If there is only one template parameter, we can omit the parentheses BinTree!T left; BinTree!T right; } -- cgit v1.2.3 From 0e330607dfa9e47db7aa4271973ed74631d926a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Wo=C5=BAniczak?= Date: Tue, 13 Oct 2015 22:02:06 +0200 Subject: Fixed incorrect information about commas in JSON doc --- json.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/json.html.markdown b/json.html.markdown index b5e36090..060e9c3d 100644 --- a/json.html.markdown +++ b/json.html.markdown @@ -58,7 +58,7 @@ Drawbacks of JSON include lack of type definition and some sort of DTD. "alternative style": { "comment": "check this out!" - , "comma position": "doesn't matter - as long as it's before the value, then it's valid" + , "comma position": "doesn't matter - as long as it's before the next key, then it's valid" , "another comment": "how nice" }, -- cgit v1.2.3 From ad5b0a615b6dd6857de6d2055c1a2743bd340d83 Mon Sep 17 00:00:00 2001 From: Cameron Wood Date: Tue, 13 Oct 2015 17:03:26 -0400 Subject: [csharp/en] Fix for a few spelling errors Fixed a few typos and spelling errors in the C# documentation --- csharp.html.markdown | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/csharp.html.markdown b/csharp.html.markdown index 28da9fe5..7aca2c6f 100644 --- a/csharp.html.markdown +++ b/csharp.html.markdown @@ -160,7 +160,7 @@ on a new line! ""Wow!"", the masses cried"; // List = new List(); List intList = new List(); List stringList = new List(); - List z = new List { 9000, 1000, 1337 }; // intialize + List z = new List { 9000, 1000, 1337 }; // initialize // The <> are for generics - Check out the cool stuff section // Lists don't default to a value; @@ -460,7 +460,7 @@ on a new line! ""Wow!"", the masses cried"; { // OPTIONAL PARAMETERS MethodSignatures(3, 1, 3, "Some", "Extra", "Strings"); - MethodSignatures(3, another: 3); // explicity set a parameter, skipping optional ones + MethodSignatures(3, another: 3); // explicitly set a parameter, skipping optional ones // BY REF AND OUT PARAMETERS int maxCount = 0, count; // ref params must have value @@ -481,7 +481,7 @@ on a new line! ""Wow!"", the masses cried"; // in case variable is null int notNullable = nullable ?? 0; // 0 - // ?. is an operator for null-propogation - a shorthand way of checking for null + // ?. is an operator for null-propagation - a shorthand way of checking for null nullable?.Print(); // Use the Print() extension method if nullable isn't null // IMPLICITLY TYPED VARIABLES - you can let the compiler work out what the type is: @@ -650,7 +650,7 @@ on a new line! ""Wow!"", the masses cried"; { return _cadence; } - set // set - define a method to set a proprety + set // set - define a method to set a property { _cadence = value; // Value is the value passed in to the setter } -- cgit v1.2.3 From c05400477b05eb2f5f9ef7fb2d168c84e14fc26e Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Tue, 13 Oct 2015 17:56:48 -0700 Subject: Update Python 2 vs Python 3 Add fact that Python 2 is reaching end of life. And note that you can use `__future__` to add Python 2 and 3 compatible code. --- python.html.markdown | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/python.html.markdown b/python.html.markdown index 5b36083d..57a4d0d6 100644 --- a/python.html.markdown +++ b/python.html.markdown @@ -14,7 +14,13 @@ executable pseudocode. Feedback would be highly appreciated! You can reach me at [@louiedinh](http://twitter.com/louiedinh) or louiedinh [at] [google's email service] Note: This article applies to Python 2.7 specifically, but should be applicable -to Python 2.x. For Python 3.x, take a look at the [Python 3 tutorial](http://learnxinyminutes.com/docs/python3/). +to Python 2.x. Python 2.7 is reachong end of life and will stop beeign maintained in 2020, +it is though recommended to start learnign Python with Python 3. +For Python 3.x, take a look at the [Python 3 tutorial](http://learnxinyminutes.com/docs/python3/). + +It is also possible to write Python code which is compatible with Python 2.7 and 3.x at the same time, +using Python [`__future__` imports](https://docs.python.org/2/library/__future__.html). `__future__` imports +allow you to write Python 3 code that will run on Python 2, so check out the Python 3 tutorial. ```python -- cgit v1.2.3 From 518a383de1cfbe61d7758170755fba0888a4c9e4 Mon Sep 17 00:00:00 2001 From: Dillon J Byrne Date: Tue, 13 Oct 2015 20:03:46 -0500 Subject: Cleaned up formatting and clarified output Unified the formatting throughout the document, clarified the output of a few lines, and tried to make it easier to visually separate comments from code when reading. --- python3.html.markdown | 238 +++++++++++++++++++++++++------------------------- 1 file changed, 119 insertions(+), 119 deletions(-) diff --git a/python3.html.markdown b/python3.html.markdown index 87fa0b70..dd22fc8e 100644 --- a/python3.html.markdown +++ b/python3.html.markdown @@ -33,27 +33,27 @@ Note: This article applies to Python 3 specifically. Check out [here](http://lea 3 # => 3 # Math is what you would expect -1 + 1 # => 2 -8 - 1 # => 7 +1 + 1 # => 2 +8 - 1 # => 7 10 * 2 # => 20 # Except division which returns floats, real numbers, by default 35 / 5 # => 7.0 # Result of integer division truncated down both for positive and negative. -5 // 3 # => 1 -5.0 // 3.0 # => 1.0 # works on floats too --5 // 3 # => -2 --5.0 // 3.0 # => -2.0 +5 // 3 # => 1 +5.0 // 3.0 # => 1.0 # works on floats too +-5 // 3 # => -2 +-5.0 // 3.0 # => -2.0 # When you use a float, results are floats -3 * 2.0 # => 6.0 +3 * 2.0 # => 6.0 # Modulo operation -7 % 3 # => 1 +7 % 3 # => 1 # Exponentiation (x**y, x to the yth power) -2**4 # => 16 +2**4 # => 16 # Enforce precedence with parentheses (1 + 3) * 2 # => 8 @@ -63,20 +63,20 @@ True False # negate with not -not True # => False +not True # => False not False # => True # Boolean Operators # Note "and" and "or" are case-sensitive -True and False #=> False -False or True #=> True +True and False # => False +False or True # => True # Note using Bool operators with ints -0 and 2 #=> 0 --5 or 0 #=> -5 -0 == False #=> True -2 == True #=> False -1 == True #=> True +0 and 2 # => 0 +-5 or 0 # => -5 +0 == False # => True +2 == True # => False +1 == True # => True # Equality is == 1 == 1 # => True @@ -98,13 +98,13 @@ False or True #=> True # (is vs. ==) is checks if two variable refer to the same object, but == checks # if the objects pointed to have the same values. -a = [1, 2, 3, 4] # Point a at a new list, [1, 2, 3, 4] -b = a # Point b at what a is pointing to -b is a # => True, a and b refer to the same object -b == a # => True, a's and b's objects are equal -b = [1, 2, 3, 4] # Point a at a new list, [1, 2, 3, 4] -b is a # => False, a and b do not refer to the same object -b == a # => True, a's and b's objects are equal +a = [1, 2, 3, 4] # Point a at a new list, [1, 2, 3, 4] +b = a # Point b at what a is pointing to +b is a # => True, a and b refer to the same object +b == a # => True, a's and b's objects are equal +b = [1, 2, 3, 4] # Point a at a new list, [1, 2, 3, 4] +b is a # => False, a and b do not refer to the same object +b == a # => True, a's and b's objects are equal # Strings are created with " or ' "This is a string." @@ -113,24 +113,24 @@ b == a # => True, a's and b's objects are equal # Strings can be added too! But try not to do this. "Hello " + "world!" # => "Hello world!" # Strings can be added without using '+' -"Hello " "world!" # => "Hello world!" +"Hello " "world!" # => "Hello world!" # A string can be treated like a list of characters "This is a string"[0] # => 'T' # .format can be used to format strings, like this: -"{} can be {}".format("strings", "interpolated") +"{} can be {}".format("Strings", "interpolated") # => "Strings can be interpolated" # You can repeat the formatting arguments to save some typing. "{0} be nimble, {0} be quick, {0} jump over the {1}".format("Jack", "candle stick") -#=> "Jack be nimble, Jack be quick, Jack jump over the candle stick" +# => "Jack be nimble, Jack be quick, Jack jump over the candle stick" # You can use keywords if you don't want to count. -"{name} wants to eat {food}".format(name="Bob", food="lasagna") #=> "Bob wants to eat lasagna" +"{name} wants to eat {food}".format(name="Bob", food="lasagna") # => "Bob wants to eat lasagna" # If your Python 3 code also needs to run on Python 2.5 and below, you can also # still use the old style of formatting: -"%s can be %s the %s way" % ("strings", "interpolated", "old") +"%s can be %s the %s way" % ("Strings", "interpolated", "old") # => "Strings can be interpolated the old way" # None is an object @@ -139,14 +139,14 @@ None # => None # Don't use the equality "==" symbol to compare objects to None # Use "is" instead. This checks for equality of object identity. "etc" is None # => False -None is None # => True +None is None # => True # None, 0, and empty strings/lists/dicts all evaluate to False. # All other values are True -bool(0) # => False +bool(0) # => False bool("") # => False -bool([]) #=> False -bool({}) #=> False +bool([]) # => False +bool({}) # => False #################################################### @@ -154,11 +154,11 @@ bool({}) #=> False #################################################### # Python has a print function -print("I'm Python. Nice to meet you!") +print("I'm Python. Nice to meet you!") # => I'm Python. Nice to meet you! # By default the print function also prints out a newline at the end. # Use the optional argument end to change the end character. -print("Hello, World", end="!") # => Hello, World! +print("Hello, World", end="!") # => Hello, World! # No need to declare variables before assigning to them. # Convention is to use lower_case_with_underscores @@ -185,7 +185,7 @@ li.pop() # => 3 and li is now [1, 2, 4] li.append(3) # li is now [1, 2, 4, 3] again. # Access a list like you would any array -li[0] # => 1 +li[0] # => 1 # Look at the last element li[-1] # => 3 @@ -194,61 +194,61 @@ li[4] # Raises an IndexError # You can look at ranges with slice syntax. # (It's a closed/open range for you mathy types.) -li[1:3] # => [2, 4] +li[1:3] # => [2, 4] # Omit the beginning -li[2:] # => [4, 3] +li[2:] # => [4, 3] # Omit the end -li[:3] # => [1, 2, 4] +li[:3] # => [1, 2, 4] # Select every second entry li[::2] # =>[1, 4] # Return a reversed copy of the list -li[::-1] # => [3, 4, 2, 1] +li[::-1] # => [3, 4, 2, 1] # Use any combination of these to make advanced slices # li[start:end:step] # Make a one layer deep copy using slices -li2 = li[:] # => li2 = [1, 2, 4, 3] but (li2 is li) will result in false. +li2 = li[:] # => li2 = [1, 2, 4, 3] but (li2 is li) will result in false. # Remove arbitrary elements from a list with "del" -del li[2] # li is now [1, 2, 3] +del li[2] # li is now [1, 2, 3] # You can add lists # Note: values for li and for other_li are not modified. -li + other_li # => [1, 2, 3, 4, 5, 6] +li + other_li # => [1, 2, 3, 4, 5, 6] # Concatenate lists with "extend()" -li.extend(other_li) # Now li is [1, 2, 3, 4, 5, 6] +li.extend(other_li) # Now li is [1, 2, 3, 4, 5, 6] # Check for existence in a list with "in" -1 in li # => True +1 in li # => True # Examine the length with "len()" -len(li) # => 6 +len(li) # => 6 # Tuples are like lists but are immutable. tup = (1, 2, 3) -tup[0] # => 1 +tup[0] # => 1 tup[0] = 3 # Raises a TypeError # Note that a tuple of length one has to have a comma after the last element but # tuples of other lengths, even zero, do not. -type((1)) # => -type((1,)) # => -type(()) # => +type((1)) # => +type((1,)) # => +type(()) # => # You can do most of the list operations on tuples too -len(tup) # => 3 -tup + (4, 5, 6) # => (1, 2, 3, 4, 5, 6) -tup[:2] # => (1, 2) -2 in tup # => True +len(tup) # => 3 +tup + (4, 5, 6) # => (1, 2, 3, 4, 5, 6) +tup[:2] # => (1, 2) +2 in tup # => True # You can unpack tuples (or lists) into variables -a, b, c = (1, 2, 3) # a is now 1, b is now 2 and c is now 3 +a, b, c = (1, 2, 3) # a is now 1, b is now 2 and c is now 3 # Tuples are created by default if you leave out the parentheses d, e, f = 4, 5, 6 # Now look how easy it is to swap two values -e, d = d, e # d is now 5 and e is now 4 +e, d = d, e # d is now 5 and e is now 4 # Dictionaries store mappings @@ -259,45 +259,45 @@ filled_dict = {"one": 1, "two": 2, "three": 3} # Note keys for dictionaries have to be immutable types. This is to ensure that # the key can be converted to a constant hash value for quick look-ups. # Immutable types include ints, floats, strings, tuples. -invalid_dict = {[1,2,3]: "123"} # => Raises a TypeError: unhashable type: 'list' -valid_dict = {(1,2,3):[1,2,3]} # Values can be of any type, however. +invalid_dict = {[1,2,3]: "123"} # => Raises a TypeError: unhashable type: 'list' +valid_dict = {(1,2,3):[1,2,3]} # Values can be of any type, however. # Look up values with [] -filled_dict["one"] # => 1 +filled_dict["one"] # => 1 # Get all keys as an iterable with "keys()". We need to wrap the call in list() # to turn it into a list. We'll talk about those later. Note - Dictionary key # ordering is not guaranteed. Your results might not match this exactly. -list(filled_dict.keys()) # => ["three", "two", "one"] +list(filled_dict.keys()) # => ["three", "two", "one"] # Get all values as an iterable with "values()". Once again we need to wrap it # in list() to get it out of the iterable. Note - Same as above regarding key # ordering. -list(filled_dict.values()) # => [3, 2, 1] +list(filled_dict.values()) # => [3, 2, 1] # Check for existence of keys in a dictionary with "in" -"one" in filled_dict # => True -1 in filled_dict # => False +"one" in filled_dict # => True +1 in filled_dict # => False # Looking up a non-existing key is a KeyError -filled_dict["four"] # KeyError +filled_dict["four"] # KeyError # Use "get()" method to avoid the KeyError -filled_dict.get("one") # => 1 -filled_dict.get("four") # => None +filled_dict.get("one") # => 1 +filled_dict.get("four") # => None # The get method supports a default argument when the value is missing filled_dict.get("one", 4) # => 1 -filled_dict.get("four", 4) # => 4 +filled_dict.get("four", 4) # => 4 # "setdefault()" inserts into a dictionary only if the given key isn't present filled_dict.setdefault("five", 5) # filled_dict["five"] is set to 5 filled_dict.setdefault("five", 6) # filled_dict["five"] is still 5 # Adding to a dictionary -filled_dict.update({"four":4}) #=> {"one": 1, "two": 2, "three": 3, "four": 4} -#filled_dict["four"] = 4 #another way to add to dict +filled_dict.update({"four":4}) # => {"one": 1, "two": 2, "three": 3, "four": 4} +#filled_dict["four"] = 4 #another way to add to dict # Remove keys from a dictionary with del del filled_dict["one"] # Removes the key "one" from filled dict @@ -306,31 +306,31 @@ del filled_dict["one"] # Removes the key "one" from filled dict # Sets store ... well sets empty_set = set() # Initialize a set with a bunch of values. Yeah, it looks a bit like a dict. Sorry. -some_set = {1, 1, 2, 2, 3, 4} # some_set is now {1, 2, 3, 4} +some_set = {1, 1, 2, 2, 3, 4} # some_set is now {1, 2, 3, 4} # Similar to keys of a dictionary, elements of a set have to be immutable. -invalid_set = {[1], 1} # => Raises a TypeError: unhashable type: 'list' +invalid_set = {[1], 1} # => Raises a TypeError: unhashable type: 'list' valid_set = {(1,), 1} # Can set new variables to a set filled_set = some_set # Add one more item to the set -filled_set.add(5) # filled_set is now {1, 2, 3, 4, 5} +filled_set.add(5) # filled_set is now {1, 2, 3, 4, 5} # Do set intersection with & other_set = {3, 4, 5, 6} -filled_set & other_set # => {3, 4, 5} +filled_set & other_set # => {3, 4, 5} # Do set union with | -filled_set | other_set # => {1, 2, 3, 4, 5, 6} +filled_set | other_set # => {1, 2, 3, 4, 5, 6} # Do set difference with - -{1, 2, 3, 4} - {2, 3, 5} # => {1, 4} +{1, 2, 3, 4} - {2, 3, 5} # => {1, 4} # Check for existence in a set with in 2 in filled_set # => True -10 in filled_set # => False +10 in filled_set # => False @@ -416,12 +416,12 @@ try: # Use "raise" to raise an error raise IndexError("This is an index error") except IndexError as e: - pass # Pass is just a no-op. Usually you would do recovery here. + pass # Pass is just a no-op. Usually you would do recovery here. except (TypeError, NameError): - pass # Multiple exceptions can be handled together, if required. -else: # Optional clause to the try/except block. Must follow all except blocks + pass # Multiple exceptions can be handled together, if required. +else: # Optional clause to the try/except block. Must follow all except blocks print("All good!") # Runs only if the code in try raises no exceptions -finally: # Execute under all circumstances +finally: # Execute under all circumstances print("We can clean up resources here") # Instead of try/finally to cleanup resources you can use a with statement @@ -435,11 +435,11 @@ with open("myfile.txt") as f: filled_dict = {"one": 1, "two": 2, "three": 3} our_iterable = filled_dict.keys() -print(our_iterable) #=> range(1,10). This is an object that implements our Iterable interface +print(our_iterable) # => range(1,10). This is an object that implements our Iterable interface # We can loop over it. for i in our_iterable: - print(i) # Prints one, two, three + print(i) # Prints one, two, three # However we cannot address elements by index. our_iterable[1] # Raises a TypeError @@ -449,17 +449,17 @@ our_iterator = iter(our_iterable) # Our iterator is an object that can remember the state as we traverse through it. # We get the next object with "next()". -next(our_iterator) #=> "one" +next(our_iterator) # => "one" # It maintains state as we iterate. -next(our_iterator) #=> "two" -next(our_iterator) #=> "three" +next(our_iterator) # => "two" +next(our_iterator) # => "three" # After the iterator has returned all of its data, it gives you a StopIterator Exception -next(our_iterator) # Raises StopIteration +next(our_iterator) # Raises StopIteration # You can grab all the elements of an iterator by calling list() on it. -list(filled_dict.keys()) #=> Returns ["one", "two", "three"] +list(filled_dict.keys()) # => Returns ["one", "two", "three"] #################################################### @@ -469,20 +469,20 @@ list(filled_dict.keys()) #=> Returns ["one", "two", "three"] # Use "def" to create new functions def add(x, y): print("x is {} and y is {}".format(x, y)) - return x + y # Return values with a return statement + return x + y # Return values with a return statement # Calling functions with parameters -add(5, 6) # => prints out "x is 5 and y is 6" and returns 11 +add(5, 6) # => prints out "x is 5 and y is 6" and returns 11 # Another way to call functions is with keyword arguments -add(y=6, x=5) # Keyword arguments can arrive in any order. +add(y=6, x=5) # Keyword arguments can arrive in any order. # You can define functions that take a variable number of # positional arguments def varargs(*args): return args -varargs(1, 2, 3) # => (1, 2, 3) +varargs(1, 2, 3) # => (1, 2, 3) # You can define functions that take a variable number of # keyword arguments, as well @@ -490,7 +490,7 @@ def keyword_args(**kwargs): return kwargs # Let's call it to see what happens -keyword_args(big="foot", loch="ness") # => {"big": "foot", "loch": "ness"} +keyword_args(big="foot", loch="ness") # => {"big": "foot", "loch": "ness"} # You can do both at once, if you like @@ -507,33 +507,33 @@ all_the_args(1, 2, a=3, b=4) prints: # Use * to expand tuples and use ** to expand kwargs. args = (1, 2, 3, 4) kwargs = {"a": 3, "b": 4} -all_the_args(*args) # equivalent to foo(1, 2, 3, 4) -all_the_args(**kwargs) # equivalent to foo(a=3, b=4) -all_the_args(*args, **kwargs) # equivalent to foo(1, 2, 3, 4, a=3, b=4) +all_the_args(*args) # equivalent to foo(1, 2, 3, 4) +all_the_args(**kwargs) # equivalent to foo(a=3, b=4) +all_the_args(*args, **kwargs) # equivalent to foo(1, 2, 3, 4, a=3, b=4) # Returning multiple values (with tuple assignments) def swap(x, y): - return y, x # Return multiple values as a tuple without the parenthesis. - # (Note: parenthesis have been excluded but can be included) + return y, x # Return multiple values as a tuple without the parenthesis. + # (Note: parenthesis have been excluded but can be included) x = 1 y = 2 -x, y = swap(x, y) # => x = 2, y = 1 -# (x, y) = swap(x,y) # Again parenthesis have been excluded but can be included. +x, y = swap(x, y) # => x = 2, y = 1 +# (x, y) = swap(x,y) # Again parenthesis have been excluded but can be included. # Function Scope x = 5 def setX(num): # Local var x not the same as global variable x - x = num # => 43 - print (x) # => 43 + x = num # => 43 + print (x) # => 43 def setGlobalX(num): global x - print (x) # => 5 - x = num # global var x is now set to 6 - print (x) # => 6 + print (x) # => 5 + x = num # global var x is now set to 6 + print (x) # => 6 setX(43) setGlobalX(6) @@ -549,20 +549,20 @@ add_10 = create_adder(10) add_10(3) # => 13 # There are also anonymous functions -(lambda x: x > 2)(3) # => True -(lambda x, y: x ** 2 + y ** 2)(2, 1) # => 5 +(lambda x: x > 2)(3) # => True +(lambda x, y: x ** 2 + y ** 2)(2, 1) # => 5 # TODO - Fix for iterables # There are built-in higher order functions -map(add_10, [1, 2, 3]) # => [11, 12, 13] -map(max, [1, 2, 3], [4, 2, 1]) # => [4, 2, 3] +map(add_10, [1, 2, 3]) # => [11, 12, 13] +map(max, [1, 2, 3], [4, 2, 1]) # => [4, 2, 3] -filter(lambda x: x > 5, [3, 4, 5, 6, 7]) # => [6, 7] +filter(lambda x: x > 5, [3, 4, 5, 6, 7]) # => [6, 7] # We can use list comprehensions for nice maps and filters # List comprehension stores the output as a list which can itself be a nested list -[add_10(i) for i in [1, 2, 3]] # => [11, 12, 13] -[x for x in [3, 4, 5, 6, 7] if x > 5] # => [6, 7] +[add_10(i) for i in [1, 2, 3]] # => [11, 12, 13] +[x for x in [3, 4, 5, 6, 7] if x > 5] # => [6, 7] #################################################### ## 5. Classes @@ -609,15 +609,15 @@ j = Human("Joel") print(j.say("hello")) # prints out "Joel: hello" # Call our class method -i.get_species() # => "H. sapiens" +i.get_species() # => "H. sapiens" # Change the shared attribute Human.species = "H. neanderthalensis" -i.get_species() # => "H. neanderthalensis" -j.get_species() # => "H. neanderthalensis" +i.get_species() # => "H. neanderthalensis" +j.get_species() # => "H. neanderthalensis" # Call the static method -Human.grunt() # => "*grunt*" +Human.grunt() # => "*grunt*" #################################################### @@ -630,8 +630,8 @@ print(math.sqrt(16)) # => 4 # You can get specific functions from a module from math import ceil, floor -print(ceil(3.7)) # => 4.0 -print(floor(3.7)) # => 3.0 +print(ceil(3.7)) # => 4.0 +print(floor(3.7)) # => 3.0 # You can import all functions from a module. # Warning: this is not recommended @@ -639,7 +639,7 @@ from math import * # You can shorten module names import math as m -math.sqrt(16) == m.sqrt(16) # => True +math.sqrt(16) == m.sqrt(16) # => True # Python modules are just ordinary python files. You # can write your own, and import them. The name of the @@ -698,7 +698,7 @@ def say(say_please=False): return msg, say_please -print(say()) # Can you buy me a beer? +print(say()) # Can you buy me a beer? print(say(say_please=True)) # Can you buy me a beer? Please! I am poor :( ``` -- cgit v1.2.3 From e1d2f8c718858323e1716cc0bde4c652e9b87ce6 Mon Sep 17 00:00:00 2001 From: Ankit Aggarwal Date: Wed, 14 Oct 2015 10:27:25 +0530 Subject: Updated the input() method usage and description --- python.html.markdown | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/python.html.markdown b/python.html.markdown index 95146ca8..11642ff8 100644 --- a/python.html.markdown +++ b/python.html.markdown @@ -4,7 +4,6 @@ contributors: - ["Louie Dinh", "http://ldinh.ca"] - ["Amin Bandali", "http://aminbandali.com"] - ["Andre Polykanine", "https://github.com/Oire"] - - ["Ankit Aggarwal", "http://ankitaggarwal.me"] filename: learnpython.py --- @@ -146,8 +145,10 @@ bool("") # => False print "I'm Python. Nice to meet you!" # Simple way to get input data from console -input_string_var = raw_input("Enter some data: ") # Data is stored as a string -input_number_var = input("Enter a number: ") # Data is stored as a number +input_string_var = raw_input("Enter some data: ") # Returns the data as a string +input_var = input("Enter some data: ") # Evaluates the data as python code +# Warning: Caution is recommended for input() method usage +# Note: In python 3, input() is deprecated and raw_input() is renamed to input() # No need to declare variables before assigning to them. some_var = 5 # Convention is to use lower_case_with_underscores -- cgit v1.2.3 From da556f64f982e11a299db6aa38ab4c260eab11d9 Mon Sep 17 00:00:00 2001 From: Romin Irani Date: Wed, 14 Oct 2015 12:03:05 +0530 Subject: Added Go Mobile information --- go.html.markdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/go.html.markdown b/go.html.markdown index 646a5650..a857a76c 100644 --- a/go.html.markdown +++ b/go.html.markdown @@ -423,3 +423,5 @@ idioms. Or you can click on a function name in [the documentation](http://golang.org/pkg/) and the source code comes up! Another great resource to learn Go is [Go by example](https://gobyexample.com/). + +Go Mobile adds support for mobile platforms (Android and iOS). You can write all-Go native mobile apps or write a library that contains bindings from a Go package, which can be invoked via Java (Android) and Objective-C (iOS). Check out the [Go Mobile page](https://github.com/golang/go/wiki/Mobile) for more information. -- cgit v1.2.3 From b4535eaae356e7c0977c29bbb25464d9e5034e6f Mon Sep 17 00:00:00 2001 From: Levi Bostian Date: Wed, 14 Oct 2015 09:45:13 -0500 Subject: Fix header to hopefully bring back ruby to the site. --- ruby.html.markdown | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ruby.html.markdown b/ruby.html.markdown index c10255d8..0e798706 100644 --- a/ruby.html.markdown +++ b/ruby.html.markdown @@ -12,8 +12,7 @@ contributors: - ["Dzianis Dashkevich", "https://github.com/dskecse"] - ["Levi Bostian", "https://github.com/levibostian"] - ["Rahil Momin", "https://github.com/iamrahil"] - - ["Gabriel Halley", https://github.com/ghalley] - + - ["Gabriel Halley", https://github.com/ghalley"] --- ```ruby -- cgit v1.2.3 From 223c8140a0392f3a0a33b93222597de7a68679e4 Mon Sep 17 00:00:00 2001 From: Awal Garg Date: Wed, 14 Oct 2015 20:41:36 +0530 Subject: clarify that args' names are not required in proto with obligatory conventional warning --- c.html.markdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/c.html.markdown b/c.html.markdown index 3339032f..7c64cffe 100644 --- a/c.html.markdown +++ b/c.html.markdown @@ -54,6 +54,8 @@ int function_2(void); // Must declare a 'function prototype' before main() when functions occur after // your main() function. int add_two_ints(int x1, int x2); // function prototype +// although `int add_two_ints(int, int);` is also valid (no need to name the args), +// it is recommended to name arguments in the prototype as well for easier inspection // Your program's entry point is a function called // main with an integer return type. -- cgit v1.2.3 From 4599cd319fd409ddc697feffb607697285b26368 Mon Sep 17 00:00:00 2001 From: Awal Garg Date: Wed, 14 Oct 2015 20:44:45 +0530 Subject: [c/en] clarify common tripping point of newbies int foo () { printf("bar\n"); int x; // this is not valid in C89+ } --- c.html.markdown | 3 +++ 1 file changed, 3 insertions(+) diff --git a/c.html.markdown b/c.html.markdown index 3339032f..8d4cfd93 100644 --- a/c.html.markdown +++ b/c.html.markdown @@ -74,6 +74,9 @@ int main (int argc, char** argv) /////////////////////////////////////// // Types /////////////////////////////////////// + + // All variables MUST be declared at the top of the current block scope + // we declare them dynamically along the code for the sake of the tutorial // ints are usually 4 bytes int x_int = 0; -- cgit v1.2.3 From f4022052471d6dc0a9c2fb8794e1352253b4c5ad Mon Sep 17 00:00:00 2001 From: Awal Garg Date: Wed, 14 Oct 2015 21:10:28 +0530 Subject: [bash/en] use $var with quotes in conditions --- bash.html.markdown | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/bash.html.markdown b/bash.html.markdown index 191f916a..211d2944 100644 --- a/bash.html.markdown +++ b/bash.html.markdown @@ -90,17 +90,26 @@ else echo "Your name is your username" fi +# NOTE: if $Name is empty, bash sees the above condition as: +if [ -ne $USER ] +# which is invalid syntax +# so the "safe" way to use potentially empty variables in bash is: +if [ "$Name" -ne $USER ] ... +# which, when $Name is empty, is seen by bash as: +if [ "" -ne $USER ] ... +# which works as expected + # There is also conditional execution echo "Always executed" || echo "Only executed if first command fails" echo "Always executed" && echo "Only executed if first command does NOT fail" # To use && and || with if statements, you need multiple pairs of square brackets: -if [ $Name == "Steve" ] && [ $Age -eq 15 ] +if [ "$Name" == "Steve" ] && [ "$Age" -eq 15 ] then echo "This will run if $Name is Steve AND $Age is 15." fi -if [ $Name == "Daniya" ] || [ $Name == "Zach" ] +if [ "$Name" == "Daniya" ] || [ "$Name" == "Zach" ] then echo "This will run if $Name is Daniya OR Zach." fi -- cgit v1.2.3 From a8b32c362bccedf01aa7bac0b77eff8f16c88482 Mon Sep 17 00:00:00 2001 From: Ankit Aggarwal Date: Wed, 14 Oct 2015 21:16:18 +0530 Subject: Added instructions for input operations in Python3 --- python3.html.markdown | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python3.html.markdown b/python3.html.markdown index f3f4dd37..a1125c73 100644 --- a/python3.html.markdown +++ b/python3.html.markdown @@ -160,6 +160,10 @@ print("I'm Python. Nice to meet you!") # => I'm Python. Nice to meet you! # Use the optional argument end to change the end character. print("Hello, World", end="!") # => Hello, World! +# Simple way to get input data from console +input_string_var = input("Enter some data: ") # Returns the data as a string +# Note: In earlier versions of Python, input() method was named as raw_input() + # No need to declare variables before assigning to them. # Convention is to use lower_case_with_underscores some_var = 5 -- cgit v1.2.3 From d2a8a7f161b70148c541326989d0c39f342217ad Mon Sep 17 00:00:00 2001 From: ScheRas Date: Wed, 14 Oct 2015 21:11:05 +0200 Subject: Fixed typo --- cs-cz/python3.html.markdown | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cs-cz/python3.html.markdown b/cs-cz/python3.html.markdown index 11c8a654..6d2fd1eb 100644 --- a/cs-cz/python3.html.markdown +++ b/cs-cz/python3.html.markdown @@ -48,7 +48,7 @@ Poznámka: Tento článek je zaměřen na Python 3. Zde se můžete [naučit sta -5 // 3 # => -2 -5.0 // 3.0 # => -2.0 -# Pokud použiteje desetinné číslo, výsledek je jím také +# Pokud použijete desetinné číslo, výsledek je jím také 3 * 2.0 # => 6.0 # Modulo @@ -420,7 +420,7 @@ next(iterator) # Vyhodí StopIteration ## 4. Funkce #################################################### -# Pro vytvoření nové funkce použijte def +# Pro vytvoření nové funkce použijte klíčové slovo def def secist(x, y): print("x je {} a y je {}".format(x, y)) return x + y # Hodnoty se vrací pomocí return @@ -520,7 +520,7 @@ class Clovek(object): # podtržítka na začátku a na konci značí, že se jedná o atribut nebo # objekt využívaný Pythonem ke speciálním účelům, ale můžete sami # definovat jeho chování. Metody jako __init__, __str__, __repr__ - # a další se nazývají "magické metody". Nikdy nepoužívejte toto + # a další se nazývají "magické metody". Nikdy nepoužívejte toto # speciální pojmenování pro běžné metody. def __init__(self, jmeno): # Přiřazení parametru do atributu instance jmeno -- cgit v1.2.3 From 6cdd2a910292c8fa1323ed8fb4e241caa0b3a75b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Wo=C5=BAniczak?= Date: Wed, 14 Oct 2015 21:31:04 +0200 Subject: Superfluous spaces removed in some tags in 'XML', where no attributes were present --- xml.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xml.html.markdown b/xml.html.markdown index 4d33e614..547deb08 100644 --- a/xml.html.markdown +++ b/xml.html.markdown @@ -83,7 +83,7 @@ With this tool, you can check the XML data outside the application logic. - Everyday Italian + Everyday Italian 30.00 @@ -121,7 +121,7 @@ With this tool, you can check the XML data outside the application logic. - Everyday Italian + Everyday Italian 30.00 -- cgit v1.2.3 From 7a885b86c6b7054aaf48275c252de6ccfc718098 Mon Sep 17 00:00:00 2001 From: Sean Corrales Date: Wed, 14 Oct 2015 15:22:46 -0500 Subject: Adding sections on Sass functions, import, partials, and math operations. Adding some comments regarding best practices. Adding section on compatibility. --- sass.html.markdown | 215 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 215 insertions(+) diff --git a/sass.html.markdown b/sass.html.markdown index 509aee9b..02bec47f 100644 --- a/sass.html.markdown +++ b/sass.html.markdown @@ -3,6 +3,7 @@ language: sass filename: learnsass.scss contributors: - ["Laura Kyle", "https://github.com/LauraNK"] + - ["Sean Corrales", "https://github.com/droidenator"] --- Sass is a CSS extension language that adds features such as variables, nesting, mixins and more. @@ -11,6 +12,7 @@ Sass (and other preprocessors, such as [Less](http://lesscss.org/)) help develop Sass has two different syntax options to choose from. SCSS, which has the same syntax as CSS but with the added features of Sass. Or Sass (the original syntax), which uses indentation rather than curly braces and semicolons. This tutorial is written using SCSS. +If you're already familiar with CSS3, you'll be able to pick up Sass relatively quickly. It does not provide any new styling options but rather the tools to write your CSS more efficiently and make maintenance much easier. ```scss @@ -121,6 +123,69 @@ div { +/*Functions +==============================*/ + + + +/* Sass provides functions that can be used to accomplish a variety of + tasks. Consider the following */ + +/* Functions can be invoked by using their name and passing in the + required arguments */ +body { + width: round(10.25px); +} + +.footer { + background-color: fade_out(#000000, 0.25) +} + +/* Compiles to: */ + +body { + width: 10px; +} + +.footer { + background-color: rgba(0, 0, 0, 0.75); +} + +/* You may also define your own functions. Functions are very similar to + mixins. When trying to choose between a function or a mixin, remember + that mixins are best for generating CSS while functions are better for + logic that might be used throughout your Sass code. The examples in + the Math Operators' section are ideal candidates for becoming a reusable + function. */ + +/* This function will take a target size and the parent size and calculate + and return the percentage */ + +@function calculate-percentage($target-size, $parent-size) { + @return $target-size / $parent-size * 100%; +} + +$main-content: calculate-percentage(600px, 960px); + +.main-content { + width: $main-content; +} + +.sidebar { + width: calculate-percentage(300px, 960px); +} + +/* Compiles to: */ + +.main-content { + width: 62.5%; +} + +.sidebar { + width: 31.25%; +} + + /*Extend (Inheritance) ==============================*/ @@ -150,6 +215,12 @@ div { border-color: #22df56; } +/* Extending a CSS statement is preferable to creating a mixin + because of the way it groups together the classes that all share + the same base styling. If this was done with a mixin, the width, + height, and border would be duplicated for each statement that + called the mixin. While it won't affect your workflow, it will + add unnecessary bloat to the files created by the Sass compiler. */ @@ -172,6 +243,7 @@ ul { /* '&' will be replaced by the parent selector. */ /* You can also nest pseudo-classes. */ /* Keep in mind that over-nesting will make your code less maintainable. +Best practices recommend going no more than 3 levels deep when nesting. For example: */ ul { @@ -212,6 +284,140 @@ ul li a { +/*Partials and Imports +==============================*/ + + + +/* Sass allows you to create partial files. This can help keep your Sass + code modularized. Partial files should begin with an '_', e.g. _reset.css. + Partials are not generated into CSS. */ + +/* Consider the following CSS which we'll put in a file called _reset.css */ + +html, +body, +ul, +ol { + margin: 0; + padding: 0; +} + +/* Sass offers @import which can be used to import partials into a file. + This differs from the traditional CSS @import statement which makes + another HTTP request to fetch the imported file. Sass takes the + imported file and combines it with the compiled code. */ + +@import 'reset'; + +body { + font-size: 16px; + font-family: Helvetica, Arial, Sans-serif; +} + +/* Compiles to: */ + +html, body, ul, ol { + margin: 0; + padding: 0; +} + +body { + font-size: 16px; + font-family: Helvetica, Arial, Sans-serif; +} + + + +/*Placeholder Selectors +==============================*/ + + + +/* Placeholders are useful when creating a CSS statement to extend. If you + wanted to create a CSS statement that was exclusively used with @extend, + you can do so using a placeholder. Placeholders begin with a '%' instead + of '.' or '#'. Placeholders will not appear in the compiled CSS. */ + +%content-window { + font-size: 14px; + padding: 10px; + color: #000; + border-radius: 4px; +} + +.message-window { + @extend %content-window; + background-color: #0000ff; +} + +/* Compiles to: */ + +.message-window { + font-size: 14px; + padding: 10px; + color: #000; + border-radius: 4px; +} + +.message-window { + background-color: #0000ff; +} + + + +/*Math Operations +==============================*/ + + + +/* Sass provides the following operators: +, -, *, /, and %. These can + be useful for calculating values directly in your Sass files instead + of using values that you've already calculated by hand. Below is an example + of a setting up a simple two column design. */ + +$content-area: 960px; +$main-content: 600px; +$sidebar-content: 300px; + +$main-size: $main-content / $content-area * 100%; +$sidebar-size: $sidebar-content / $content-area * 100%; +$gutter: 100% - ($main-size + $sidebar-size); + +body { + width: 100%; +} + +.main-content { + width: $main-size; +} + +.sidebar { + width: $sidebar-size; +} + +.gutter { + width: $gutter; +} + +/* Compiles to: */ + +body { + width: 100%; +} + +.main-content { + width: 62.5%; +} + +.sidebar { + width: 31.25%; +} + +.gutter { + width: 6.25%; +} + ``` @@ -226,6 +432,15 @@ Because people were constantly writing it as "SASS", the creator of the language If you want to play with Sass in your browser, check out [SassMeister](http://sassmeister.com/). You can use either syntax, just go into the settings and select either Sass or SCSS. + +## Compatibility + +Sass can be used in any project as long as you have a program to compile it +into CSS. You'll want to verify that the CSS you're using is compatible +with your target browsers. + +[QuirksMode CSS](http://www.quirksmode.org/css/) and [CanIUse](http://caniuse.com) are great resources for checking compatibility. + ## Further reading * [Official Documentation](http://sass-lang.com/documentation/file.SASS_REFERENCE.html) -- cgit v1.2.3 From b5bd5d7ba2dd6cc857f1bdf574eb1e7b3b7206aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Su=C3=A1rez?= Date: Thu, 15 Oct 2015 00:05:18 +0200 Subject: Fix some typos in LaTeX article --- latex.html.markdown | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/latex.html.markdown b/latex.html.markdown index 146e8d45..fe2ddf43 100644 --- a/latex.html.markdown +++ b/latex.html.markdown @@ -12,7 +12,7 @@ filename: learn-latex.tex % LaTeX is NOT a "What You See Is What You Get" word processing software like % MS Word, or OpenOffice Writer -% Every Latex command starts with a backslash (\) +% Every LaTeX command starts with a backslash (\) % LaTeX documents start with a defining the type of document it's compiling % Other document types include book, report, presentations, etc. @@ -45,7 +45,7 @@ filename: learn-latex.tex % but before the main sections of the body. % This command is available in the document classes article and report. \begin{abstract} - LaTex documentation written as LaTex! How novel and totally not my idea! + LaTeX documentation written as LaTeX! How novel and totally not my idea! \end{abstract} % Section commands are intuitive. @@ -63,8 +63,8 @@ I think we need another one Much better now. \label{subsec:pythagoras} -% By using the asterisk we can suppress Latex's inbuilt numbering. -% This works for other Latex commands as well. +% By using the asterisk we can suppress LaTeX's inbuilt numbering. +% This works for other LaTeX commands as well. \section*{This is an unnumbered section} However not all sections have to be numbered! @@ -74,7 +74,7 @@ a line \\ needs \\ to \\ break \\ you add \textbackslash\textbackslash to the source code. \\ \section{Lists} -Lists are one of the easiest things to create in Latex! I need to go shopping +Lists are one of the easiest things to create in LaTeX! I need to go shopping tomorrow, so let's make a grocery list. \begin{enumerate} % This creates an "enumerate" environment. % \item tells the enumerate to increment @@ -106,7 +106,7 @@ Here's how you state all y that belong to X, $\forall$ x $\in$ X. \\ % The opposite also holds true. Variable can also be rendered in math-mode. My favorite Greek letter is $\xi$. I also like $\beta$, $\gamma$ and $\sigma$. -I haven't found a Greek letter that yet that Latex doesn't know about! +I haven't found a Greek letter that yet that LaTeX doesn't know about! Operators are essential parts of a mathematical document: trigonometric functions ($\sin$, $\cos$, $\tan$), @@ -126,7 +126,7 @@ $^{10}/_{7}$ % \frac{numerator}{denominator} $\frac{n!}{k!(n - k)!}$ \\ -We can also insert equations in an "equation environment." +We can also insert equations in an "equation environment". % Display math with the equation 'environment' \begin{equation} % enters math-mode @@ -141,7 +141,7 @@ figures, equations, sections, etc. Summations and Integrals are written with sum and int commands: -% Some latex compilers will complain if there are blank lines +% Some LaTeX compilers will complain if there are blank lines % In an equation environment. \begin{equation} \sum_{i=0}^{5} f_{i} @@ -181,9 +181,9 @@ We can also insert Tables in the same way as figures. % \section{Hyperlinks} % Coming soon -\section{Getting Latex to not compile something (i,e, Source Code)} -Let's say we want to include some code into our Latex document, -we would then need Latex to not try and interpret that text and +\section{Getting LaTeX to not compile something (i.e. Source Code)} +Let's say we want to include some code into our LaTeX document, +we would then need LaTeX to not try and interpret that text and instead just print it to the document. We do this we a verbatim environment. @@ -198,7 +198,7 @@ environment. \section{Compiling} By now you're probably wondering how to compile this fabulous document -and look at the glorious glory that is a Latex pdf. +and look at the glorious glory that is a LaTeX pdf. (yes, this document actually does compiles). \\ Getting to the final document using LaTeX consists of the following steps: \begin{enumerate} @@ -206,7 +206,7 @@ Getting to the final document using LaTeX consists of the following steps: \item Compile source code to produce a pdf. The compilation step looks something like this (in Linux): \\ \begin{verbatim} - $pdflatex learn-latex.tex learn-latex.pdf + $pdfLaTeX learn-LaTeX.tex learn-LaTeX.pdf \end{verbatim} \end{enumerate} @@ -228,4 +228,4 @@ That's all for now! ## More on LaTeX * The amazing LaTeX wikibook: [https://en.wikibooks.org/wiki/LaTeX](https://en.wikibooks.org/wiki/LaTeX) -* An actual tutorial: [http://www.latex-tutorial.com/](http://www.latex-tutorial.com/) +* An actual tutorial: [http://www.LaTeX-tutorial.com/](http://www.LaTeX-tutorial.com/) -- cgit v1.2.3 From 2605af62489e5c184ab2166d264c8ccbbb413d87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Su=C3=A1rez?= Date: Thu, 15 Oct 2015 00:11:05 +0200 Subject: Fix more typos --- latex.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/latex.html.markdown b/latex.html.markdown index fe2ddf43..e180e622 100644 --- a/latex.html.markdown +++ b/latex.html.markdown @@ -206,7 +206,7 @@ Getting to the final document using LaTeX consists of the following steps: \item Compile source code to produce a pdf. The compilation step looks something like this (in Linux): \\ \begin{verbatim} - $pdfLaTeX learn-LaTeX.tex learn-LaTeX.pdf + $pdflatex learn-latex.tex learn-latex.pdf \end{verbatim} \end{enumerate} @@ -228,4 +228,4 @@ That's all for now! ## More on LaTeX * The amazing LaTeX wikibook: [https://en.wikibooks.org/wiki/LaTeX](https://en.wikibooks.org/wiki/LaTeX) -* An actual tutorial: [http://www.LaTeX-tutorial.com/](http://www.LaTeX-tutorial.com/) +* An actual tutorial: [http://www.latex-tutorial.com/](http://www.latex-tutorial.com/) -- cgit v1.2.3 From 328ceb1a94f0fc6736e001ad0e7b6646173ca207 Mon Sep 17 00:00:00 2001 From: Elton Viana Date: Wed, 14 Oct 2015 21:44:42 -0300 Subject: Some extra information --- c.html.markdown | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/c.html.markdown b/c.html.markdown index db2ac930..aaf176c1 100644 --- a/c.html.markdown +++ b/c.html.markdown @@ -221,7 +221,7 @@ int main(void) { 0 || 1; // => 1 (Logical or) 0 || 0; // => 0 - // Conditional expression ( ? : ) + // Conditional ternary expression ( ? : ) int e = 5; int f = 10; int z; @@ -291,6 +291,8 @@ int main(void) { for (i = 0; i <= 5; i++) { ; // use semicolon to act as the body (null statement) } + // Or + for (i = 0; i <= 5; i++); // branching with multiple choices: switch() switch (a) { -- cgit v1.2.3 From 27bb1a1e80b727b00b5ea8045d4bfa07eb1293bd Mon Sep 17 00:00:00 2001 From: Zachary Ferguson Date: Wed, 14 Oct 2015 21:59:42 -0400 Subject: Removed separate code section Removed the separate code section for header files --- c.html.markdown | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/c.html.markdown b/c.html.markdown index 0c4916ac..5e8e13c1 100644 --- a/c.html.markdown +++ b/c.html.markdown @@ -628,9 +628,7 @@ typedef void (*my_fnp_type)(char *); // , | left to right // //---------------------------------------------------// -``` - -### Header Files +/******************************* Header Files ********************************** Header files are an important part of c as they allow for the connection of c source files and can simplify code and definitions by seperating them into @@ -640,8 +638,8 @@ Header files are syntaxtically similar to c source files but reside in ".h" files. They can be included in your c source file by using the precompiler command #include "example.h", given that example.h exists in the same directory as the c file. +*/ -```h /* A safe guard to prevent the header from being defined too many times. This */ /* happens in the case of circle dependency, the contents of the header is */ /* already defined. */ -- cgit v1.2.3 From 28751f213493d57ce06983f91077dd2d51e06821 Mon Sep 17 00:00:00 2001 From: Nimit Shah Date: Thu, 15 Oct 2015 19:37:44 +0530 Subject: A minor typo. XML is singular so the word should be carries --- xml.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xml.html.markdown b/xml.html.markdown index 547deb08..efc2340f 100644 --- a/xml.html.markdown +++ b/xml.html.markdown @@ -7,7 +7,7 @@ contributors: XML is a markup language designed to store and transport data. -Unlike HTML, XML does not specify how to display or to format data, just carry it. +Unlike HTML, XML does not specify how to display or to format data, it just carries it. * XML Syntax -- cgit v1.2.3 From d136abe95434a94bd70a981b1ea2bf0ee1dbf636 Mon Sep 17 00:00:00 2001 From: Gautam Kotian Date: Thu, 15 Oct 2015 07:31:48 +0200 Subject: Improve code comments --- d.html.markdown | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/d.html.markdown b/d.html.markdown index 88a83e41..ea1c1700 100644 --- a/d.html.markdown +++ b/d.html.markdown @@ -74,16 +74,18 @@ are passed to functions by value (i.e. copied) and classes are passed by referen we can use templates to parameterize all of these on both types and values! ```c -// Here, T is a type parameter. Think from C++/C#/Java +// Here, 'T' is a type parameter. Think '' from C++/C#/Java. struct LinkedList(T) { T data = null; - LinkedList!(T)* next; // The ! is used to instaniate a parameterized type. Again, think + + // Use '!' to instantiate a parameterized type. Again, think ''. + LinkedList!(T)* next; } class BinTree(T) { T data = null; - // If there is only one template parameter, we can omit the parentheses + // If there is only one template parameter, we can omit the parentheses. BinTree!T left; BinTree!T right; } @@ -98,13 +100,11 @@ enum Day { Saturday, } -// Use alias to create abbreviations for types - +// Use alias to create abbreviations for types. alias IntList = LinkedList!int; alias NumTree = BinTree!double; // We can create function templates as well! - T max(T)(T a, T b) { if(a < b) return b; @@ -112,9 +112,8 @@ T max(T)(T a, T b) { return a; } -// Use the ref keyword to ensure pass by referece. -// That is, even if a and b are value types, they -// will always be passed by reference to swap +// Use the ref keyword to ensure pass by reference. That is, even if 'a' and 'b' +// are value types, they will always be passed by reference to 'swap()'. void swap(T)(ref T a, ref T b) { auto temp = a; @@ -122,13 +121,13 @@ void swap(T)(ref T a, ref T b) { b = temp; } -// With templates, we can also parameterize on values, not just types +// With templates, we can also parameterize on values, not just types. class Matrix(uint m, uint n, T = int) { T[m] rows; T[n] columns; } -auto mat = new Matrix!(3, 3); // We've defaulted type T to int +auto mat = new Matrix!(3, 3); // We've defaulted type 'T' to 'int'. ``` @@ -138,21 +137,20 @@ have the syntax of POD structures (`structure.x = 7`) with the semantics of getter and setter methods (`object.setX(7)`)! ```c -// Consider a class parameterized on a types T, U - +// Consider a class parameterized on types 'T' & 'U'. class MyClass(T, U) { T _data; U _other; - } -// And "getter" and "setter" methods like so +// And "getter" and "setter" methods like so: class MyClass(T, U) { T _data; U _other; - // Constructors are always named `this` + // Constructors are always named 'this'. this(T t, U u) { + // This will call the setter methods below. data = t; other = u; } @@ -175,8 +173,8 @@ class MyClass(T, U) { _other = u; } } -// And we use them in this manner +// And we use them in this manner: void main() { auto mc = MyClass!(int, string); -- cgit v1.2.3 From a77d0264c9df6ac2ac4c1e2202e352704580c579 Mon Sep 17 00:00:00 2001 From: Gautam Kotian Date: Thu, 15 Oct 2015 07:32:48 +0200 Subject: Make the code compilable and add some additional comments to explain what's happening. --- d.html.markdown | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/d.html.markdown b/d.html.markdown index ea1c1700..80c1dc65 100644 --- a/d.html.markdown +++ b/d.html.markdown @@ -176,13 +176,21 @@ class MyClass(T, U) { // And we use them in this manner: void main() { - auto mc = MyClass!(int, string); + auto mc = new MyClass!(int, string)(7, "seven"); - mc.data = 7; - mc.other = "seven"; + // Import the 'stdio' module from the standard library for writing to + // console (imports can be local to a scope). + import std.stdio; - writeln(mc.data); - writeln(mc.other); + // Call the getters to fetch the values. + writefln("Earlier: data = %d, str = %s", mc.data, mc.other); + + // Call the setters to assign new values. + mc.data = 8; + mc.other = "eight"; + + // Call the getters again to fetch the new values. + writefln("Later: data = %d, str = %s", mc.data, mc.other); } ``` -- cgit v1.2.3 From 8417366a1b2d2b7bce35e2e4a4fdccee2a60f457 Mon Sep 17 00:00:00 2001 From: Zachary Ferguson Date: Thu, 15 Oct 2015 14:50:20 -0400 Subject: Cleaned up c file --- c.html.markdown | 4 ---- 1 file changed, 4 deletions(-) diff --git a/c.html.markdown b/c.html.markdown index 7bb363b3..a8f71057 100644 --- a/c.html.markdown +++ b/c.html.markdown @@ -6,12 +6,8 @@ contributors: - ["Árpád Goretity", "http://twitter.com/H2CO3_iOS"] - ["Jakub Trzebiatowski", "http://cbs.stgn.pl"] - ["Marco Scannadinari", "https://marcoms.github.io"] -<<<<<<< HEAD - ["Zachary Ferguson", "https://github.io/zfergus2"] -======= - ["himanshu", "https://github.com/himanshu81494"] - ->>>>>>> refs/remotes/adambard/master --- Ah, C. Still **the** language of modern high-performance computing. -- cgit v1.2.3