summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--csharp.html.markdown2
-rw-r--r--fa-ir/brainfuck.html.markdown81
-rw-r--r--java.html.markdown34
-rw-r--r--javascript.html.markdown13
-rw-r--r--julia.html.markdown34
-rw-r--r--ko-kr/brainfuck-kr.html.markdown3
-rw-r--r--php.html.markdown2
-rw-r--r--pt-br/java-pt.html.markdown435
-rw-r--r--python.html.markdown4
-rw-r--r--ruby.html.markdown4
-rw-r--r--zh-cn/bash-cn.html.markdown148
-rw-r--r--zh-cn/brainfuck-cn.html.markdown70
12 files changed, 787 insertions, 43 deletions
diff --git a/csharp.html.markdown b/csharp.html.markdown
index 87c2f704..dad0c26b 100644
--- a/csharp.html.markdown
+++ b/csharp.html.markdown
@@ -233,7 +233,7 @@ on a new line! ""Wow!"", the masses cried";
int fooWhile = 0;
while (fooWhile < 100)
{
- //Iterated 99 times, fooWhile 0->99
+ //Iterated 100 times, fooWhile 0->99
fooWhile++;
}
diff --git a/fa-ir/brainfuck.html.markdown b/fa-ir/brainfuck.html.markdown
new file mode 100644
index 00000000..ef2bcba3
--- /dev/null
+++ b/fa-ir/brainfuck.html.markdown
@@ -0,0 +1,81 @@
+---
+language: brainfuck
+contributors:
+ - ["Mohammad Valipour", "https://github.com/mvalipour"]
+lang: fa-ir
+---
+
+<p dir='rtl'>برین فاک زبان برنامه نویسی تورینگ کامل بی نهایت ساده ایست که دارای فقط هشت</p>
+<p dir='rtl'>دستور است.</p>
+
+<p dir='rtl'>هر کارکتری به جر کارکتر های زیر در این زبان در نظر گرفته نمیشود.</p>
+
+
+`>` `<` `+` `-` `.` `,` `[` `]`
+
+<p dir='rtl'>برین فاک به صورت یک آرایه ی سی هزار خانه ای کار میکند که در ابتدا تمامی خانه های آن صفر هستند.</p>
+<p dir='rtl'>همچنین یک اشاره گر در این برنامه به خانه ی فعلی اشاره میکند.</p>
+
+<p dir='rtl'>در زیر هشت دستور این زبان شرح داده شده است:</p>
+
+<p dir='rtl'>`+` : یک عدد به خانه ی فعلی اضافه می کند.
+<p dir='rtl'>`-` : یک عدد از خانه ی فعلی کم می کند. </p>
+<p dir='rtl'>`>` : اشاره گر به خانه ی بعدی میرود -- به راست</p>
+<p dir='rtl'>`<` : اشاره گر به خانه ی قبلی میرود -- به چپ</p>
+<p dir='rtl'>`.` : کارکتر اسکی معادل مقدار خانه ی فعلی را چاپ میکند. -- به عنوان مثال 65 برای A</p>
+<p dir='rtl'>`,` : یک کارکتر را از ورودی خوانده و مقدار آن را در خانه ی فعلی زخیره میکند.</p>
+<p dir='rtl'>`[` : اگر مقدار خانه ی فعلی صفر باشد به محل بسته شدن کروشه جهش میکند. -- و از همه ی دستور های بین آن صرف نظر میشود.</p>
+<p dir='rtl'>در غیر این صورت به دستور بعدی میرود.</p>
+<p dir='rtl'>`]` : اگر مقدار خانه ی فعلی صفر باشد به خانه ی بعدی و در غیر این صورت به محل باز شدن کروشه جهش می کند. -- به عقب</p>
+
+<p dir='rtl'>دو علامت کروشه امکان ایجاد حلقه را فراهم میکنند.</p>
+
+<p dir='rtl'>در اینجا یک برنامه ی ساره برین فاک را مشاهده میکنید.</p>
+
+```
+++++++ [ > ++++++++++ < - ] > +++++ .
+```
+
+<p dir='rtl'>این برنامه کارکتر A را بر روی خروجی چاپ میکند.</p>
+<p dir='rtl'>در این برنامه خانه ی اول به عنوان متغیر حلقه و خانه ی دوم برای مقدار عددی A</p>
+<p dir='rtl'>ابتدا عدد شش در خانه ی اول ایجاد شده. سپس برنامه وارد یک حلقه میشود که در هر بار </p>
+<p dir='rtl'>تکرار آن اشاره گر به خانه ی دوم رفته و ده بار به خانه ی فعلی اضافه می کند.</p>
+<p dir='rtl'>-- و در انتهای حلقه به خانه ی اول برگشته تا حلقه کنترل شود</p>
+<p dir='rtl'>بعد از اتمام حلقه به خانه ی دوم میرود و پنج بار به این خانه اضافه کرده و سپس آنرا چاپ میکند.</p>
+
+```
+, [ > + < - ] > .
+```
+
+<p dir='rtl'>در این برنامه ابتدا یک کارکتر از ورودی خوانده می شود. سپس یک حلقه به تعداد بار مقدار</p>
+<p dir='rtl'>عددی کارکتر، یک عدد به خانه ی دوم اضافه می کند. با این کار در واقع برنامه مقدار ورودی را در خانه ی </p>
+<p dir='rtl'>دوم کپی می کند. و در نهایت آن را برروی خروجی چاپ می کند.</p>
+
+<p dir='rtl'>توجه داشته باشید که ردر بالا فواصل بین دستور ها فقط برای خوانایی بیشتر گذاشته شده اند.</p>
+<p dir='rtl'>در واقع برنامه بالا به شکل زیر صحیح می باشد.</p>
+
+```
+,[>+<-]>.
+```
+
+<p dir='rtl'>حال سعی کنید ببینید که برنامه ی زیر چه کاری انجام می دهد؟</p>
+
+```
+,>,< [ > [ >+ >+ << -] >> [- << + >>] <<< -] >>
+```
+
+<p dir='rtl'>این برنامه دو عدد را از ورودی خوانده و با هم ضرب می کند.</p>
+
+<p dir='rtl'>ابتدا دو عدد از ورودی خوانده می شوند. سپس حلقه ی بیرونی بر روی خانه شماره یک شروع میشود.</p>
+<p dir='rtl'>و درون آن حلقه ی دیگری بر روی خانه ی دوم شروع میشود که خانه ی 3 را زیاد میکند.</p>
+<p dir='rtl'>ولی مشکلی که در اینجا به وجود می آید اینست که در پایان حلقه ی دوم مقدار خانه ی 2 صفر شده</p>
+<p dir='rtl'>و مقدار اولیه ی آن از دست رفته است. برای حل این مشکل خانه ی شماره چهار هم زیاد میشود</p>
+<p dir='rtl'>و در پایان حلقه مقدار آن به خانه 2 کپی میشود.</p>
+<p dir='rtl'>در پایان خانه ی شماره 2 حاوی حاصلضرب خواهد بود.</p>
+
+<hr>
+
+<p dir='rtl'>و این همه ی برین فاک بود! خیلی ساده برای یادگیری ولی سنگین برای به کار بردن.</p>
+<p dir='rtl'>حال می توانید برای تفریح مشغول نوشتن برنامه ی های مختلف با آن شوید.</p>
+<p dir='rtl'>و یا یک اجرا کننده برین فاک را با یک زبان دیگر پیاده سازی کنید.</p>
+<p dir='rtl'>و یا اگر خیلی دوست داشتید یک اجرا کننده ی برین فاک با برین فاک بنویسید!!</p>
diff --git a/java.html.markdown b/java.html.markdown
index 3d0cb1d7..b4624d5e 100644
--- a/java.html.markdown
+++ b/java.html.markdown
@@ -26,7 +26,8 @@ import java.util.ArrayList;
// Import all classes inside of java.security package
import java.security.*;
-// Each .java file contains one public class, with the same name as the file.
+// Each .java file contains one outer-level public class, with the same name as
+// the file.
public class LearnJava {
// A program must have a main method as an entry point
@@ -84,7 +85,7 @@ public class LearnJava {
// Char - A single 16-bit Unicode character
char fooChar = 'A';
- // Use final to make a variable immutable
+ // final variables can't be reassigned to another object
final int HOURS_I_WORK_PER_WEEK = 9001;
// Strings
@@ -99,7 +100,7 @@ public class LearnJava {
System.out.println(bazString);
// Arrays
- //The array size must be decided upon declaration
+ //The array size must be decided upon instantiation
//The format for declaring an array is follows:
//<datatype> [] <var name> = new <datatype>[<array size>];
int [] intArray = new int[10];
@@ -161,10 +162,13 @@ public class LearnJava {
// Incrementations
int i = 0;
System.out.println("\n->Inc/Dec-rementation");
- System.out.println(i++); //i = 1. Post-Incrementation
- System.out.println(++i); //i = 2. Pre-Incrementation
- System.out.println(i--); //i = 1. Post-Decrementation
- System.out.println(--i); //i = 0. Pre-Decrementation
+ // The ++ and -- operators increment and decrement by 1 respectively.
+ // If they are placed before the variable, they increment then return;
+ // after the variable they return then increment.
+ System.out.println(i++); //i = 1, prints 0 (post-increment)
+ System.out.println(++i); //i = 2, prints 2 (pre-increment)
+ System.out.println(i--); //i = 1, prints 2 (post-decrement)
+ System.out.println(--i); //i = 0, prints 0 (pre-decrement)
///////////////////////////////////////
// Control Structures
@@ -211,19 +215,19 @@ public class LearnJava {
//Iterated 10 times, fooFor 0->9
}
System.out.println("fooFor Value: " + fooFor);
-
+
// For Each Loop
// An automatic iteration through an array or list of objects.
int[] fooList = {1,2,3,4,5,6,7,8,9};
//for each loop structure => for(<object> : <array_object>)
//reads as: for each object in the array
//note: the object type must match the array.
-
+
for( int bar : fooList ){
//System.out.println(bar);
//Iterates 9 times and prints 1-9 on new lines
}
-
+
// Switch Case
// A switch works with the byte, short, char, and int data types.
// It also works with enumerated types (discussed in Enum Types),
@@ -246,7 +250,7 @@ public class LearnJava {
break;
}
System.out.println("Switch Case Result: " + monthString);
-
+
// Conditional Shorthand
// You can use the '?' operator for quick assignments or logic forks.
// Reads as "If (statement) is true, use <first value>, otherwise, use <second value>"
@@ -294,14 +298,14 @@ public class LearnJava {
trek.speedUp(3); // You should always use setter and getter methods
trek.setCadence(100);
- // toString is a convention to display the value of this Object.
+ // toString returns this Object's string representation.
System.out.println("trek info: " + trek.toString());
} // End main method
} // End LearnJava class
-// You can include other, non-public classes in a .java file
+// You can include other, non-public outer-level classes in a .java file
// Class Declaration Syntax:
@@ -319,7 +323,7 @@ class Bicycle {
String name; // default: Only accessible from within this package
// Constructors are a way of creating classes
- // This is a default constructor
+ // This is a constructor
public Bicycle() {
gear = 1;
cadence = 50;
@@ -327,7 +331,7 @@ class Bicycle {
name = "Bontrager";
}
- // This is a specified constructor (it contains arguments)
+ // This is a constructor that takes arguments
public Bicycle(int startCadence, int startSpeed, int startGear, String name) {
this.gear = startGear;
this.cadence = startCadence;
diff --git a/javascript.html.markdown b/javascript.html.markdown
index 2ac98105..b6d4c8b7 100644
--- a/javascript.html.markdown
+++ b/javascript.html.markdown
@@ -107,10 +107,10 @@ false;
// There's also null and undefined
null; // used to indicate a deliberate non-value
-undefined; // used to indicate a value is not currently present (although undefined
- // is actually a value itself)
+undefined; // used to indicate a value is not currently present (although
+ // undefined is actually a value itself)
-// false, null, undefined, NaN, 0 and "" are falsy, and everything else is truthy.
+// false, null, undefined, NaN, 0 and "" are falsy; everything else is truthy.
// Note that 0 is falsy and "0" is truthy, even though 0 == "0".
///////////////////////////////////
@@ -306,8 +306,8 @@ myObj.myOtherFunc = myOtherFunc;
myObj.myOtherFunc(); // = "HELLO WORLD!"
// When you call a function with the new keyword, a new object is created, and
-// made available to the function via this. Functions designed to be called
-// like this are called constructors.
+// made available to the function via the this keyword. Functions designed to be
+// called like that are called constructors.
var MyConstructor = function(){
this.myNumber = 5;
@@ -323,7 +323,7 @@ myNewObj.myNumber; // = 5
// property __proto__. While this is useful for explaining prototypes it's not
// part of the standard; we'll get to standard ways of using prototypes later.
var myObj = {
- myString: "Hello world!",
+ myString: "Hello world!"
};
var myPrototype = {
meaningOfLife: 42,
@@ -331,6 +331,7 @@ var myPrototype = {
return this.myString.toLowerCase()
}
};
+
myObj.__proto__ = myPrototype;
myObj.meaningOfLife; // = 42
diff --git a/julia.html.markdown b/julia.html.markdown
index 4ebd50ff..c3d2195b 100644
--- a/julia.html.markdown
+++ b/julia.html.markdown
@@ -100,7 +100,7 @@ false
println("I'm Julia. Nice to meet you!")
# You don't declare variables before assigning to them.
-some_var = 5 #=> 5
+some_var = 5 #=> 5
some_var #=> 5
# Accessing a previously unassigned variable is an error
@@ -201,7 +201,7 @@ b = [1,2,3]
append!(a,b) # Now a is [1, 2, 3, 4, 5, 1, 2, 3]
# Check for existence in a list with in
-in(a,1) #=> true
+in(1, a) #=> true
# Examine the length with length
length(a) #=> 8
@@ -218,7 +218,7 @@ end
# Many list functions also work on tuples
length(tup) #=> 3
tup[1:2] #=> (1,2)
-in(tup,2) #=> true
+in(2, tup) #=> true
# You can unpack tuples into variables
a, b, c = (1, 2, 3) #=> (1,2,3) # a is now 1, b is now 2 and c is now 3
@@ -249,14 +249,14 @@ keys(filled_dict)
#=> KeyIterator{Dict{ASCIIString,Int64}}(["three"=>3,"one"=>1,"two"=>2])
# Note - dictionary keys are not sorted or in the order you inserted them.
-# Get all values
+# Get all values
values(filled_dict)
#=> ValueIterator{Dict{ASCIIString,Int64}}(["three"=>3,"one"=>1,"two"=>2])
# Note - Same as above regarding key ordering.
# Check for existence of keys in a dictionary with in, haskey
-in(filled_dict, ("one", 1)) #=> true
-in(filled_dict, ("two", 3)) #=> false
+in(("one", 1), filled_dict) #=> true
+in(("two", 3), filled_dict) #=> false
haskey(filled_dict, "one") #=> true
haskey(filled_dict, 1) #=> false
@@ -281,8 +281,8 @@ filled_set = Set(1,2,2,3,4) #=> Set{Int64}(1,2,3,4)
push!(filled_set,5) #=> Set{Int64}(5,4,2,3,1)
# Check if the values are in the set
-in(filled_set,2) #=> true
-in(filled_set,10) #=> false
+in(2, filled_set) #=> true
+in(10, filled_set) #=> false
# There are functions for set intersection, union, and difference.
other_set = Set(3, 4, 5, 6) #=> Set{Int64}(6,4,5,3)
@@ -396,7 +396,7 @@ varargs(1,2,3) #=> (1,2,3)
# The ... is called a splat.
# We just used it in a function definition.
# It can also be used in a fuction call,
-# where it will splat an Array or Tuple's contents into the argument list.
+# where it will splat an Array or Tuple's contents into the argument list.
Set([1,2,3]) #=> Set{Array{Int64,1}}([1,2,3]) # produces a Set of Arrays
Set([1,2,3]...) #=> Set{Int64}(1,2,3) # this is equivalent to Set(1,2,3)
@@ -423,7 +423,7 @@ end
# You can define functions that take keyword arguments
function keyword_args(;k1=4,name2="hello") # note the ;
return ["k1"=>k1,"name2"=>name2]
-end
+end
keyword_args(name2="ness") #=> ["name2"=>"ness","k1"=>4]
keyword_args(k1="mine") #=> ["k1"=>"mine","name2"=>"hello"]
@@ -511,7 +511,7 @@ end
# The default constructor's arguments are the properties
# of the tyep, in order the order they are listed in the definition
tigger = Tiger(3.5,"orange") #=> Tiger(3.5,"orange")
-
+
# The type doubles as the constructor function for values of that type
sherekhan = typeof(tigger)(5.6,"fire") #=> Tiger(5.6,"fire")
@@ -529,8 +529,8 @@ subtypes(Number) #=> 6-element Array{Any,1}:
# Complex{Float32}
# Complex{Float64}
# Complex{T<:Real}
- # ImaginaryUnit
- # Real
+ # ImaginaryUnit
+ # Real
subtypes(Cat) #=> 0-element Array{Any,1}
# Every type has a super type; use the `super` function to get it.
@@ -565,7 +565,7 @@ end
# When possible, you should use outer constructors rather than inner ones.
####################################################
-## 6. Multiple-Dispatch
+## 6. Multiple-Dispatch
####################################################
# In Julia, all named functions are generic functions
@@ -641,11 +641,11 @@ end
# Also let the cat go first
fight(c::Cat,l::Lion) = println("The cat beats the Lion")
-#=> Warning: New definition
+#=> Warning: New definition
# fight(Cat,Lion) at none:1
-# is ambiguous with
+# is ambiguous with
# fight(Lion,Cat) at none:2.
-# Make sure
+# Make sure
# fight(Lion,Lion)
# is defined first.
#fight (generic function with 4 methods)
diff --git a/ko-kr/brainfuck-kr.html.markdown b/ko-kr/brainfuck-kr.html.markdown
index 661fcfea..c2e4341f 100644
--- a/ko-kr/brainfuck-kr.html.markdown
+++ b/ko-kr/brainfuck-kr.html.markdown
@@ -5,10 +5,11 @@ contributors:
- ["Mathias Bynens", "http://mathiasbynens.be/"]
translators:
- ["JongChan Choi", "http://0xABCDEF.com/"]
+ - ["Peter Lee", "http://peterjlee.com/"]
lang: ko-kr
---
-Brainfuck(f는 대문자로 적지 않습니다)은
+Brainfuck(문장을 시작하는 단어가 아닌이상 첫글자는 대문자를 사용하지 않습니다)은
여덟가지 명령어만으로 튜링-완전한 최소주의 프로그래밍 언어입니다.
```
diff --git a/php.html.markdown b/php.html.markdown
index 226eefff..c3317d59 100644
--- a/php.html.markdown
+++ b/php.html.markdown
@@ -11,7 +11,7 @@ This document describes PHP 5+.
```php
<?php // PHP code must be enclosed with <?php tags
-// If your php file only contains PHP code, it is best practise
+// If your php file only contains PHP code, it is best practice
// to omit the php closing tag.
// Two forward slashes start a one-line comment.
diff --git a/pt-br/java-pt.html.markdown b/pt-br/java-pt.html.markdown
new file mode 100644
index 00000000..e8d5a538
--- /dev/null
+++ b/pt-br/java-pt.html.markdown
@@ -0,0 +1,435 @@
+---
+
+language: java
+contributors:
+ - ["Jake Prather", "http://github.com/JakeHP"]
+ - ["Madison Dickson", "http://github.com/mix3d"]
+translators:
+ - ["Victor Kléber Santos L. Melo", "http://victormelo.com.br/blog"]
+ - ["Renê Douglas N. de Morais", "mailto:rene.douglas.bsi@gmail.com"]
+lang: pt-br
+filename: LearnJava.java
+
+---
+
+Java é uma linguagem de programação de propósito geral, concorrente, baseada em classes e orientada a objetos.
+[Leia mais aqui](http://docs.oracle.com/javase/tutorial/java/index.html)
+
+```java
+// Comentários de uma linha começam com //
+/*
+Comentários de várias linhas são feitos dessa forma.
+*/
+/**
+Comentários JavaDoc são feitos assim. São usados para descrever a Classe ou os atributos da Classe.
+*/
+
+// Importa a classe ArrayList que está dentro do pacote java.util
+import java.util.ArrayList;
+// Importa todas as classes que estão dentro do pacote java.security
+import java.security.*;
+
+// Cada arquivo .java contém uma classe pública, com o mesmo nome do arquivo.
+public class LearnJava {
+
+ // Um programa precisa ter um método main como um ponto de entrada.
+ public static void main (String[] args) {
+
+ // O System.out.println é usado para imprimir no console
+ System.out.println("Olá Mundo!");
+ System.out.println(
+ "Integer: " + 10 +
+ " Double: " + 3.14 +
+ " Boolean: " + true);
+
+ // Para imprimir sem inserir uma nova lina, use o System.out.print
+ System.out.print("Olá ");
+ System.out.print("Mundo");
+
+
+ ///////////////////////////////////////
+ // Tipos & Variáveis
+ ///////////////////////////////////////
+
+ // Declara-se variáveis usando <tipo> <nome> [
+ // Byte - inteiro de 8 bits com sinal complementado a dois
+ // (-128 <= byte <= 127)
+ byte fooByte = 100;
+
+ // Short - inteiro de 16 bits com sinal complementado a dois
+ // (-32,768 <= short <= 32,767)
+ short fooShort = 10000;
+
+ // Integer - inteiro de 32 bits com sinal complementado a dois
+ // (-2,147,483,648 <= int <= 2,147,483,647)
+ int fooInt = 1;
+
+ // Long - inteiro de 64 bits com sinal complementado a dois
+ // (-9,223,372,036,854,775,808 <= long <= 9,223,372,036,854,775,807)
+ long fooLong = 100000L;
+ // L é usado para indicar que o valor da variável é do tipo Long;
+ // sem o L, tudo é tratado como inteiro por padrão.
+
+ // Nota: Java não tem tipos sem sinal
+
+ // Float - Ponto Flutuante 32-bits, de precisão simples no padrão IEEE 754
+ float fooFloat = 234.5f;
+ // f é usado para indicar que o valor da variável é do tipo float;
+ // caso contrário, ela é tratada como double.
+
+ // Double - Ponto Flutuante 64-bits, de precisão dupla no padrão IEEE 754
+ double fooDouble = 123.4;
+
+ // Boolean - true & false
+ boolean fooBoolean = true;
+ boolean barBoolean = false;
+
+ // Char - Um caractere Unicode de 16 bits
+ char fooChar = 'A';
+
+ // Usa-se o final para fazer com que a variável seja imutável.
+ final int HORAS_QUE_TRABALHEI_POR_SEMANA = 9001;
+
+ // Strings
+ String fooString = "Aqui está minha String!";
+
+ // \n é um caractere de escape que inicia uma nova linha
+ String barString = "Imprimir em uma nova linha?\nSem problemas!";
+ // \t é um caractere de escape que adiciona um caractere de tabulação
+ String bazString = "Você quer adicionar tabulação?\tSem problemas!";
+ System.out.println(fooString);
+ System.out.println(barString);
+ System.out.println(bazString);
+
+ // Arrays
+ //O tamanho do array precisa ser determinado na sua declaração
+ //O formato para declarar um array é:
+ //<tipo de dado> [] <nome da variável> = new <tipo de dado>[<tamanho do array>];
+ int [] intArray = new int[10];
+ String [] stringArray = new String[1];
+ boolean [] booleanArray = new boolean[100];
+
+ // Outra maneira de declarar e inicializar um array
+ int [] y = {9000, 1000, 1337};
+
+ // Indexando um array - Acessando um elemento
+ System.out.println("intArray no índice 0: " + intArray[0]);
+
+ // O primeiro termo de um array é o 0 e eles são mutáveis.
+ intArray[1] = 1;
+ System.out.println("intArray no índice 1: " + intArray[1]); // => 1
+
+ // Outras estruturas que devem ser vistas
+ // ArrayLists - São parecidos com os arrays, porém oferecem mais funcionalidades
+ // e o tamanho é mutável.
+ // LinkedLists
+ // Maps
+ // HashMaps
+
+ ///////////////////////////////////////
+ // Operadores
+ ///////////////////////////////////////
+ System.out.println("\n->Operadores");
+
+ int i1 = 1, i2 = 2; // Forma abreviada de escrever múltiplas declarações.
+
+ // Aritmética é feita da forma convencional
+ System.out.println("1+2 = " + (i1 + i2)); // => 3
+ System.out.println("2-1 = " + (i2 - i1)); // => 1
+ System.out.println("2*1 = " + (i2 * i1)); // => 2
+ System.out.println("1/2 = " + (i1 / i2)); // => 0 (0.5 arredondado para baixo)
+
+ // Módulo
+ System.out.println("11%3 = "+(11 % 3)); // => 2
+
+ // Operadores de comparação
+ System.out.println("3 == 2? " + (3 == 2)); // => false
+ System.out.println("3 != 2? " + (3 != 2)); // => true
+ System.out.println("3 > 2? " + (3 > 2)); // => true
+ System.out.println("3 < 2? " + (3 < 2)); // => false
+ System.out.println("2 <= 2? " + (2 <= 2)); // => true
+ System.out.println("2 >= 2? " + (2 >= 2)); // => true
+
+ // Operadores bit-a-bit!
+ /*
+ ~ Complemento de um
+ << Deslocamento a esquerda com sinal
+ >> Deslocamento a direita com sinal
+ >>> Deslocamento a direita sem sinal
+ & E bit-a-bit
+ | OU bit-a-bit
+ ^ OU exclusivo bit-a-bit
+ */
+
+ // Incrementações
+ int i = 0;
+ System.out.println("\n->Inc/Dec-rementação");
+ System.out.println(i++); //i = 1. Pós-Incrementação
+ System.out.println(++i); //i = 2. Pre-Incrementação
+ System.out.println(i--); //i = 1. Pós-Decrementação
+ System.out.println(--i); //i = 0. Pre-Decrementação
+
+ ///////////////////////////////////////
+ // Estruturas de Controle
+ ///////////////////////////////////////
+ System.out.println("\n->Estruturas de Controle");
+
+ // Os comandos If são parecidos com o da linguagem C
+ int j = 10;
+ if (j == 10){
+ System.out.println("Eu serei impresso");
+ } else if (j > 10) {
+ System.out.println("Eu não");
+ } else {
+ System.out.println("Eu também não");
+ }
+
+ // O Loop While
+ int fooWhile = 0;
+ while(fooWhile < 100)
+ {
+ //System.out.println(fooWhile);
+ //Incrementando o contador
+ //Iteração feita 99 vezes, fooWhile 0->99
+ fooWhile++;
+ }
+ System.out.println("Valor do fooWhile: " + fooWhile);
+
+ // O Loop Do While
+ int fooDoWhile = 0;
+ do
+ {
+ //System.out.println(fooDoWhile);
+ //Incrementando o contador
+ //Iteração feita 99 vezes, fooDoWhile 0->99
+ fooDoWhile++;
+ }while(fooDoWhile < 100);
+ System.out.println("Valor do fooDoWhile: " + fooDoWhile);
+
+ // O Loop For
+ int fooFor;
+ //estrutura do loop for => for(<operação_de_início>; <condição>; <passo>)
+ for(fooFor=0; fooFor<10; fooFor++){
+ //System.out.println(fooFor);
+ //Iteração feita 10 vezes, fooFor 0->9
+ }
+ System.out.println("Valor do fooFor: " + fooFor);
+
+ // O Loop For Each
+ // Itera automaticamente por um array ou lista de objetos.
+ int[] fooList = {1,2,3,4,5,6,7,8,9};
+ //estrutura do loop for each => for(<objeto> : <array_de_objeto>)
+ //lê-se: para cada objeto no array
+ //nota: o tipo do objeto deve ser o mesmo do array.
+
+ for( int bar : fooList ){
+ //System.out.println(bar);
+ //Itera 9 vezes e imprime 1-9 em novas linhas
+ }
+
+ // Switch
+ // Um switch funciona com os tipos de dados: byte, short, char e int
+ // Ele também funciona com tipos enumerados (vistos em tipos Enum)
+ // como também a classe String e algumas outras classes especiais
+ // tipos primitivos: Character, Byte, Short e Integer
+ int mes = 3;
+ String mesString;
+ switch (mes){
+ case 1:
+ mesString = "Janeiro";
+ break;
+ case 2:
+ mesString = "Fevereiro";
+ break;
+ case 3:
+ mesString = "Março";
+ break;
+ default:
+ mesString = "Algum outro mês";
+ break;
+ }
+ System.out.println("Resultado do Switch: " + mesString);
+
+ // Condição de forma abreviada.
+ // Você pode usar o operador '?' para atribuições rápidas ou decisões lógicas.
+ // Lê-se "Se (declaração) é verdadeira, use <primeiro valor>
+ // caso contrário, use <segundo valor>".
+ int foo = 5;
+ String bar = (foo < 10) ? "A" : "B";
+ System.out.println(bar); //Imprime A, pois a condição é verdadeira.
+
+
+ ///////////////////////////////////////
+ // Convertendo tipos de dados e Casting
+ ///////////////////////////////////////
+
+ //Conversão de Dados
+
+ //Convertendo String para Inteiro.
+ Integer.parseInt("123");//retorna uma versão inteira de "123".
+
+ //Convertendo Inteiro para String
+ Integer.toString(123);//retorna uma versão String de 123.
+
+ // Para outras conversões confira as seguintes classes
+ // Double
+ // Long
+ // String
+
+ // Casting
+ // Você pode também converter objetos java, há vários detalhes e
+ // lida com alguns conceitos intermediários
+ // Dê uma olhada no link:
+ // http://docs.oracle.com/javase/tutorial/java/IandI/subclasses.html
+
+
+ ///////////////////////////////////////
+ // Classes e Métodos
+ ///////////////////////////////////////
+
+ System.out.println("\n->Classes e Métodos");
+
+ // (segue a definição da classe Bicicleta)
+
+ // Use o new para instanciar uma classe
+ Bicicleta caloi = new Bicicleta(); // Objeto caloi criado.
+
+ // Chame os métodos do objeto
+ caloi.aumentarVelocidade(3); // Você deve sempre usar métodos para modificar variáveis
+ caloi.setRitmo(100);
+
+ // toString é uma convenção para mostrar o valor deste objeto.
+ System.out.println("informações de caloi: " + caloi.toString());
+
+ } // Fim do método main
+} // Fim da classe LearnJava
+
+
+// Você pode incluir outras classes que não são públicas num arquivo .java
+
+
+// Sintaxe de declaração de Classe.
+// <public/private/protected> class <nome da classe>{
+// // atributos, construtores e todos os métodos.
+// // funções são chamadas de métodos em Java.
+// }
+
+class Bicicleta {
+
+ // Atributos/Variáveis da classe Bicicleta.
+ public int ritmo; // Public: Pode ser acessada em qualquer lugar.
+ private int velocidade; // Private: Apenas acessível a classe.
+ protected int catraca; // Protected: Acessível a classe e suas subclasses.
+ String nome; // default: Apenas acessível ao pacote.
+
+ // Construtores são uma forma de criação de classes
+ // Este é o construtor padrão.
+ public Bicicleta() {
+ catraca = 1;
+ ritmo = 50;
+ velocidade = 5;
+ nome = "Bontrager";
+ }
+
+ // Este é um construtor específico (ele contém argumentos).
+ public Bicicleta (int ritmoInicial, int velocidadeInicial, int catracaInicial, String nome) {
+ this.catraca = catracaInicial;
+ this.ritmo = ritmoInicial;
+ this.velocidade = velocidadeInicial;
+ this.nome = nome;
+ }
+
+ // Sintaxe de um método:
+ // <public/private/protected> <tipo de retorno> <nome do método>(<args>) //
+
+ // Classes em Java costumam implementar métodos getters e setters para seus campos.
+
+ // Sintaxe de declaração de métodos
+ // <escopo> <tipo de retorno> <nome do método>(<args>) //
+ public int getRitmo() {
+ return ritmo;
+ }
+
+ // Métodos do tipo void não requerem declaração de retorno.
+ public void setRitmo(int novoValor) {
+ ritmo = novoValor;
+ }
+
+ public void setEquipamento(int novoValor) {
+ catraca = novoValor;
+ }
+
+ public void aumentarVelocidade(int incremento) {
+ velocidade += incremento;
+ }
+
+ public void diminuirVelocidade(int decremento) {
+ velocidade -= decremento;
+ }
+
+ public void setNome(String novoNome) {
+ nome = novoNome;
+ }
+
+ public String getNome() {
+ return nome; // retorna um dado do tipo String.
+ }
+
+ //Método para mostrar os valores dos atributos deste objeto.
+ @Override
+ public String toString() {
+ return "catraca: " + catraca +
+ " ritmo: " + ritmo +
+ " velocidade: " + velocidade +
+ " nome: " + nome;
+ }
+} // fim classe Bicicleta
+
+// Velocipede é uma subclasse de bicicleta.
+class Velocipede extends Bicicleta {
+ // (Velocípedes são bicicletas com rodas dianteiras grandes
+ // Elas não possuem catraca.)
+
+ public Velocipede(int ritmoInicial, int velocidadeInicial){
+ // Chame o construtor do pai (construtor de Bicicleta) com o comando super.
+ super(ritmoInicial, velocidadeInicial, 0, "PennyFarthing");
+ }
+
+ // Você pode marcar um método que você está substituindo com uma @annotation
+ // Para aprender mais sobre o que são as annotations e sua finalidade
+ // dê uma olhada em: http://docs.oracle.com/javase/tutorial/java/annotations/
+ @Override
+ public void setEquipamento(int catraca) {
+ catraca = 0;
+ }
+
+}
+
+```
+
+## Leitura Recomendada
+
+Os links fornecidos aqui abaixo são apenas para ter uma compreensão do tema, use o Google e encontre exemplos específicos.
+
+Outros tópicos para pesquisar:
+
+* [Tutorial Java para Sun Trail / Oracle](http://docs.oracle.com/javase/tutorial/index.html)
+
+* [Modificadores de acesso do Java](http://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html)
+
+* [Coceitos de Programação Orientada à Objetos](http://docs.oracle.com/javase/tutorial/java/concepts/index.html):
+ * [Herança](http://docs.oracle.com/javase/tutorial/java/IandI/subclasses.html)
+ * [Polimorfismo](http://docs.oracle.com/javase/tutorial/java/IandI/polymorphism.html)
+ * [Abstração](http://docs.oracle.com/javase/tutorial/java/IandI/abstract.html)
+
+* [Exceções](http://docs.oracle.com/javase/tutorial/essential/exceptions/index.html)
+
+* [Interfaces](http://docs.oracle.com/javase/tutorial/java/IandI/createinterface.html)
+
+* [Tipos Genéricos](http://docs.oracle.com/javase/tutorial/java/generics/index.html)
+
+* [Conversões de código Java](http://www.oracle.com/technetwork/java/codeconv-138413.html)
+
+Livros:
+
+* [Use a cabeça, Java] (http://www.headfirstlabs.com/books/hfjava/)
diff --git a/python.html.markdown b/python.html.markdown
index 08e68407..22d236ac 100644
--- a/python.html.markdown
+++ b/python.html.markdown
@@ -2,6 +2,7 @@
language: python
contributors:
- ["Louie Dinh", "http://ldinh.ca"]
+ - ["Amin Bandali", "http://aminbandali.com"]
filename: learnpython.py
---
@@ -159,6 +160,8 @@ li[1:3] #=> [2, 4]
li[2:] #=> [4, 3]
# Omit the end
li[:3] #=> [1, 2, 4]
+# Revert the list
+li[::-1] #=> [3, 4, 2, 1]
# Remove arbitrary elements from a list with "del"
del li[2] # li is now [1, 2, 3]
@@ -481,6 +484,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/)
+* [A Crash Course in Python for Scientists](http://nbviewer.ipython.org/5920182)
### Dead Tree
diff --git a/ruby.html.markdown b/ruby.html.markdown
index 8723e18f..bf4cb229 100644
--- a/ruby.html.markdown
+++ b/ruby.html.markdown
@@ -139,8 +139,8 @@ array.[] 12 #=> nil
# From the end
array[-1] #=> 5
-# With a start and end index
-array[2, 4] #=> [3, 4, 5]
+# With a start index and length
+array[2, 3] #=> [3, 4, 5]
# Or with a range
array[1..3] #=> [2, 3, 4]
diff --git a/zh-cn/bash-cn.html.markdown b/zh-cn/bash-cn.html.markdown
new file mode 100644
index 00000000..e3eed3a6
--- /dev/null
+++ b/zh-cn/bash-cn.html.markdown
@@ -0,0 +1,148 @@
+---
+category: tool
+tool: bash
+contributors:
+ - ["Max Yankov", "https://github.com/golergka"]
+ - ["Darren Lin", "https://github.com/CogBear"]
+ - ["Alexandre Medeiros", "http://alemedeiros.sdf.org"]
+translators:
+ - ["Chunyang Xu", "https://github.com/XuChunyang"]
+filename: LearnBash-cn.sh
+lang: zh-cn
+---
+
+Bash 是一个为 GNU 计划编写的 Unix shell,是 Linux 和 Mac OS X 下的默认 shell。
+以下大多数例子可以作为脚本的一部分运行也可直接在 shell 下交互执行。
+
+[更多信息](http://www.gnu.org/software/bash/manual/bashref.html)
+
+```bash
+#!/bin/sh
+# 脚本的第一行叫 shebang,用来告知系统如何执行该脚本:
+# 参见: http://en.wikipedia.org/wiki/Shebang_(Unix)
+# 如你所见,注释以 # 开头,shebang 也是注释。
+
+# 显示 “Hello world!”
+echo Hello, world!
+
+# 每一句指令以换行或分号隔开:
+echo 'This is the first line'; echo 'This is the second line'
+
+# 声明一个变量:
+VARIABLE="Some string"
+
+# 下面是错误的做法:
+VARIABLE = "Some string"
+# Bash 会把 VARIABLE 当做一个指令,由于找不到该指令,因此这里会报错。
+
+
+# 使用变量:
+echo $VARIABLE
+echo "$VARIABLE"
+echo '$VARIABLE'
+# 当你分配 (assign) 、导出 (export),或者以其他方式使用变量时,变量名前不加 $。
+# 如果要使用变量的值, 则要加 $。
+# 注意: ' (单引号) 不会展开变量(即会屏蔽掉变量)。
+
+
+# 在变量内部进行字符串代换
+echo ${VARIABLE/Some/A}
+# 会把 VARIABLE 中首次出现的 "some" 替换成 “A”。
+
+# 内置变量:
+# 下面的内置变量很有用
+echo "Last program return value: $?"
+echo "Script's PID: $$"
+echo "Number of arguments: $#"
+echo "Scripts arguments: $@"
+echo "Scripts arguments separeted in different variables: $1 $2..."
+
+# 读取输入:
+echo "What's your name?"
+read NAME # 这里不需要声明新变量
+echo Hello, $NAME!
+
+# 通常的 if 结构看起来像这样:
+# 'man test' 可查看更多的信息
+if [ $NAME -ne $USER ]
+then
+ echo "Your name is you username"
+else
+ echo "Your name isn't you username"
+fi
+
+# 根据上一个指令执行结果决定是否执行下一个指令
+echo "Always executed" || echo "Only executed if first command fail"
+echo "Always executed" && echo "Only executed if first command does NOT fail"
+
+# 表达式的格式如下:
+echo $(( 10 + 5 ))
+
+# 与其他编程语言不同的是,bash 运行时依赖上下文。比如,使用 ls 时,列出当前目录。
+ls
+
+# 指令可以带有选项:
+ls -l # 列出文件和目录的详细信息
+
+# 前一个指令的输出可以当作后一个指令的输入。grep 用来匹配字符串。
+# 用下面的指令列出当前目录下所有的 txt 文件:
+ls -l | grep "\.txt"
+
+# 重定向可以到输出,输入和错误输出。
+python2 hello.py < "input.in"
+python2 hello.py > "output.out"
+python2 hello.py 2> "error.err"
+# > 会覆盖已存在的文件, >> 会以累加的方式输出文件中。
+
+# 一个指令可用 $( ) 嵌套在另一个指令内部:
+# 以下的指令会打印当前目录下的目录和文件总数
+echo "There are $(ls | wc -l) items here."
+
+# Bash 的 case 语句与 Java 和 C++ 中的 switch 语句类似:
+case "$VARIABLE" in
+ # 列出需要匹配的字符串
+ 0) echo "There is a zero.";;
+ 1) echo "There is a one.";;
+ *) echo "It is not null.";;
+esac
+
+# 循环遍历给定的参数序列:
+# 变量$VARIABLE 的值会被打印 3 次。
+# 注意 ` ` 和 $( ) 等价。seq 返回长度为 3 的数组。
+for VARIABLE in `seq 3`
+do
+ echo "$VARIABLE"
+done
+
+# 你也可以使用函数
+# 定义函数:
+function foo ()
+{
+ echo "Arguments work just like script arguments: $@"
+ echo "And: $1 $2..."
+ echo "This is a function"
+ return 0
+}
+
+# 更简单的方法
+bar ()
+{
+ echo "Another way to declare functions!"
+ return 0
+}
+
+# 调用函数
+foo "My name is" $NAME
+
+# 有很多有用的指令需要学习:
+tail -n 10 file.txt
+# 打印 file.txt 的最后 10 行
+head -n 10 file.txt
+# 打印 file.txt 的前 10 行
+sort file.txt
+# 将 file.txt 按行排序
+uniq -d file.txt
+# 报告或忽略重复的行,用选项 -d 打印重复的行
+cut -d ',' -f 1 file.txt
+# 打印每行中 ',' 之前内容
+```
diff --git a/zh-cn/brainfuck-cn.html.markdown b/zh-cn/brainfuck-cn.html.markdown
new file mode 100644
index 00000000..a6f3fa09
--- /dev/null
+++ b/zh-cn/brainfuck-cn.html.markdown
@@ -0,0 +1,70 @@
+---
+language: brainfuck
+lang: zh-cn
+contributors:
+ - ["Prajit Ramachandran", "http://prajitr.github.io/"]
+ - ["Mathias Bynens", "http://mathiasbynens.be/"]
+translators:
+ - ["lyuehh", "https://github.com/lyuehh"]
+---
+
+Brainfuck 是一个极小的只有8个指令的图灵完全的编程语言。
+
+```
+除"><+-.,[]"之外的的任何字符都会被忽略 (不包含双引号)。
+
+Brainfuck 包含一个有30,000个单元为0的数组,和
+一个数据指针指向当前的单元。
+
+8个指令如下:
++ : 指针指向的单元的值加1
+- : 指针指向的单元的值减1
+> : 将指针移动到下一个单元(右边的元素)
+< : 将指针移动到上一个单元(左边的元素)
+. : 打印当前单元的内容的ASCII值 (比如 65 = 'A').
+, : 读取一个字符到当前的单元
+[ : 如果当前单元的值是0,则向后调转到对应的]处
+] : 如果当前单元的值不是0,则向前跳转到对应的[处
+
+[ 和 ] 组成了一个while循环。很明显,它们必须配对。
+
+让我们看一些基本的brainfuck 程序。
+
+++++++ [ > ++++++++++ < - ] > +++++ .
+
+这个程序打印字母'A'。首先,它把 #1 增加到6,使用它来作为循环条件,
+然后,进入循环,将指针移动到 #2 ,将 #2 的值增加到10,然后
+移动回 #1,将单元 #1 的值减1,然后继续。循环共进行了6次。
+
+这时,我们在 #1,它的值为0,#2 的值为60,我们移动到
+#2,将 #2 的内容加上5,然后将 #2 的内容打印出来,65在
+ASCII中表示'A', 所以'A'就会被打印出来。
+
+
+, [ > + < - ] > .
+
+这个程序从用户的输入中读取一个字符,然后把它复制到 #1。
+然后我们开始一个循环,移动到 #2,将 #2 的值加1,再移动回 #1,将 #1
+的值减1,直到 #1的值为0,这样 #2 里就保存了 #1 的旧值,循环结束时我们
+在 #1,这时我们移动到 #2,然后把字符以ASCII打印出来。
+
+而且要记住的一点就是,空格在这里只是为了可读性,你可以将他们写成这样:
+
+,[>+<-]>.
+
+试着思考一下这段程序是干什么的:
+
+,>,< [ > [ >+ >+ << -] >> [- << + >>] <<< -] >>
+
+这段程序从输入接收2个参数,然后将他们相乘。
+
+先读取2个输入,然后开始外层循环,以 #1 作为终止条件,然后将指针移动到
+#2,然后开始 #2 的内层循环,将 #3 加1。但是这里有一个小问题,在内层
+循环结束的时候,#2 的值是0了,那么下次执行外层循环的时候,就有问题了。
+为了解决这个问题,我们可以增加 #4 的值,然后把 #4 的值复制到 #2,
+最后结果就保存在 #3 中了。
+```
+好了这就是brainfuck了。也没那么难,是吧?为了好玩,你可以写你自己的
+brainfuck程序,或者用其他语言写一个brainfuck的解释器,解释器非常容易
+实现,但是如果你是一个自虐狂的话,你可以尝试用brainfuck写一个brainfuk的
+解释器。