summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--bash.html.markdown68
-rw-r--r--brainfuck.html.markdown14
-rw-r--r--clojure.html.markdown6
-rw-r--r--common-lisp.html.markdown2
-rw-r--r--csharp.html.markdown81
-rw-r--r--de-de/elixir-de.html.markdown2
-rw-r--r--es-es/clojure-es.html.markdown2
-rw-r--r--fr-fr/clojure-fr.html.markdown398
-rw-r--r--fr-fr/haskell.html.markdown430
-rw-r--r--git.html.markdown2
-rw-r--r--java.html.markdown2
-rw-r--r--javascript.html.markdown10
-rw-r--r--ko-kr/brainfuck-kr.html.markdown83
-rw-r--r--livescript.html.markdown14
-rw-r--r--lua.html.markdown2
-rw-r--r--perl.html.markdown12
-rw-r--r--pogo.html.markdown202
-rw-r--r--pt-pt/brainfuck-pt.html.markdown84
-rw-r--r--python.html.markdown44
-rw-r--r--ru-ru/ruby-ru.html.markdown99
-rw-r--r--ruby.html.markdown12
-rw-r--r--scala.html.markdown2
-rw-r--r--vi-vn/git-vi.html.markdown392
-rw-r--r--vi-vn/objective-c-vi.html.markdown318
-rw-r--r--zh-cn/r-cn.html.markdown540
25 files changed, 2732 insertions, 89 deletions
diff --git a/bash.html.markdown b/bash.html.markdown
index 708131bd..276bc31f 100644
--- a/bash.html.markdown
+++ b/bash.html.markdown
@@ -4,6 +4,7 @@ tool: bash
contributors:
- ["Max Yankov", "https://github.com/golergka"]
- ["Darren Lin", "https://github.com/CogBear"]
+ - ["Alexandre Medeiros", "http://alemedeiros.sdf.org"]
filename: LearnBash.sh
---
@@ -35,8 +36,22 @@ VARIABLE = "Some string"
# Using the variable:
echo $VARIABLE
echo "$VARIABLE"
+echo '$VARIABLE'
# When you use the variable itself — assign it, export it, or else — you write
# its name without $. If you want to use variable's value, you should use $.
+# Note that ' (single quote) won't expand the variables!
+
+# String substitution in variables
+echo ${VARIABLE/Some/A}
+# This will substitute the first occurance of "Some" with "A"
+
+# Bultin variables:
+# There are some useful builtin variables, like
+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..."
# Reading a value from input:
echo "What's your name?"
@@ -44,13 +59,18 @@ read NAME # Note that we didn't need to declare new variable
echo Hello, $NAME!
# We have the usual if structure:
-if true
+# use 'man test' for more info about conditionals
+if [ $NAME -ne $USER ]
then
- echo "This is expected"
+ echo "Your name is you username"
else
- echo "And this is not"
+ echo "Your name isn't you username"
fi
+# There is also conditional execution
+echo "Always executed" || echo "Only executed if first command fail"
+echo "Always executed" && echo "Only executed if first command does NOT fail"
+
# Expressions are denoted with the following format:
echo $(( 10 + 5 ))
@@ -67,12 +87,19 @@ ls -l # Lists every file and directory on a separate line
# txt files in the current directory:
ls -l | grep "\.txt"
-# Commands can be substitued within other commands using $( ):
+# You can also redirect a command output, input and error output.
+python2 hello.py < "input.in"
+python2 hello.py > "output.out"
+python2 hello.py 2> "error.err"
+# The output error will overwrite the file if it exists, if you want to
+# concatenate them, use ">>" instead.
+
+# Commands can be substituted within other commands using $( ):
# The following command displays the number of files and directories in the
# current directory.
echo "There are $(ls | wc -l) items here."
-# Bash uses a case statement that works similarily to switch in Java and C++:
+# Bash uses a case statement that works similarly to switch in Java and C++:
case "$VARIABLE" in
#List patterns for the conditions you want to meet
0) echo "There is a zero.";;
@@ -80,11 +107,36 @@ case "$VARIABLE" in
*) echo "It is not null.";;
esac
-#For loops iterate for as many arguments given:
-#The contents of var $VARIABLE is printed three times.
-for VARIABLE in x y z
+# For loops iterate for as many arguments given:
+# The contents of var $VARIABLE is printed three times.
+# Note that ` ` is equivalent to $( ) and that seq returns a sequence of size 3.
+for VARIABLE in `seq 3`
do
echo "$VARIABLE"
done
+# You can also define functions
+# Definition:
+foo ()
+{
+ echo "Arguments work just like script arguments: $@"
+ echo "And: $1 $2..."
+ echo "This is a function"
+ return 0
+}
+
+# Calling your function
+foo "My name is" $NAME
+
+# There are a lot of useful commands you should learn:
+tail -n 10 file.txt
+# prints last 10 lines of file.txt
+head -n 10 file.txt
+# prints first 10 lines of file.txt
+sort file.txt
+# sort file.txt's lines
+uniq -d file.txt
+# report or omit repeated lines, with -d it reports them
+cut -d ',' -f 1 file.txt
+# prints only the first column before the ',' character
```
diff --git a/brainfuck.html.markdown b/brainfuck.html.markdown
index 9282381f..27ac6921 100644
--- a/brainfuck.html.markdown
+++ b/brainfuck.html.markdown
@@ -53,25 +53,27 @@ until cell #1 is 0, and cell #2 holds cell #1's old value. Because we're on
cell #1 at the end of the loop, move to cell #2, and then print out the value
in ASCII.
-Also keep in mind that the spaces are purely for readibility purposes. You
+Also keep in mind that the spaces are purely for readability purposes. You
could just as easily write it as:
,[>+<-]>.
Try and figure out what this program does:
-,>,< [ > [ >+ >+ << -] >> [- << + >>] <<< -] >>
+,>,< [ > [ >+ >+ << -] >> [- << + >>] <<< -] >>
This program takes two numbers for input, and multiplies them.
The gist is it first reads in two inputs. Then it starts the outer loop,
conditioned on cell #1. Then it moves to cell #2, and starts the inner
-loop conditioned on cell #2, incrementing cell #3. However, there comes a
-problem: at the end of the inner loop, cell #2 is zero. To solve this problem,
+loop conditioned on cell #2, incrementing cell #3. However, there comes a
+problem: At the end of the inner loop, cell #2 is zero. In that case,
+inner loop won't work anymore since next time. To solve this problem,
we also increment cell #4, and then recopy cell #4 into cell #2.
+Then cell #3 is the result.
```
-And that's brainfuck. Not that hard, eh? For fun, you can write your own
-brainfuck programs, or you can write a brainfuck interpreter in another
+And that's brainfuck. Not that hard, eh? For fun, you can write your own
+brainfuck programs, or you can write a brainfuck interpreter in another
language. The interpreter is fairly simple to implement, but if you're a
masochist, try writing a brainfuck interpreter… in brainfuck.
diff --git a/clojure.html.markdown b/clojure.html.markdown
index a502a95c..779c28ae 100644
--- a/clojure.html.markdown
+++ b/clojure.html.markdown
@@ -63,7 +63,7 @@ and often automatically.
; If you want to create a literal list of data, use ' to stop it from
; being evaluated
'(+ 1 2) ; => (+ 1 2)
-; (shorthand for (quote (+ 1 2))
+; (shorthand for (quote (+ 1 2)))
; You can eval a quoted list
(eval '(+ 1 2)) ; => 3
@@ -205,7 +205,7 @@ keymap ; => {:a 1, :c 3, :b 2}
;("a" stringmap)
; => Exception: java.lang.String cannot be cast to clojure.lang.IFn
-; Retrieving a non-present value returns nil
+; Retrieving a non-present key returns nil
(stringmap "d") ; => nil
; Use assoc to add new keys to hash-maps
@@ -341,7 +341,7 @@ keymap ; => {:a 1, :b 2, :c 3}
(swap! my-atom assoc :a 1) ; Sets my-atom to the result of (assoc {} :a 1)
(swap! my-atom assoc :b 2) ; Sets my-atom to the result of (assoc {:a 1} :b 2)
- ; Use '@' to dereference the atom and get the value
+; Use '@' to dereference the atom and get the value
my-atom ;=> Atom<#...> (Returns the Atom object)
@my-atom ; => {:a 1 :b 2}
diff --git a/common-lisp.html.markdown b/common-lisp.html.markdown
index a672b682..dda60797 100644
--- a/common-lisp.html.markdown
+++ b/common-lisp.html.markdown
@@ -377,7 +377,7 @@ nil ; for false - and the empty list
;; 4. Equality
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Common Lisp has a sophisticated equality system. A couple are covered yere.
+;; Common Lisp has a sophisticated equality system. A couple are covered here.
;; for numbers use `='
(= 3 3.0) ; => t
diff --git a/csharp.html.markdown b/csharp.html.markdown
index d3adbd01..1471b833 100644
--- a/csharp.html.markdown
+++ b/csharp.html.markdown
@@ -3,6 +3,7 @@ language: c#
contributors:
- ["Irfan Charania", "https://github.com/irfancharania"]
- ["Max Yankov", "https://github.com/golergka"]
+ - ["Melvyn Laïly", "http://x2a.yt"]
filename: LearnCSharp.cs
---
@@ -95,17 +96,25 @@ namespace Learning
// Double - Double-precision 64-bit IEEE 754 Floating Point
// Precision: 15-16 digits
double fooDouble = 123.4;
+
+ // Decimal - a 128-bits data type, with more precision than other floating-point types,
+ // suited for financial and monetary calculations
+ decimal fooDecimal = 150.3m;
- // Bool - true & false
+ // Boolean - true & false
bool fooBoolean = true;
bool barBoolean = false;
// Char - A single 16-bit Unicode character
char fooChar = 'A';
- // Strings
+ // Strings -- unlike the previous base types which are all value types,
+ // a string is a reference type. That is, you can set it to null
string fooString = "My string is here!";
Console.WriteLine(fooString);
+ // You can access each character of the string with an indexer:
+ char charFromString = fooString[1]; // 'y'
+ // Strings are immutable: you can't do fooString[1] = 'X';
// formatting
string fooFs = string.Format("Check Check, {0} {1}, {0} {1:0.0}", 1, 2);
@@ -138,14 +147,21 @@ namespace Learning
const int HOURS_I_WORK_PER_WEEK = 9001;
// Nullable types
- // any type can be made nullable by suffixing a ?
+ // any value type (i.e. not a class) can be made nullable by suffixing a ?
// <type>? <var name> = <value>
int? nullable = null;
Console.WriteLine("Nullable variable: " + nullable);
- // In order to use nullable's value, you have to use Value property or to explicitly cast it
- string? nullableString = "not null";
- Console.WriteLine("Nullable value is: " + nullableString.Value + " or: " + (string) nullableString );
+ // In order to use nullable's value, you have to use Value property
+ // or to explicitly cast it
+ DateTime? nullableDate = null;
+ // The previous line would not have compiled without the '?'
+ // because DateTime is a value type
+ // <type>? is equivalent to writing Nullable<type>
+ Nullable<DateTime> otherNullableDate = nullableDate;
+
+ nullableDate = DateTime.Now;
+ Console.WriteLine("Nullable value is: " + nullableDate.Value + " or: " + (DateTime) nullableDate );
// ?? is syntactic sugar for specifying default value
// in case variable is null
@@ -153,6 +169,8 @@ namespace Learning
Console.WriteLine("Not nullable variable: " + notNullable);
// Var - compiler will choose the most appropriate type based on value
+ // Please note that this does not remove type safety.
+ // In this case, the type of fooImplicit is known to be a bool at compile time
var fooImplicit = true;
///////////////////////////////////////////////////
@@ -201,7 +219,7 @@ namespace Learning
// Others data structures to check out:
//
// Stack/Queue
- // Dictionary
+ // Dictionary (an implementation of a hash map)
// Read-only Collections
// Tuple (.Net 4+)
@@ -235,7 +253,6 @@ namespace Learning
~ Unary bitwise complement
<< Signed left shift
>> Signed right shift
- >>> Unsigned right shift
& Bitwise AND
^ Bitwise exclusive OR
| Bitwise inclusive OR
@@ -308,6 +325,18 @@ namespace Learning
//Iterated 10 times, fooFor 0->9
}
Console.WriteLine("fooFor Value: " + fooFor);
+
+ // For Each Loop
+ // foreach loop structure => foreach(<iteratorType> <iteratorName> in <enumerable>)
+ // The foreach loop loops over any object implementing IEnumerable or IEnumerable<T>
+ // All the collection types (Array, List, Dictionary...) in the .Net framework
+ // implement one or both of these interfaces.
+ // (The ToCharArray() could be removed, because a string also implements IEnumerable)
+ foreach (char character in "Hello World".ToCharArray())
+ {
+ //Console.WriteLine(character);
+ //Iterated over all the characters in the string
+ }
// Switch Case
// A switch works with the byte, short, char, and int data types.
@@ -327,6 +356,14 @@ namespace Learning
case 3:
monthString = "March";
break;
+ // You can assign more than one case to an action
+ // But you can't add an action without a break before another case
+ // (if you want to do this, you would have to explicitly add a goto case x
+ case 6:
+ case 7:
+ case 8:
+ monthString = "Summer time!!";
+ break;
default:
monthString = "Some other month";
break;
@@ -335,7 +372,7 @@ namespace Learning
///////////////////////////////////////
- // Converting Data Types And Typcasting
+ // Converting Data Types And Typecasting
///////////////////////////////////////
// Converting data
@@ -389,7 +426,7 @@ namespace Learning
// Class Declaration Syntax:
- // <public/private/protected> class <class name>{
+ // <public/private/protected/internal> class <class name>{
// //data fields, constructors, functions all inside.
// //functions are called as methods in Java.
// }
@@ -404,17 +441,20 @@ namespace Learning
string name; // Everything is private by default: Only accessible from within this class
// Enum is a value type that consists of a set of named constants
+ // It is really just mapping a name to a value (an int, unless specified otherwise).
+ // The approved types for an enum are byte, sbyte, short, ushort, int, uint, long, or ulong.
+ // An enum can't contain the same value twice.
public enum Brand
{
AIST,
BMC,
- Electra,
+ Electra=42, //you can explicitly set a value to a name
Gitane
}
// We defined this type inside a Bicycle class, so it is a nested type
// Code outside of this class should reference this type as Bicycle.Brand
- public Brand brand; // After declaing an enum type, we can declare the field of this type
+ public Brand brand; // After declaring an enum type, we can declare the field of this type
// Static members belong to the type itself rather then specific object.
static public int bicyclesCreated = 0;
@@ -459,7 +499,7 @@ namespace Learning
// <public/private/protected> <return type> <function name>(<args>)
// classes can implement getters and setters for their fields
- // or they can implement properties
+ // or they can implement properties (this is the preferred way in C#)
// Method declaration syntax:
// <scope> <return type> <method name>(<args>)
@@ -474,13 +514,14 @@ namespace Learning
cadence = newValue;
}
- // virtual keyword indicates this method can be overridden
+ // virtual keyword indicates this method can be overridden in a derived class
public virtual void SetGear(int newValue)
{
gear = newValue;
}
- // Method parameters can have defaut values. In this case, methods can be called with these parameters omitted
+ // Method parameters can have default values.
+ // In this case, methods can be called with these parameters omitted
public void SpeedUp(int increment = 1)
{
_speed += increment;
@@ -500,6 +541,12 @@ namespace Learning
get { return _hasTassles; }
set { _hasTassles = value; }
}
+
+ // You can also define an automatic property in one line
+ // this syntax will create a backing field automatically.
+ // You can set an access modifier on either the getter or the setter (or both)
+ // to restrict its access:
+ public bool IsBroken { get; private set; }
// Properties can be auto-implemented
public int FrameSize
@@ -525,7 +572,7 @@ namespace Learning
// Methods can also be static. It can be useful for helper methods
public static bool DidWeCreateEnoughBycles()
{
- // Within a static method, we only can reference static class memebers
+ // Within a static method, we only can reference static class members
return bicyclesCreated > 9000;
} // If your class only needs static members, consider marking the class itself as static.
@@ -564,7 +611,7 @@ namespace Learning
interface IBreakable
{
- bool Broken { get; } // interfaces can contain properties as well as methods, fields & events
+ bool Broken { get; } // interfaces can contain properties as well as methods & events
}
// Class can inherit only one other class, but can implement any amount of interfaces
diff --git a/de-de/elixir-de.html.markdown b/de-de/elixir-de.html.markdown
index f77f9b0c..29d5132d 100644
--- a/de-de/elixir-de.html.markdown
+++ b/de-de/elixir-de.html.markdown
@@ -5,7 +5,7 @@ contributors:
translators:
- ["Gregor Große-Bölting", "http://www.ideen-und-soehne.de"]
filename: learnelixir-de.ex
-+lang: de-de
+lang: de-de
---
Elixir ist eine moderne, funktionale Sprache für die Erlang VM. Sie ist voll
diff --git a/es-es/clojure-es.html.markdown b/es-es/clojure-es.html.markdown
index 1ccdc50e..150d0bb2 100644
--- a/es-es/clojure-es.html.markdown
+++ b/es-es/clojure-es.html.markdown
@@ -70,7 +70,7 @@ y a menudo automáticamente.
; Si quieres crear una lista de datos, precedela con una comilla
; simple para evitar su evaluación
'(+ 1 2) ; => (+ 1 2)
-; (que es una abreviatura de (quote (+ 1 2))
+; (que es una abreviatura de (quote (+ 1 2)) )
; Puedes evaluar una lista precedida por comilla con eval
(eval '(+ 1 2)) ; => 3
diff --git a/fr-fr/clojure-fr.html.markdown b/fr-fr/clojure-fr.html.markdown
new file mode 100644
index 00000000..d3c5a67b
--- /dev/null
+++ b/fr-fr/clojure-fr.html.markdown
@@ -0,0 +1,398 @@
+---
+language: clojure
+filename: learnclojure-fr.clj
+contributors:
+ - ["Adam Bard", "http://adambard.com/"]
+translators:
+ - ["Bastien Guerry", "https://github.com/bzg"]
+lang: fr-fr
+---
+
+Clojure est un langage de la famille des Lisp développé pour la machine
+virtuelle Java. Ce langage insiste beaucoup plus sur la [programmation
+fonctionnelle](https://fr.wikipedia.org/wiki/Programmation_fonctionnelle) pure
+que Common Lisp, mais comprend plusieurs outils de gestion de la mémoire
+transactionnelle
+[STM](https://en.wikipedia.org/wiki/Software_transactional_memory) pour gérer
+les changements d'états si besoin.
+
+Cette combinaison permet de gérer le parallélisme très simplement, et
+souvent de façon automatique.
+
+(Vous avez besoin de Clojure 1.2 ou plus récent pour ce tutoriel.)
+
+```clojure
+; Les commentaires commencent avec un point-virgule.
+
+; Clojure est composé de « formes », qui sont simplement des listes
+; d'expressions entre parenthèses, séparées par une ou des espaces.
+;
+; L'interpréteur Clojure suppose que le premier élément est une fonction
+; ou une macro, et que le reste contient des arguments.
+
+; Le premier appel dans un fichier doit être ns, pour définir
+; l'espace de nom
+(ns learnclojure)
+
+; D'autres d'exemples basiques:
+
+; str va créer une chaîne de caractères à partir de tous ses arguments
+(str "Hello" " " "World") ; => "Hello World"
+
+; Les opérations mathématiques sont simples
+(+ 1 1) ; => 2
+(- 2 1) ; => 1
+(* 1 2) ; => 2
+(/ 2 1) ; => 2
+
+; L'égalité est =
+(= 1 1) ; => true
+(= 2 1) ; => false
+
+; Vous avez aussi besoin de not pour la négation logique
+(not true) ; => false
+
+; Les formes imbriquées fonctionnent comme on s'y attend
+(+ 1 (- 3 2)) ; = 1 + (3 - 2) => 2
+
+; Types
+;;;;;;;;;;;;;
+
+; Clojure utilise les types d'objets Java pour les booléens, les chaînes de
+; caractères et les nombres.
+; Utilisez `class` pour inspecter les types.
+(class 1) ; Les nombres entiers littéraux sont java.lang.Long par défaut
+(class 1.); Les flottants littéraux sont java.lang.Double
+(class ""); Les chaînes sont toujours entourées de guillemets doubles, et sont java.lang.String
+(class false) ; Les booléens sont java.lang.Boolean
+(class nil); La valeur "null" est appelée nil
+
+; Si vous voulez créer une liste littérale de données, utilisez ' pour en
+; empêcher son évaluation
+'(+ 1 2) ; => (+ 1 2)
+; (qui est un raccourci pour (quote (+ 1 2)))
+
+; Vous pouvez évaluer une liste "quotée":
+(eval '(+ 1 2)) ; => 3
+
+; Collections & séquences
+;;;;;;;;;;;;;;;;;;;;;;;;;
+
+; Les listes sont des structures de données en listes chaînées, alors que les
+; vecteurs reposent sur des tableaux.
+; Les vecteurs et les listes sont des classes Java aussi !
+(class [1 2 3]); => clojure.lang.PersistentVector
+(class '(1 2 3)); => clojure.lang.PersistentList
+
+; Une liste serait écrite comme (1 2 3), mais nous devons la quoter
+; pour empêcher l'interpréteur de penser que c'est une fonction.
+; Et (list 1 2 3) est la même chose que '(1 2 3)
+
+; Les "Collections" sont juste des groupes de données
+; Les listes et les vecteurs sont tous deux des collections:
+(coll? '(1 2 3)) ; => true
+(coll? [1 2 3]) ; => true
+
+; Les "séquences" (seqs) sont des abstractions à partir de listes de données.
+; Seules les listes sont elles-mêmes des séquences.
+(seq? '(1 2 3)) ; => true
+(seq? [1 2 3]) ; => false
+
+; Une séquence n'a besoin de fournir une entrée que lorsqu'on y accède.
+; Donc, les séquences peuvent être "lazy" -- et définir une série infinie:
+(range 4) ; => (0 1 2 3)
+(range) ; => (0 1 2 3 4 ...) (une série infinie)
+(take 4 (range)) ; (0 1 2 3)
+
+; Utilisez cons pour ajouter un item au début d'une liste ou d'un vecteur
+(cons 4 [1 2 3]) ; => (4 1 2 3)
+(cons 4 '(1 2 3)) ; => (4 1 2 3)
+
+; Conj ajoutera un item à une collection de la manière la plus efficace
+; Pour les listes, conj ajoute l'item au début; pour les vecteurs, à la fin.
+(conj [1 2 3] 4) ; => [1 2 3 4]
+(conj '(1 2 3) 4) ; => (4 1 2 3)
+
+; Utilisez concat pour ajouter des listes ou vecteurs:
+(concat [1 2] '(3 4)) ; => (1 2 3 4)
+
+; Utilisez filter, map pour interagir avec des collections
+(map inc [1 2 3]) ; => (2 3 4)
+(filter even? [1 2 3]) ; => (2)
+
+; Utilisez reduce pour les réduire
+(reduce + [1 2 3 4])
+; = (+ (+ (+ 1 2) 3) 4)
+; => 10
+
+; Reduce peut aussi prendre un argument pour la valeur initiale
+(reduce conj [] '(3 2 1))
+; = (conj (conj (conj [] 3) 2) 1)
+; => [3 2 1]
+
+; Fonctions
+;;;;;;;;;;;;;;;;;;;;;
+
+; Utilisez fn pour créer de nouvelles fonctions.
+; Une fonction renvoie toujours sa dernière expression.
+(fn [] "Hello World") ; => fn
+
+; (Vous devez ajouter des parenthèses pour l'appeler)
+((fn [] "Hello World")) ; => "Hello World"
+
+; Vous pouvez créer une variable en utilisant def
+(def x 1)
+x ; => 1
+
+; Assignez une fonction à une variable
+(def hello-world (fn [] "Hello World"))
+(hello-world) ; => "Hello World"
+
+; Vous pouvez raccourcir le procédé en utilisant defn
+(defn hello-world [] "Hello World")
+
+; [] contient la liste des arguments de la fonction
+(defn hello [name]
+ (str "Hello " name))
+(hello "Steve") ; => "Hello Steve"
+
+; Vous pouvez aussi utiliser ce raccourci pour créer des fonctions
+(def hello2 #(str "Hello " %1))
+(hello2 "Fanny") ; => "Hello Fanny"
+
+; Vous pouvez avoir des fonctions multi-variadiques
+(defn hello3
+ ([] "Hello World")
+ ([name] (str "Hello " name)))
+(hello3 "Jake") ; => "Hello Jake"
+(hello3) ; => "Hello World"
+
+; Les fonctions peuvent inclure des arguments supplémentaires dans une séquence
+(defn count-args [& args]
+ (str "You passed " (count args) " args: " args))
+(count-args 1 2 3) ; => "Vous avez passé 3 args: (1 2 3)"
+
+; Vous pouvez combiner les arguments normaux et supplémentaires
+(defn hello-count [name & args]
+ (str "Hello " name ", vous avez passé " (count args) " args supplémentaires"))
+(hello-count "Finn" 1 2 3)
+; => "Hello Finn, vous avez passé 3 args supplémentaires"
+
+
+; Maps
+;;;;;;;;;;;;;;;
+
+; Les hashmaps et les arraymaps partagent une interface. Les hashmaps
+; sont interrogés plus rapidement mais ne retiennent pas l'ordre des clefs.
+(class {:a 1 :b 2 :c 3}) ; => clojure.lang.PersistentArrayMap
+(class (hash-map :a 1 :b 2 :c 3)) ; => clojure.lang.PersistentHashMap
+
+; Les array maps deviennent automatiquement des hashmaps pour la
+; plupart des opérations si elles deviennent assez larges, donc vous
+; n'avez pas à vous en faire.
+
+; Tous les types "hashables" sont acceptés comme clefs, mais en
+; général on utilise des mots-clefs ("keywords")
+; Les mots-clefs sont comme les chaînes de caractères mais en plus efficaces
+(class :a) ; => clojure.lang.Keyword
+
+(def stringmap {"a" 1, "b" 2, "c" 3})
+stringmap ; => {"a" 1, "b" 2, "c" 3}
+
+(def keymap {:a 1, :b 2, :c 3})
+keymap ; => {:a 1, :c 3, :b 2}
+
+; Au passage, les virgules sont toujours traitées comme des espaces et
+; ne font rien.
+
+; Sélectionnez une valeur dans une map en l'appelant comme fonction
+(stringmap "a") ; => 1
+(keymap :a) ; => 1
+
+; Les mots-clefs peuvent aussi être utilisés pour sélectionner leur
+; valeur dans une map !
+(:b keymap) ; => 2
+
+; N'essayez pas ça avec les chaînes de caractères
+;("a" stringmap)
+; => Exception: java.lang.String cannot be cast to clojure.lang.IFn
+
+; Sélectionner une clef absente renvoie nil
+(stringmap "d") ; => nil
+
+; Use assoc to add new keys to hash-maps
+(def newkeymap (assoc keymap :d 4))
+newkeymap ; => {:a 1, :b 2, :c 3, :d 4}
+
+; Mais souvenez-vous, les types en Clojure sont immuables !
+keymap ; => {:a 1, :b 2, :c 3}
+
+; Utilisez dissoc pour retirer des clefs
+(dissoc keymap :a :b) ; => {:c 3}
+
+; Ensembles
+;;;;;;;;;;;;;;;
+
+(class #{1 2 3}) ; => clojure.lang.PersistentHashSet
+(set [1 2 3 1 2 3 3 2 1 3 2 1]) ; => #{1 2 3}
+
+; Ajoutez un élément avec conj
+(conj #{1 2 3} 4) ; => #{1 2 3 4}
+
+; Retirez-en un avec disj
+(disj #{1 2 3} 1) ; => #{2 3}
+
+; Testez la présence en utilisant l'ensemble comme une fonction
+(#{1 2 3} 1) ; => 1
+(#{1 2 3} 4) ; => nil
+
+; Il y a encore d'autres fonctions dans l'espace de nom clojure.sets.
+
+; Formes utiles
+;;;;;;;;;;;;;;;
+
+; Les constructions logiques en Clojure sont juste des macros, et
+ressemblent à toutes les autres formes:
+(if false "a" "b") ; => "b"
+(if false "a") ; => nil
+
+; Utilisez let pour créer des assignations temporaires
+(let [a 1 b 2]
+ (> a b)) ; => false
+
+; Groupez les énoncés ensemble avec do
+(do
+ (print "Hello")
+ "World") ; => "World" (prints "Hello")
+
+; Les fonctions ont un do implicit
+(defn print-and-say-hello [name]
+ (print "Saying hello to " name)
+ (str "Hello " name))
+(print-and-say-hello "Jeff") ;=> "Hello Jeff" (prints "Saying hello to Jeff")
+
+; De même pour let
+(let [name "Urkel"]
+ (print "Saying hello to " name)
+ (str "Hello " name)) ; => "Hello Urkel" (prints "Saying hello to Urkel")
+
+; Modules
+;;;;;;;;;;;;;;;
+
+; Utilisez "use" pour obtenir toutes les fonctions d'un module
+(use 'clojure.set)
+
+; Maintenant nous pouvons utiliser les opération de set
+(intersection #{1 2 3} #{2 3 4}) ; => #{2 3}
+(difference #{1 2 3} #{2 3 4}) ; => #{1}
+
+; Vous pouvez aussi choisir un sous-ensemble de fonctions à importer
+(use '[clojure.set :only [intersection]])
+
+; Utilisez require pour importer un module
+(require 'clojure.string)
+
+; Utilisez / pour appeler les fonctions d'un module
+; Ici, le module est clojure.string et la fonction est blank?
+(clojure.string/blank? "") ; => true
+
+; Vous pouvez associer un nom plus court au module au moment de l'importer
+(require '[clojure.string :as str])
+(str/replace "This is a test." #"[a-o]" str/upper-case) ; => "THIs Is A tEst."
+; (#"" dénote une expression régulière)
+
+; Vous pouvez utiliser require (et use, mais ne le faites pas) en
+; appelant :require depuis un espace de noms.
+; Dans ce cas-là, vous n'avez pas besoin de "quoter" vos modules:
+(ns test
+ (:require
+ [clojure.string :as str]
+ [clojure.set :as set]))
+
+; Java
+;;;;;;;;;;;;;;;;;
+
+; Java a une librairie standard énorme, donc vous voudrez apprendre à
+; vous familiariser avec.
+
+; Utilisez import pour charger un module java
+(import java.util.Date)
+
+; Vous pouvez importer depuis un ns aussi.
+(ns test
+ (:import java.util.Date
+ java.util.Calendar))
+
+; Utilisez les noms de classes avec "." à la fin pour créer une instance
+(Date.) ; <un objet date>
+
+; Utilisez . pour invoquer des méthodes. Ou utilisez le raccourci ".method"
+(. (Date.) getTime) ; <un timestamp>
+(.getTime (Date.)) ; exactement la même chose
+
+; Utilisez / pour appeler des méthodes statiques
+(System/currentTimeMillis) ; <un timestamp> (system est toujours présent)
+
+; Utilisez doto to rendre plus tolérable l'interaction avec des
+; classes (mutables)
+(import java.util.Calendar)
+(doto (Calendar/getInstance)
+ (.set 2000 1 1 0 0 0)
+ .getTime) ; => Une classe Date. définie comme 2000-01-01 00:00:00
+
+; STM
+;;;;;;;;;;;;;;;;;
+
+; La mémoire logiciel transactionnelle ("Software Transactional Memory")
+; est le mécanisme que Clojure utilise pour gérer les états persistents.
+; Il y a plusieurs formes en Clojure qui utilisent cela.
+
+; L'atome est la plus simple. Passez-lui une valeur initiale
+(def my-atom (atom {}))
+
+; Mettez à jour un atome avec swap!.
+; swap! prend une fonction en argument et l'appelle avec la valeur
+; actuelle de l'atome comme premier argument, et les autres arguments
+; comme second argument.
+(swap! my-atom assoc :a 1) ; Définit my-atom comme le résultat de (assoc {} :a 1)
+(swap! my-atom assoc :b 2) ; Définit my-atom comme le résultat de (assoc {:a 1} :b 2)
+
+; Use '@' to dereference the atom and get the value
+my-atom ;=> Atom<#...> (Renvoie l'objet Atom)
+@my-atom ; => {:a 1 :b 2}
+
+; Voici un simple compteur utilisant un atome
+(def counter (atom 0))
+(defn inc-counter []
+ (swap! counter inc))
+
+(inc-counter)
+(inc-counter)
+(inc-counter)
+(inc-counter)
+(inc-counter)
+
+@counter ; => 5
+
+; Les autres formes STM sont les refs et les agents.
+; Refs: http://clojure.org/refs
+; Agents: http://clojure.org/agents
+```
+
+### Lectures complémentaires
+
+C'est loin d'être exhaustif, mais assez pour vous permettre de continuer.
+
+Clojure.org propose de nombreux articles:
+[http://clojure.org/](http://clojure.org/)
+
+Clojuredocs.org a de la documentation avec des exemples pour la
+plupart des fonctions principales :
+[http://clojuredocs.org/quickref/Clojure%20Core](http://clojuredocs.org/quickref/Clojure%20Core)
+
+4Clojure est une super manière d'augmenter vos compétences en Clojure et
+en programmation fonctionnelle :
+[http://www.4clojure.com/](http://www.4clojure.com/)
+
+Clojure-doc.org a pas mal d'article pour débuter :
+[http://clojure-doc.org/](http://clojure-doc.org/)
diff --git a/fr-fr/haskell.html.markdown b/fr-fr/haskell.html.markdown
new file mode 100644
index 00000000..9d0cec99
--- /dev/null
+++ b/fr-fr/haskell.html.markdown
@@ -0,0 +1,430 @@
+---
+language: haskell
+contributors:
+ - ["Adit Bhargava", "http://adit.io"]
+translators:
+ - ["David Baumgartner", "http://davidbaumgartner.ch"]
+lang: fr-fr
+---
+
+Haskell a été conçu pour être un langage fonctionnel pur et maniable. Il est connu pour ses monades et son système de types, mais je n'ai cesse d'y revenir pour son élégance. Pour moi, Haskell fait de la programmation une joie.
+
+```haskell
+-- Un commentaire en une ligne commence avec deux tirets.
+{- Un commentaire sur plusieurs lignes peut être contenu dans
+un bloc de cette façon.
+-}
+
+----------------------------------------------------
+-- 1. Types de données primitifs et opérateurs
+----------------------------------------------------
+
+-- Vous avez les nombres
+3 -- 3
+
+-- Les maths sont comme vous vous y attendez
+1 + 1 -- 2
+8 - 1 -- 7
+10 * 2 -- 20
+35 / 5 -- 7.0
+
+-- La division n'est pas entière par défaut
+35 / 4 -- 8.75
+
+-- division entière
+35 `div` 4 -- 8
+
+-- Les booléens sont primitifs
+True
+False
+
+-- Opérations avec les booléens
+not True -- False
+not False -- True
+1 == 1 -- True
+1 /= 1 -- False
+1 < 10 -- True
+
+-- Dans les exemples plus hauts, `not` est une fonction qui prend une valeur.
+-- Haskell n'a pas besoin de parenthèses pour appeler une fonction... tous
+-- les arguments sont juste listés après la fonction. Le schéma général est
+-- donc :
+-- func arg1 arg2 arg3...
+-- Voyez la section sur les fonctions pour savoir comment écrire les vôtres.
+
+-- Caractères et chaînes de caractère
+"Ceci est une chaîne de caractère."
+'a' -- caractère
+'Vous ne pouvez pas utiliser des apostrophes pour les chaînes de caractère.' -- erreur !
+
+-- Les chaînes peuvent être concaténées
+"Hello " ++ "world!" -- "Hello world!"
+
+-- Une chaîne de caractère est *réellement* une liste
+"Ceci est une chaîne." !! 0 -- 'C'
+
+
+----------------------------------------------------
+-- Listes et tuples
+----------------------------------------------------
+
+-- Tous les éléments d'une liste doit avoir le même type.
+-- les deux lignes suivantes sont semblables
+[1, 2, 3, 4, 5]
+[1..5]
+
+-- Il y a aussi des listes infinies en Haskell !
+[1..] -- une liste de tous les nombres naturels
+
+-- Les listes infinies fonctionnent parce que Haskell est « paresseux »:
+-- ça veut dire qu'il n'évalue que ce qui a besoin de l'être. Vous pouvez
+-- donc vous demander le 1000e élément de votre liste et il vous le donnera :
+
+[1..] !! 999 -- 1000
+
+-- Et là, Haskell a évalué les éléments 1 à 1000 de la liste... mais le reste
+-- de cette liste « infinie » n'existe pas encore ! En fait, Haskell ne va jamais
+-- le faire à moins qu'il ne le doive.
+
+-- Adjoindre deux listes
+[1..5] ++ [6..10]
+
+-- ajouter au début de la liste
+0:[1..5] -- [0, 1, 2, 3, 4, 5]
+
+-- l'indice d'une liste
+[0..] !! 5 -- 5
+
+-- d'autres opérations sur les listes
+head [1..5] -- 1
+tail [1..5] -- [2, 3, 4, 5]
+init [1..5] -- [1, 2, 3, 4]
+last [1..5] -- 5
+
+--liste en compréhension
+[x*2 | x <- [1..5]] -- [2, 4, 6, 8, 10]
+
+--avec un conditionnel
+[x*2 | x <- [1..5], x*2 > 4] -- [6, 8, 10]
+
+-- Chaque élément d'un tuple peut être d'un type différent, mais un
+-- tuple a une longueur fixée.
+-- Un tuple :
+("haskell", 1)
+
+-- accéder aux éléments d'un tuple
+fst ("haskell", 1) -- "haskell"
+snd ("haskell", 1) -- 1
+
+----------------------------------------------------
+-- 3. Functions
+----------------------------------------------------
+-- Une simple fonction qui prend deux paramètres
+add a b = a + b
+
+-- Notez que si vous utilisez ghci (l'interpréteur Haskell)
+-- vous devrez utiliser `let`. Par exemple :
+-- let add a b = a + b
+
+-- Utiliser une fonction
+add 1 2 -- 3
+
+-- Vous pouvez également mettre le nom de la fonction entre les
+-- deux arguments avec des accents graves :
+1 `add` 2 -- 3
+
+-- Vous pouvez également définir des fonctions qui n'ont pas de
+-- lettres ! Ça vous laisse créer vos propres opérateurs ! Voilà
+-- un opérateur qui fait une division entière :
+(//) a b = a `div` b
+35 // 4 -- 8
+
+-- Gardes : Une façon de gérer la valeur de vos arguments en amont
+fib x
+ | x < 2 = x
+ | otherwise = fib (x - 1) + fib (x - 2)
+
+-- Le filtrage par motif est similaire. Là, on a donné trois
+-- définitions différentes de `fib`. Haskell appellera automatiquement
+-- la première fonction qui correspond au motif de la valeur.
+fib 1 = 1
+fib 2 = 2
+fib x = fib (x - 1) + fib (x - 2)
+
+-- Filtrage par motif sur un tuple.
+foo (x, y) = (x + 1, y + 2)
+
+-- Filtrage par motif sur des listes. Ici, `x` est le premier
+-- élément de la liste, et `xs` le reste. On peut écrire notre
+-- propre fonction `map` :
+myMap func [] = []
+myMap func (x:xs) = func x:(myMap func xs)
+
+-- Les fonctions anonymes sont créées avec des barres obliques
+-- inverses, suivies de tous les arguments.
+myMap (\x -> x + 2) [1..5] -- [3, 4, 5, 6, 7]
+
+-- Une utilisation de fold (appelée `inject` dans quelques autres
+-- langages) avec comme paramètre une fonction anonyme.
+-- `foldl1` veut dire fold left -- soit littéralement pli gauche --
+-- et utilise la première valeur de la liste comme accumulateur.
+foldl1 (\acc x -> acc + x) [1..5] -- 15
+
+----------------------------------------------------
+-- 4. Plus de fonctions
+----------------------------------------------------
+
+-- curryfication : si vous n'appliquez pas tous les arguments à une
+-- fonction, elle devient « curryfiée ». Ça veut dire qu'elle retourne
+-- une fonction qui prend le reste des arguments.
+
+add a b = a + b
+foo = add 10 -- foo est une fonction qui prend un nombre et y ajoute 10
+foo 5 -- 15
+
+-- Une autre façon de l'écrire
+foo = (+10)
+foo 5 -- 15
+
+-- Composition de fonctions
+-- la fonction (.) enchaîne deux fonctions.
+-- Par exemple, on a foo qui est une fonction qui prend une valeur, y ajoute
+-- 10 et multiplie ce résultat par 5, et ensuite retourne la valeur finale.
+foo = (*5) . (+10)
+
+-- (5 + 10) * 5 = 75
+foo 5 -- 75
+
+-- fixation de priorité
+-- Haskell a une autre fonction appelée `$`. Elle peut changer la priorité
+-- de sorte que tout ce qu'il y a à sa gauche est calculé d'abord et ensuite
+-- appliqué à tout ce qu'il y a à droite. Vous pouvez utiliser `.` et `$`
+-- pour vous débarrasser de beaucoup de parenthèses :
+
+-- avant
+(even (fib 7)) -- False
+
+-- ensuite
+even . fib $ 7 -- False
+
+----------------------------------------------------
+-- 5. Signature de type
+----------------------------------------------------
+
+-- Haskell a un système de types très strict : par exemple, tout a un type.
+
+-- Quelques types simples :
+5 :: Integer
+"hello" :: String
+True :: Bool
+
+-- Les fonctions ont également des types.
+-- `not` prend un booléen et retourne un booléen.
+-- not :: Bool -> Bool
+
+-- Voilà une fonction qui prend deux paramètres.
+-- add :: Integer -> Integer -> Integer
+
+-- Quand vous définissez une valeur (souvenez-vous, tout est valeur en
+-- Haskell), une bonne pratique est d'écrire son type explicitement
+double :: Integer -> Integer
+double x = x * 2
+
+----------------------------------------------------
+-- 6. Flux de contrôle et structures conditionnelles
+----------------------------------------------------
+
+-- structure conditionnelle if
+haskell = if 1 == 1 then "awesome" else "awful" -- haskell = "awesome"
+
+-- les structures if peuvent être écrites sur plusieurs lignes
+haskell = if 1 == 1
+ then "awesome"
+ else "awful"
+
+-- les structures case : voilà comment vous pourriez analyser les arguments de
+-- ligne de commande
+case args of
+ "help" -> printHelp
+ "start" -> startProgram
+ _ -> putStrLn "bad args"
+
+
+-- Haskell n'a pas de boucles parce qu'il utilise la récursion.
+-- `map` applique une fonction sur chaque élément d'une liste
+
+map (*2) [1..5] -- [2, 4, 6, 8, 10]
+
+-- vous pouvez créer une fonction `for` en utilisant `map`
+for array func = map func array
+
+-- et l'utiliser
+for [0..5] $ \i -> show i
+
+-- nous aurions pu l'écrire également ainsi
+for [0..5] show
+
+-- vous pouvez utiliser foldl et foldr pour
+-- réduire une liste
+-- foldl <fonction> <valeur initiale> <liste>
+foldl (\x y -> 2*x + y) 4 [1,2,3] -- 43
+
+-- C'est donc la même chose que
+(2 * (2 * (2 * 4 + 1) + 2) + 3)
+
+-- foldl évalue de gauche à droite, foldr
+-- de droite à gauche
+foldr (\x y -> 2*x + y) 4 [1,2,3] -- 16
+
+-- Et c'est équivalent à
+(2 * 3 + (2 * 2 + (2 * 1 + 4)))
+
+----------------------------------------------------
+-- 7. Types de données
+----------------------------------------------------
+
+-- Vous pouvez écrire vos propres types de données en Haskell
+
+data Couleur = Rouge | Bleu | Vert
+
+-- Et maintenant l'utiliser dans une fonction
+
+
+say :: Couleur -> String
+say Rouge = "Vous êtes Rouge !"
+say Bleu = "Vous êtes Bleu !"
+say Vert = "Vous êtes Vert !"
+
+-- Vos types peuvent également avoir des paramètres
+
+data Maybe a = Nothing | Just a
+
+-- Tous les exemples ci-dessous sont issus du type Maybe
+Just "hello" -- of type `Maybe String`
+Just 1 -- of type `Maybe Int`
+Nothing -- of type `Maybe a` for any `a`
+
+----------------------------------------------------
+-- 8. Haskell IO
+----------------------------------------------------
+
+-- Tandis que l'IO ne peut pas être totalement expliqué pleinement
+-- sans que les monades ne le soient, il n'est pas difficile
+-- d'expliquer suffisamment pour commencer.
+
+-- Quand un programme en Haskell est exécuté, la fonction `main`
+-- est appelée. Il doit retourner une valeur de type `IO ()`.
+-- Par exemple :
+
+main :: IO ()
+main = putStrLn $ "Bonjour, le ciel ! " ++ (say Blue)
+-- putStrLn a comme type String -> IO ()
+
+-- La façon la plus simple pour faire de l'IO est de faire un programme
+-- fonction de String vers String. La fonction
+-- interact :: (String -> String) -> IO ()
+-- prend un texte, applique une fonction et affiche le résultat.
+
+countLines :: String -> String
+countLines = show . length . lines
+
+main' = interact countLines
+
+-- Vous pouvez considérer qu'une valeur de type `IO ()` représente
+-- une séquence d'actions que l'ordinateur exécute, un peu comme
+-- dans un langage impératif. On peut utiliser la structure `do`
+-- pour enchaîner des actions. Par exemple :
+
+sayHello :: IO ()
+sayHello = do
+ putStrLn "Quel est ton nom ?"
+ name <- getLine -- prend une ligne et assigne sa valeur à `name`
+ putStrLn $ "Salut, " ++ name
+
+-- Exercice : écrire votre propre version d'`interact` qui ne fait
+-- que de lire une ligne d'entrée.
+
+-- Le code de `sayHello` ne sera jamais exécuté, cependant. La seule
+-- action qui sera exécutée est la valeur de `main`.
+-- Pour lancer `sayHello`, commentez l'ancienne définition de `main`
+-- et remplacez-le par :
+-- main = sayHello
+
+-- Essaions de mieux comprendre comment la fonction `getLine` que
+-- nous venons d'utiliser. Son type est :
+-- getLine :: IO String
+-- vous pouvez considérer le type `IO a` comme un programme que
+-- le programme va générer comme une valeur de type `a` quand
+-- il sera exécuté. On peut l'enregistrer et la réutiliser en
+-- utilisant `<-`. On peut aussi faire nos propres actions
+-- de type `IO String` :
+
+action :: IO String
+action = do
+ putStrLn "C'est une ligne. Heu"
+ input1 <- getLine
+ input2 <- getLine
+ -- Le type de la structure `do` est celui de sa dernière ligne.
+ -- `return` n'est pas un mot clef, mais simplement une fonction.
+ return (input1 ++ "\n" ++ input2) -- return :: String -> IO String
+
+-- On peut maintenant l'utiliser comme on a utilisé `getLine`
+-- tout à l'heure
+
+main'' = do
+ putStrLn "Je vais afficher deux lignes !"
+ result <- action
+ putStrLn result
+ putStrLn "C'était tout !"
+
+-- Le type `IO` est un exemple de « monade ». La façon dont Haskell utilise
+-- une monade pour faire de l'IO lui permet d'être purement fonctionnel. N'importe
+-- quelle fonction qui interagit avec le « monde extérieur » (c'est à dire fait de l'IO)
+-- devient marqué comme `IO` dans la signature de son type. Ça nous montre
+-- quelles fonctions sont « pures » (n'interagissent pas avec le monde extérieur
+-- ou ne changent pas d'état) et quelles fonctions ne le sont pas.
+
+-- C'est une fonctionnalité très puissante, car il est facile d'exécuter
+-- des fonctions pures simultanément, et donc la concurrence en Haskell
+-- est très facile.
+
+
+----------------------------------------------------
+-- 9. Le REPL de Haskell
+----------------------------------------------------
+
+-- Lancer le REPL en tapant `ghci`.
+-- Vous pouvez maintenant taper du code Haskell.
+-- Toutes les nouvelles valeurs peuvent être crées
+-- avec `let` :
+
+let foo = 5
+
+-- Vous pouvez voir le type de n'importe quelle valeur avec `:t` :
+
+>:t foo
+foo :: Integer
+
+-- Vous pouvez également lancer des actions de type `IO ()`
+
+> sayHello
+Quel est ton nom ?
+Ami
+Salut, Ami !
+
+```
+
+Et Haskell ne se limite pas à ça, on trouve encore par exemple les classes de types et les monades. Il y a beaucoup de raisons qui font que coder en Haskell est si *fun*. Je vous laisse avec un dernier exemple : une implémentation de quicksort :
+
+```haskell
+qsort [] = []
+qsort (p:xs) = qsort lesser ++ [p] ++ qsort greater
+ where lesser = filter (< p) xs
+ greater = filter (>= p) xs
+```
+
+Haskell facile à installer. Téléchargez-le [ici](http://www.haskell.org/platform/).
+
+Vous pouvez trouver une approche beaucoup plus douce avec les excellents
+[Learn you a Haskell](http://lyah.haskell.fr/) ou
+[Real World Haskell (en)](http://book.realworldhaskell.org/).
diff --git a/git.html.markdown b/git.html.markdown
index abe8e3a7..4b5e466e 100644
--- a/git.html.markdown
+++ b/git.html.markdown
@@ -40,7 +40,7 @@ Version control is a system that records changes to a file, or set of files, ove
### Repository
-A set of files, directories, historical records, commits, and heads. Imagine it as a source code datastructure,
+A set of files, directories, historical records, commits, and heads. Imagine it as a source code data structure,
with the attribute that each source code "element" gives you access to its revision history, among other things.
A git repository is comprised of the .git directory & working tree.
diff --git a/java.html.markdown b/java.html.markdown
index 0dec51d1..3d0cb1d7 100644
--- a/java.html.markdown
+++ b/java.html.markdown
@@ -250,7 +250,7 @@ public class LearnJava {
// 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>"
- int foo = 5
+ int foo = 5;
String bar = (foo < 10) ? "A" : "B";
System.out.println(bar); // Prints A, because the statement is true
diff --git a/javascript.html.markdown b/javascript.html.markdown
index b15eae7c..2ac98105 100644
--- a/javascript.html.markdown
+++ b/javascript.html.markdown
@@ -38,6 +38,8 @@ doStuff()
// 1. Numbers, Strings and Operators
// Javascript has one number type (which is a 64-bit IEEE 754 double).
+// As with Lua, don't freak out about the lack of ints: doubles have a 52-bit
+// mantissa, which is enough to store integers up to about 9✕10¹⁵ precisely.
3; // = 3
1.5; // = 1.5
@@ -142,6 +144,10 @@ var myArray = ["Hello", 45, true];
// Array indices start at zero.
myArray[1]; // = 45
+// Arrays are mutable and of variable length.
+myArray.push("World");
+myArray.length; // = 4
+
// JavaScript's objects are equivalent to 'dictionaries' or 'maps' in other
// languages: an unordered collection of key-value pairs.
var myObj = {key1: "Hello", key2: "World"};
@@ -357,13 +363,13 @@ myObj.meaningOfLife; // = 43
// Constructors have a property called prototype. This is *not* the prototype of
// the constructor function itself; instead, it's the prototype that new objects
// are given when they're created with that constructor and the new keyword.
-myConstructor.prototype = {
+MyConstructor.prototype = {
myNumber: 5,
getMyNumber: function(){
return this.myNumber;
}
};
-var myNewObj2 = new myConstructor();
+var myNewObj2 = new MyConstructor();
myNewObj2.getMyNumber(); // = 5
myNewObj2.myNumber = 6
myNewObj2.getMyNumber(); // = 6
diff --git a/ko-kr/brainfuck-kr.html.markdown b/ko-kr/brainfuck-kr.html.markdown
new file mode 100644
index 00000000..661fcfea
--- /dev/null
+++ b/ko-kr/brainfuck-kr.html.markdown
@@ -0,0 +1,83 @@
+---
+language: brainfuck
+contributors:
+ - ["Prajit Ramachandran", "http://prajitr.github.io/"]
+ - ["Mathias Bynens", "http://mathiasbynens.be/"]
+translators:
+ - ["JongChan Choi", "http://0xABCDEF.com/"]
+lang: ko-kr
+---
+
+Brainfuck(f는 대문자로 적지 않습니다)은
+여덟가지 명령어만으로 튜링-완전한 최소주의 프로그래밍 언어입니다.
+
+```
+"><+-.,[]" 이외의 문자들은 무시됩니다. (쌍따옴표는 제외)
+
+브레인퍽은 30,000 칸 짜리의 0으로 초기화된 배열과,
+현재 칸을 가르키는 포인터로 표현됩니다.
+
+여덟가지의 명령어는 다음과 같습니다:
++ : 포인터가 가르키는 현재 칸의 값을 1 증가시킵니다.
+- : 포인터가 가르키는 현재 칸의 값을 1 감소시킵니다.
+> : 포인터가 다음 칸(오른쪽 칸)을 가르키도록 이동시킵니다.
+< : 포인터가 이전 칸(왼쪽 칸)을 가르키도록 이동시킵니다.
+. : 현재 칸의 값을 ASCII 문자로 출력합니다. (즉, 65 = 'A')
+, : 하나의 문자를 입력받고 그 값을 현재 칸에 대입합니다.
+[ : 현재 칸의 값이 0이면 짝이 맞는 ] 명령으로 넘어갑니다.
+ 0이 아니면 다음 명령어로 넘어갑니다.
+] : 현재 칸의 값이 0이면 다음 명령어로 넘어갑니다.
+ 0이 아니면 짝이 맞는 [ 명령으로 다시 돌아갑니다.
+
+[이랑 ]은 while 루프를 만들어냅니다. 무조건, 짝이 맞아야 합니다.
+
+몇가지 간단한 브레인퍽 프로그램을 보겠습니다.
+
+++++++ [ > ++++++++++ < - ] > +++++ .
+
+이 프로그램은 문자 'A'를 출력합니다. 처음에는, 반복할 횟수를 정하기 위한 값을
+만들기 위해 첫번째 칸의 값을 6으로 증가시킵니다. 그리고 루프로 들어가서([)
+두번째 칸으로 넘어갑니다. 루프 안에서는 두번째 칸의 값을 10 증가시키고,
+다시 첫번째 칸으로 넘어가서 값을 1 감소시킵니다. 이 루프는 여섯번 돕니다.
+(첫번째 칸의 값을 6번 감소시켜서 0이 될 때 까지는 ] 명령을 만날 때마다
+루프의 시작 지점으로 돌아갑니다)
+
+이 시점에서, 두번째 칸의 값은 60이고, 포인터는 값이 0인 첫번째 칸에 위치합니다.
+여기서 두번째 칸으로 넘어간 다음 값을 5 증가시키면 두번째 칸의 값이 65가 되고,
+65는 문자 'A'에 대응하는 아스키 코드이기 때문에, 두번째 칸의 값을 출력하면
+터미널에 'A'가 출력됩니다.
+
+, [ > + < - ] > .
+
+이 프로그램은 사용자로부터 문자 하나를 입력받아 첫번째 칸에 집어넣습니다.
+그리고 루프에 들어가서, 두번째 칸으로 넘어가 값을 한 번 증가시킨 다음,
+다시 첫번째 칸으로 넘어가서 값을 한 번 감소시킵니다.
+이는 첫번째 칸의 값이 0이 될 때까지 지속되며,
+두번째 칸은 첫번째 칸이 갖고있던 값을 가지게 됩니다.
+루프가 종료되면 포인터는 첫번째 칸을 가르키기 때문에 두번째 칸으로 넘어가고,
+해당 아스키 코드에 대응하는 문자를 출력합니다.
+
+또한 공백문자는 순전히 가독성을 위해서 작성되었다는 것을 기억하세요.
+다음과 같이 작성해도 똑같이 돌아갑니다:
+
+,[>+<-]>.
+
+한 번 돌려보고 아래의 프로그램이 실제로 무슨 일을 하는지 맞춰보세요:
+
+,>,< [ > [ >+ >+ << -] >> [- << + >>] <<< -] >>
+
+이 프로그램은 두 개의 숫자를 입력받은 뒤, 그 둘을 곱합니다.
+
+위 코드는 일단 두 번의 입력을 받고, 첫번째 칸의 값만큼 바깥 루프를 돕니다.
+그리고 루프 안에서 다시 두번째 칸의 값만큼 안쪽의 루프를 돕니다.
+그리고 그 루프에서는 세번째 칸의 값을 증가시키는데, 문제가 하나 있습니다:
+내부 루프가 한 번 끝나게 되면 두번째 칸의 값은 0이 됩니다.
+그럼 다시 바깥 루프를 돌 때에 안쪽의 루프를 돌지 않게 되는데, 이를 해결하려면
+네번째 칸의 값도 같이 증가시킨 다음, 그 값을 두번째 칸으로 옮기면 됩니다.
+그러면 세번째 칸에 곱셈의 결과가 남습니다.
+```
+
+여기까지 브레인퍽이었습니다. 참 쉽죠?
+재미삼아 브레인퍽 프로그램이나 다른 언어로 브레인퍽 인터프리터를 작성해보세요.
+인터프리터 구현은 간단한 편인데,
+사서 고생하는 것을 즐기는 편이라면 한 번 작성해보세요… 브레인퍽으로.
diff --git a/livescript.html.markdown b/livescript.html.markdown
index 8e11439b..5fd61f49 100644
--- a/livescript.html.markdown
+++ b/livescript.html.markdown
@@ -135,11 +135,19 @@ funRE = //
3 % 2 # => 1
-# Comparisons are mostly the same too, except that `==` and `===` are
-# inverted.
+# Comparisons are mostly the same too, except that `==` is the same as
+# JS's `===`, where JS's `==` in LiveScript is `~=`, and `===` enables
+# object and array comparisons, and also stricter comparisons:
2 == 2 # => true
2 == "2" # => false
-2 === "2" # => true
+2 ~= "2" # => true
+2 === "2" # => false
+
+[1,2,3] == [1,2,3] # => false
+[1,2,3] === [1,2,3] # => true
+
++0 == -0 # => true
++0 === -0 # => false
# Other relational operators include <, <=, > and >=
diff --git a/lua.html.markdown b/lua.html.markdown
index 369de908..27ce105b 100644
--- a/lua.html.markdown
+++ b/lua.html.markdown
@@ -125,7 +125,7 @@ f = function (x) return x * x end
-- And so are these:
local function g(x) return math.sin(x) end
-local g = function(x) return math.xin(x) end
+local g = function(x) return math.sin(x) end
-- Equivalent to local function g(x)..., except referring
-- to g in the function body won't work as expected.
local g; g = function (x) return math.sin(x) end
diff --git a/perl.html.markdown b/perl.html.markdown
index 18339dde..ad9155e4 100644
--- a/perl.html.markdown
+++ b/perl.html.markdown
@@ -131,19 +131,17 @@ sub logger {
# Now we can use the subroutine just as any other built-in function:
logger("We have a logger subroutine!");
-
-
```
#### Using Perl modules
-Perl modules provide a range of features to help you avoid reinventing the wheel, and can be downloaded from CPAN ( http://www.cpan.org/ ). A number of popular modules are included with the Perl distribution itself.
+Perl modules provide a range of features to help you avoid reinventing the wheel, and can be downloaded from CPAN (http://www.cpan.org/). A number of popular modules are included with the Perl distribution itself.
perlfaq contains questions and answers related to many common tasks, and often provides suggestions for good CPAN modules to use.
#### Further Reading
- - [perl-tutorial](http://perl-tutorial.org/)
- - [Learn at www.perl.com](http://www.perl.org/learn.html)
- - [perldoc](http://perldoc.perl.org/)
- - and perl built-in : `perldoc perlintro`
+ - [perl-tutorial](http://perl-tutorial.org/)
+ - [Learn at www.perl.com](http://www.perl.org/learn.html)
+ - [perldoc](http://perldoc.perl.org/)
+ - and perl built-in : `perldoc perlintro`
diff --git a/pogo.html.markdown b/pogo.html.markdown
new file mode 100644
index 00000000..60a83edd
--- /dev/null
+++ b/pogo.html.markdown
@@ -0,0 +1,202 @@
+---
+language: pogoscript
+contributors:
+ - ["Tim Macfarlane", "http://github.com/refractalize"]
+filename: learnPogo.pogo
+---
+
+Pogoscript is a little language that emphasises readability, DSLs and provides excellent asynchronous primitives for writing connected JavaScript applications for the browser or server.
+
+``` javascript
+// defining a variable
+water temperature = 24
+
+// re-assigning a variable after its definition
+water temperature := 26
+
+// functions allow their parameters to be placed anywhere
+temperature at (a) altitude = 32 - a / 100
+
+// longer functions are just indented
+temperature at (a) altitude :=
+ if (a < 0)
+ water temperature
+ else
+ 32 - a / 100
+
+// calling a function
+current temperature = temperature at 3200 altitude
+
+// this function constructs a new object with methods
+position (x, y) = {
+ x = x
+ y = y
+
+ distance from position (p) =
+ dx = self.x - p.x
+ dy = self.y - p.y
+ Math.sqrt (dx * dx + dy * dy)
+}
+
+// `self` is similar to `this` in JavaScript with the
+// exception that `self` isn't redefined in each new
+// function definition
+// `self` just does what you expect
+
+// calling methods
+position (7, 2).distance from position (position (5, 1))
+
+// as in JavaScript, objects are hashes too
+position.'x' == position.x == position.('x')
+
+// arrays
+positions = [
+ position (1, 1)
+ position (1, 2)
+ position (1, 3)
+]
+
+// indexing an array
+positions.0.y
+
+n = 2
+positions.(n).y
+
+// strings
+poem = 'Tail turned to red sunset on a juniper crown a lone magpie cawks.
+ Mad at Oryoki in the shrine-room -- Thistles blossomed late afternoon.
+ Put on my shirt and took it off in the sun walking the path to lunch.
+ A dandelion seed floats above the marsh grass with the mosquitos.
+ At 4 A.M. the two middleaged men sleeping together holding hands.
+ In the half-light of dawn a few birds warble under the Pleiades.
+ Sky reddens behind fir trees, larks twitter, sparrows cheep cheep cheep
+ cheep cheep.'
+
+// that's Allen Ginsburg
+
+// interpolation
+outlook = 'amazing!'
+console.log "the weather tomorrow is going to be #(outlook)"
+
+// regular expressions
+r/(\d+)m/i
+r/(\d+) degrees/mg
+
+// operators
+true @and true
+false @or true
+@not false
+2 < 4
+2 >= 2
+2 > 1
+
+// plus all the javascript ones
+
+// to define your own
+(p1) plus (p2) =
+ position (p1.x + p2.x, p1.y + p2.y)
+
+// `plus` can be called as an operator
+position (1, 1) @plus position (0, 2)
+// or as a function
+(position (1, 1)) plus (position (0, 2))
+
+// explicit return
+(x) times (y) = return (x * y)
+
+// new
+now = @new Date ()
+
+// functions can take named optional arguments
+spark (position, color: 'black', velocity: {x = 0, y = 0}) = {
+ color = color
+ position = position
+ velocity = velocity
+}
+
+red = spark (position 1 1, color: 'red')
+fast black = spark (position 1 1, velocity: {x = 10, y = 0})
+
+// functions can unsplat arguments too
+log (messages, ...) =
+ console.log (messages, ...)
+
+// blocks are functions passed to other functions.
+// This block takes two parameters, `spark` and `c`,
+// the body of the block is the indented code after the
+// function call
+
+render each @(spark) into canvas context @(c)
+ ctx.begin path ()
+ ctx.stroke style = spark.color
+ ctx.arc (
+ spark.position.x + canvas.width / 2
+ spark.position.y
+ 3
+ 0
+ Math.PI * 2
+ )
+ ctx.stroke ()
+
+// asynchronous calls
+
+// JavaScript both in the browser and on the server (with Node.js)
+// makes heavy use of asynchronous IO with callbacks. Async IO is
+// amazing for performance and making concurrency simple but it
+// quickly gets complicated.
+// Pogoscript has a few things to make async IO much much easier
+
+// Node.js includes the `fs` module for accessing the file system.
+// Let's list the contents of a directory
+
+fs = require 'fs'
+directory listing = fs.readdir! '.'
+
+// `fs.readdir()` is an asynchronous function, so we can call it
+// using the `!` operator. The `!` operator allows you to call
+// async functions with the same syntax and largely the same
+// semantics as normal synchronous functions. Pogoscript rewrites
+// it so that all subsequent code is placed in the callback function
+// to `fs.readdir()`.
+
+// to catch asynchronous errors while calling asynchronous functions
+
+try
+ another directory listing = fs.readdir! 'a-missing-dir'
+catch (ex)
+ console.log (ex)
+
+// in fact, if you don't use `try catch`, it will raise the error up the
+// stack to the outer-most `try catch` or to the event loop, as you'd expect
+// with non-async exceptions
+
+// all the other control structures work with asynchronous calls too
+// here's `if else`
+config =
+ if (fs.stat! 'config.json'.is file ())
+ JSON.parse (fs.read file! 'config.json' 'utf-8')
+ else
+ {
+ color: 'red'
+ }
+
+// to run two asynchronous calls concurrently, use the `?` operator.
+// The `?` operator returns a *future* which can be executed to
+// wait for and obtain the result, again using the `!` operator
+
+// we don't wait for either of these calls to finish
+a = fs.stat? 'a.txt'
+b = fs.stat? 'b.txt'
+
+// now we wait for the calls to finish and print the results
+console.log "size of a.txt is #(a!.size)"
+console.log "size of b.txt is #(b!.size)"
+
+// futures in Pogoscript are analogous to Promises
+```
+
+That's it.
+
+Download [Node.js](http://nodejs.org/) and `npm install pogo`.
+
+There is plenty of documentation on [http://pogoscript.org/](http://pogoscript.org/), inlcuding a [cheat sheet](http://pogoscript.org/cheatsheet.html), a [guide](http://pogoscript.org/guide/), and how [Pogoscript translates to Javascript](http://featurist.github.io/pogo-examples/). Get in touch on the [google group](http://groups.google.com/group/pogoscript) if you have questions!
diff --git a/pt-pt/brainfuck-pt.html.markdown b/pt-pt/brainfuck-pt.html.markdown
new file mode 100644
index 00000000..60750de8
--- /dev/null
+++ b/pt-pt/brainfuck-pt.html.markdown
@@ -0,0 +1,84 @@
+---
+language: brainfuck
+contributors:
+ - ["Prajit Ramachandran", "http://prajitr.github.io/"]
+ - ["Mathias Bynens", "http://mathiasbynens.be/"]
+translators:
+ - ["Joao Marques", "http://github.com/mrshankly"]
+lang: pt-pt
+---
+
+Brainfuck (não capitalizado excepto no início de uma frase) é uma linguagem de
+programação Turing-completa extremamente simples com apenas 8 comandos.
+
+```
+Qualquer caractere excepto "><+-.,[]" (não contar com as aspas) é ignorado.
+
+Brainfuck é representado por um vector com 30 000 células inicializadas a zero
+e um ponteiro de dados que aponta para a célula actual.
+
+Existem 8 comandos:
++ : Incrementa o valor da célula actual em 1.
+- : Decrementa o valor da célula actual em 1.
+> : Move o ponteiro de dados para a célula seguinte (célula à direita).
+< : Move o ponteiro de dados para a célula anterior (célula à esquerda).
+. : Imprime o valor ASCII da célula actual. (ex. 65 = 'A').
+, : Lê um único caractere para a célula actual.
+[ : Se o valor da célula actual for zero, salta para o ] correspondente.
+ Caso contrário, passa para a instrução seguinte.
+] : Se o valor da célula actual for zero, passa para a instrução seguinte.
+ Caso contrário, volta para a instrução relativa ao [ correspondente.
+
+[ e ] formam um ciclo while. Obviamente, devem ser equilibrados.
+
+Vejamos alguns programas básicos de brainfuck.
+
+++++++ [ > ++++++++++ < - ] > +++++ .
+
+Este programa imprime a letra 'A'. Primeiro incrementa a célula #1 para 6.
+A célula #1 será usada num ciclo. Depois é iniciado o ciclo ([) e move-se
+o ponteiro de dados para a célula #2. Incrementa-se o valor da célula #1 10
+vezes, move-se o ponteiro de dados de volta para a célula #1, e decrementa-se
+a célula #1. Este ciclo acontece 6 vezes (são necessários 6 decrementos para
+a célula #1 chegar a 0, momento em que se salta para o ] correspondente,
+continuando com a instrução seguinte).
+
+Nesta altura encontramo-nos na célula #1, cujo valor é 0, enquanto a célula #2
+tem o valor 60. Movemos o ponteiro de dados para a célula #2, incrementa-se 5
+vezes para um valor final de 65, é então impresso o valor da célula #2. Ao valor
+65 corresponde o caractere 'A' em ASCII, 'A' é então impresso para o terminal.
+
+, [ > + < - ] > .
+
+Este programa lê um caractere e copia o seu valor para a célula #1. Um ciclo é
+iniciado. Movemos o ponteiro de dados para a célula #2, incrementamos o valor na
+célula #2, movemos o ponteiro de dados de volta para a célula #1, finalmente
+decrementamos o valor na célula #1. Isto continua até o valor na célula #1 ser
+igual a 0 e a célula #2 ter o antigo valor da célula #1. Como o ponteiro de
+dados está a apontar para a célula #1 no fim do ciclo, movemos o ponteiro para a
+célula #2 e imprimimos o valor em ASCII.
+
+Os espaços servem apenas para tornar o programa mais legível. Podemos escrever
+o mesmo programa da seguinte maneira:
+
+,[>+<-]>.
+
+Tenta descobrir o que este programa faz:
+
+,>,< [ > [ >+ >+ << -] >> [- << + >>] <<< -] >>
+
+Este programa lê dois números e multiplica-os.
+
+Basicamente o programa pede dois caracteres ao utilizador. Depois é iniciado um
+ciclo exterior controlado pelo valor da célula #1. Movemos o ponteiro de dados
+para a célula #2 e inicia-se o ciclo interior controlado pelo valor da célula
+#2, incrementando o valor da célula #3. Contudo, existe um problema, no final do
+ciclo interior a célula #2 tem o valor 0. Para resolver este problema o valor da
+célula #4 é também incrementado e copiado para a célula #2.
+```
+
+Fica então explicado brainfuck. Simples, não? Por divertimento podes escrever os
+teus próprios programas em brainfuck, ou então escrever um interpretador de
+brainfuck noutra linguagem. O interpretador é relativamente fácil de se
+implementar, mas se fores masoquista, tenta escrever um interpretador de
+brainfuck… em brainfuck.
diff --git a/python.html.markdown b/python.html.markdown
index bad9a360..08e68407 100644
--- a/python.html.markdown
+++ b/python.html.markdown
@@ -112,8 +112,10 @@ None is None #=> True
## 2. Variables and Collections
####################################################
-# Printing is pretty easy
-print "I'm Python. Nice to meet you!"
+# Python has a print function, available in versions 2.7 and 3...
+print("I'm Python. Nice to meet you!")
+# and an older print statement, in all 2.x versions but removed from 3.
+print "I'm also Python!"
# No need to declare variables before assigning to them.
@@ -224,7 +226,7 @@ filled_dict.get("four") #=> None
filled_dict.get("one", 4) #=> 1
filled_dict.get("four", 4) #=> 4
-# "setdefault()" method is a safe way to add new key-value pair into dictionary
+# "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
@@ -235,7 +237,7 @@ empty_set = set()
some_set = set([1,2,2,3,4]) # some_set is now set([1, 2, 3, 4])
# Since Python 2.7, {} can be used to declare a set
-filled_set = {1, 2, 2, 3, 4} # => {1 2 3 4}
+filled_set = {1, 2, 2, 3, 4} # => {1, 2, 3, 4}
# Add more items to a set
filled_set.add(5) # filled_set is now {1, 2, 3, 4, 5}
@@ -265,11 +267,11 @@ some_var = 5
# Here is an if statement. Indentation is significant in python!
# prints "some_var is smaller than 10"
if some_var > 10:
- print "some_var is totally bigger than 10."
+ print("some_var is totally bigger than 10.")
elif some_var < 10: # This elif clause is optional.
- print "some_var is smaller than 10."
+ print("some_var is smaller than 10.")
else: # This is optional too.
- print "some_var is indeed 10."
+ print("some_var is indeed 10.")
"""
@@ -281,10 +283,10 @@ prints:
"""
for animal in ["dog", "cat", "mouse"]:
# You can use % to interpolate formatted strings
- print "%s is a mammal" % animal
-
+ print("%s is a mammal" % animal)
+
"""
-"range(number)" returns a list of numbers
+"range(number)" returns a list of numbers
from zero to the given number
prints:
0
@@ -293,7 +295,7 @@ prints:
3
"""
for i in range(4):
- print i
+ print(i)
"""
While loops go until a condition is no longer met.
@@ -305,7 +307,7 @@ prints:
"""
x = 0
while x < 4:
- print x
+ print(x)
x += 1 # Shorthand for x = x + 1
# Handle exceptions with a try/except block
@@ -324,7 +326,7 @@ except IndexError as e:
# Use "def" to create new functions
def add(x, y):
- print "x is %s and y is %s" % (x, y)
+ print("x is %s and y is %s" % (x, y))
return x + y # Return values with a return statement
# Calling functions with parameters
@@ -351,8 +353,8 @@ keyword_args(big="foot", loch="ness") #=> {"big": "foot", "loch": "ness"}
# You can do both at once, if you like
def all_the_args(*args, **kwargs):
- print args
- print kwargs
+ print(args)
+ print(kwargs)
"""
all_the_args(1, 2, a=3, b=4) prints:
(1, 2)
@@ -420,10 +422,10 @@ class Human(object):
# Instantiate a class
i = Human(name="Ian")
-print i.say("hi") # prints out "Ian: hi"
+print(i.say("hi")) # prints out "Ian: hi"
j = Human("Joel")
-print j.say("hello") #prints out "Joel: hello"
+print(j.say("hello")) #prints out "Joel: hello"
# Call our class method
i.get_species() #=> "H. sapiens"
@@ -443,12 +445,12 @@ Human.grunt() #=> "*grunt*"
# You can import modules
import math
-print math.sqrt(16) #=> 4
+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
@@ -459,7 +461,7 @@ import math as m
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
+# can write your own, and import them. The name of the
# module is the same as the name of the file.
# You can find out which functions and attributes
diff --git a/ru-ru/ruby-ru.html.markdown b/ru-ru/ruby-ru.html.markdown
index ead681ef..318e0e09 100644
--- a/ru-ru/ruby-ru.html.markdown
+++ b/ru-ru/ruby-ru.html.markdown
@@ -43,7 +43,7 @@ translators:
# Логические величины -- это объекты
nil # Здесь ничего нет
-true # правда
+true # истина
false # ложь
nil.class #=> NilClass
@@ -79,7 +79,8 @@ false.class #=> FalseClass
placeholder = "использовать интерполяцию строк"
"Я могу #{placeholder}, когда создаю строку с двойными кавычками"
-#=> "Я могу использовать интерполяцию строк, когда создаю строку с двойными кавычками"
+#=> "Я могу использовать интерполяцию строк,
+# когда создаю строку с двойными кавычками"
# печатать в стандартный вывод
@@ -107,10 +108,10 @@ path = '/bad/name/'
# Идентификаторы (тоже объекты)
# Идентификаторы -- это неизменяемые, многоразовые константы.
-# Для каждого идентификатора (кроме текста) сохраняется цифровой хэш. При последующем
-# использовании идентификатора, заместо создания нового объекта, будет найден уже
-# существующий по цифровому хэшу. Они часто используются вместо строк
-# для ускорения работы приложений
+# Для каждого идентификатора (кроме текста) сохраняется цифровой хэш.
+# При последующем использовании идентификатора, заместо создания нового объекта,
+# будет найден уже существующий по цифровому хэшу.
+# Они часто используются вместо строк для ускорения работы приложений
:pending.class #=> Symbol
@@ -178,15 +179,15 @@ new_hash.keys #=> [:defcon, :action]
# Управление ходом выполнения (Управляющие структуры)
if true
- "if условие"
+ "Если истина"
elsif false
- "else if, условие"
+ "Иначе, если ложь (опционально)"
else
- "else, условие"
+ "Во всех других случаях"
end
for counter in 1..5
- puts "#итерация {counter}"
+ puts "итерация #{counter}"
end
#=> итерация 1
#=> итерация 2
@@ -197,10 +198,11 @@ end
# Однако, никто не использует "for" для циклов.
# Вместо него Вы должны использовать метод "each" вместе с блоком кода.
#
-# Блок кода -- это один из вариантов создания замыканий (лямбды, анонимные функции).
+# Блок кода -- это один из вариантов создания замыканий (лямбды,
+# анонимные функции).
# Блок может только передаваться методу, сам по себе он существовать не может.
# "for" не имеет своей области видимости и все переменные, объявленные в нём
-# будут доступны отовсюду. "each" вместе с блоком создаёт свою область видимости.
+# будут доступны отовсюду. "each" вместе с блоком создаёт свою область видимости
# Метод "each" для диапазона значений запускает блок кода один раз
# для каждого из значений диапазона
@@ -219,7 +221,7 @@ end
# Вы также можете ограничивать блоки фигурными скобками:
(1..5).each {|counter| puts "итерация #{counter}"}
-# Содержимое управляющих структур также можно перебирать используя "each":
+# Содержимое структурных данных также можно перебирать используя "each":
array.each do |element|
puts "#{element} -- часть массива"
end
@@ -350,10 +352,27 @@ dwight.name #=> "Dwight K. Schrute"
# Вызов метода класса
Human.say("Hi") #=> "Hi"
-# Класс тоже объект в Ruby. Потому класс может иметь переменные экземпляра.
+# Область видимости переменной определяется тем, как мы даём имя переменной.
+# Переменные, имя которых начинается с "$" имеют глобальную область видимости
+$var = "I'm a global var"
+defined? $var #=> "global-variable"
+
+# Переменная экземпляра класса, она видна только в экземпляре
+@var = "I'm an instance var"
+defined? @var #=> "instance-variable"
+
+# Переменная класса, видна для всех экземпляров этого класса и в самом классе
+@@var = "I'm a class var"
+defined? @@var #=> "class variable"
+
+# Имена переменных с большой буквы используются для создания констант
+Var = "I'm a constant"
+defined? Var #=> "constant"
+
+# Класс тоже объект в Ruby. Класс может иметь переменные экземпляра.
# Переменная класса доступна в классе, его экземплярах и его потомках.
-# Базовый класс
+# Пример класса
class Human
@@foo = 0
@@ -396,4 +415,54 @@ end
Human.bar # 0
Doctor.bar # nil
+module ModuleExample
+ def foo
+ 'foo'
+ end
+end
+
+# Включение модулей в класс добавляет их методы в экземпляр класса
+# Или в сам класс, зависит только от метода подключения
+class Person
+ include ModuleExample
+end
+
+class Book
+ extend ModuleExample
+end
+
+Person.foo # => NoMethodError: undefined method `foo' for Person:Class
+Person.new.foo # => 'foo'
+Book.foo # => 'foo'
+Book.new.foo # => NoMethodError: undefined method `foo'
+
+# Коллбэки при подключении модуля
+
+module ConcernExample
+ def self.included(base)
+ base.extend(ClassMethods)
+ base.send(:include, InstanceMethods)
+ end
+
+ module ClassMethods
+ def bar
+ 'bar'
+ end
+ end
+
+ module InstanceMethods
+ def qux
+ 'qux'
+ end
+ end
+end
+
+class Something
+ include ConcernExample
+end
+
+Something.bar # => 'bar'
+Something.qux # => NoMethodError: undefined method `qux'
+Something.new.bar # => NoMethodError: undefined method `bar'
+Something.new.qux # => 'qux'
```
diff --git a/ruby.html.markdown b/ruby.html.markdown
index b9ba83cb..8723e18f 100644
--- a/ruby.html.markdown
+++ b/ruby.html.markdown
@@ -287,6 +287,18 @@ surround { puts 'hello world' }
# }
+# You can pass a block to a function
+# "&" marks a reference to a passed block
+def guests(&block)
+ block.call "some_argument"
+end
+
+# You can pass a list of arguments, which will be converted into an array
+# That's what splat operator ("*") is for
+def guests(*array)
+ array.each { |guest| puts "#{guest}" }
+end
+
# Define a class with the class keyword
class Human
diff --git a/scala.html.markdown b/scala.html.markdown
index b1b3ecbf..03c1ea76 100644
--- a/scala.html.markdown
+++ b/scala.html.markdown
@@ -374,7 +374,7 @@ import scala.collection.immutable._
import scala.collection.immutable.{List, Map}
// Rename an import using '=>'
-import scala.collection.immutable{ List => ImmutableList }
+import scala.collection.immutable.{ List => ImmutableList }
// Import all classes, except some. The following excludes Map and Set:
import scala.collection.immutable.{Map => _, Set => _, _}
diff --git a/vi-vn/git-vi.html.markdown b/vi-vn/git-vi.html.markdown
new file mode 100644
index 00000000..77fec983
--- /dev/null
+++ b/vi-vn/git-vi.html.markdown
@@ -0,0 +1,392 @@
+---
+category: tool
+tool: git
+contributors:
+ - ["Jake Prather", "http://github.com/JakeHP"]
+filename: LearnGit-vi.txt
+---
+
+Git là một hệ quản lý mã nguồn và phiên bản phân tán (distributed version control and source code management system).
+
+Nó làm được điều này là do một loạt các snapshot từ đề án của bạn, and nó hoạt động
+với các snapshot đó để cung cấp cho bạn với chức năng đến phiên bản và
+quản lý mã nguồn của bạn.
+
+## Khái Niệm Versioning
+
+### Version Control là gì?
+
+Version Control là một hệ thống ghi lại những thay đổi ở một tập tin, hay một nhóm các tập tin, theo thời gian.
+
+### Centralized Versioning VS Distributed Versioning
+
+* Quản lý phiên bản tập trung (Centralized Versioning) tập trung vào việc đồng bộ hóa, theo dõi, và lưu trữ tập tin.
+* Quản lý phiên bản phân tán (Distributed Versioning) tập trung vào việc chia sẻ các thay đổi. Mỗi sự thay đổi có một mã định dạng (id) duy nhất.
+* Các hệ phân tán không có cấu trúc định sẵn. Bạn có thể thay đổi một kiểu SVN, hệ phân tán, với git.
+
+[Thông tin thêm](http://git-scm.com/book/en/Getting-Started-About-Version-Control)
+
+### Tại Sao Dùng Git?
+
+* Có thể hoạt động offline.
+* Cộng tác với nhau rất dễ dàng!
+* Phân nhánh dễ dàng!
+* Trộn (Merging)
+* Git nhanh.
+* Git linh hoạt.
+
+## Kiến Trúc Git
+
+
+### Repository
+
+Một nhóm các tập tin, thư mục, các ghi chép trong quá khứ, commit, và heads. Tưởng tượng nó như là một cấu trúc dữ liệu mã nguồn,
+với thuộc tính mà một "nhân tố" mã nguồn cho bạn quyền truy cập đến lịch sử sửa đổi, và một số thứ khác.
+
+Một git repository bao gồm thư mục .git & tree đang làm việc.
+
+### Thư mục .git (thành phần của một repository)
+
+Thư mục .git chứa tất cả các cấu hình, log, nhánh, HEAD, và hơn nữa.
+[Danh Sách Chi Tiết.](http://gitready.com/advanced/2009/03/23/whats-inside-your-git-directory.html)
+
+### Tree Đang Làm (thành phần của một repository)
+
+Đây cơ bản là các thư mục và tập tin trong repository của bạn. Nó thường được tham chiếu
+thư mục đang làm việc của bạn
+
+### Chỉ mục (thành phần của một thư mục .git)
+
+Chỉ mục của là một staging area trong git. Nó đơn giản là một lớp riêng biệt với tree đang làm việc của bạn
+từ Git repository. Điều này cho nhà phát triền nhiều lựa chọn hơn trong việc xem xét những gì được gửi đến Git
+repository.
+
+### Commit
+
+Một git commit là một snapshot của một nhóm các thay đổi, hoặc các thao tác Working Tree của bạn.
+Ví dụ, nếu bạn thêm 5 tập tin, và xóa 2 tập tin khác, những thay đổi này sẽ được chứa trong
+một commit (hoặc snapshot). Commit này có thể được đẩy đến các repo khác, hoặc không!
+
+### Nhánh
+
+Nhánh thực chất là một con trỏ đến commit mới nhất mà bạn vừa thực hiện. Khi bạn commit,
+con trỏ này sẽ cập nhật tự động và trỏ đến commit mới nhất.
+
+### HEAD và head (thành phần của thư mục .git)
+
+HEAD là một con trỏ đến nhánh hiện tại. Một repo chỉ có một HEAD *đang hoạt động*.
+head là một con trỏ đến bất kỳ commit nào. Một repo có thể có nhiều head.
+
+### Các Tài Nguyên Mang Tính Khái Niệm
+
+* [Git For Computer Scientists](http://eagain.net/articles/git-for-computer-scientists/)
+* [Git For Designers](http://hoth.entp.com/output/git_for_designers.html)
+
+
+## Các Lệnh
+
+
+### init
+
+Tạo một repo Git rỗng. Các cài đặt, thông tin lưu trữ... của Git
+được lưu ở một thư mục tên là ".git".
+
+```bash
+$ git init
+```
+
+### config
+
+Để chỉnh tùy chọn. Bất kể là cho repo, hay cho hệ thống, hay điều chỉnh
+toàn cục (global)
+
+
+
+```bash
+# In Ra & Và Gán Một Số Biến Tùy Chỉnh Cơ Bản (Toàn cục - Global)
+$ git config --global user.email
+$ git config --global user.name
+
+$ git config --global user.email "MyEmail@Zoho.com"
+$ git config --global user.name "My Name"
+```
+
+[Tìm hiểu thêm về git config.](http://git-scm.com/docs/git-config)
+
+### help
+
+Để cho bạn lối truy cập nhanh đến một chỉ dẫn cực kỳ chi tiết của từng lệnh. Hoặc chỉ để
+nhắc bạn một số cú pháp.
+
+```bash
+# Xem nhanh các lệnh có sẵn
+$ git help
+
+# Xem tất các các lệnh
+$ git help -a
+
+# Lệnh help riêng biệt - tài liệu người dùng
+# git help <command_here>
+$ git help add
+$ git help commit
+$ git help init
+```
+
+### status
+
+Để hiển thị sự khác nhau giữa tập tin index (cơ bản là repo đang làm việc) và HEAD commit
+hiện tại.
+
+
+```bash
+# Sẽ hiển thị nhánh, các tập tin chưa track (chưa commit), các thay đổi và những khác biệt khác
+$ git status
+
+# Để xem các "tid bits" về git status
+$ git help status
+```
+
+### add
+
+Để thêm các tập vào tree/thư mục/repo hiện tại. Nếu bạn không `git add` các tập tin mới đến
+tree/thư mục hiện tại, chúng sẽ không được kèm theo trong các commit!
+
+```bash
+# thêm một file vào thư mục hiện tại
+$ git add HelloWorld.java
+
+# thêm một file vào một thư mục khác
+$ git add /path/to/file/HelloWorld.c
+
+# Hỗ trợ Regular Expression!
+$ git add ./*.java
+```
+
+### branch
+
+Quản lý nhánh. Bạn có thể xem, sửa, tạo, xóa các nhánh bằng cách dùng lệnh này.
+
+```bash
+# liệt kê các nhanh đang có và ở remote
+$ git branch -a
+
+# tạo nhánh mới
+$ git branch myNewBranch
+
+# xóa một nhánh
+$ git branch -d myBranch
+
+# đặt tên lại một nhánh
+# git branch -m <oldname> <newname>
+$ git branch -m myBranchName myNewBranchName
+
+# chỉnh sủa diễn giải của một nhánh
+$ git branch myBranchName --edit-description
+```
+
+### checkout
+
+Cập nhật tất cả các file torng tree hiện tại để cho trùng khớp với phiên bản của index, hoặc tree cụ thể.
+
+```bash
+# Checkout (chuyển) một repo - mặc định là nhánh master
+$ git checkout
+# Checkout một nhánh cụ thể
+$ git checkout branchName
+# Tạo một nhánh mới và chuyển đến nó, tương tự: "git branch <name>; git checkout <name>"
+$ git checkout -b newBranch
+```
+
+### clone
+
+Nhân bản, hoặc sao chép, một repo hiện có thành một thư mục mới. Nó cũng thêm
+các nhánh có remote-tracking cho mỗi nhánh trong một repo được nhân bản, mà
+cho phép bạn push đến một nhánh remote.
+
+```bash
+# Nhân bản learnxinyminutes-docs
+$ git clone https://github.com/adambard/learnxinyminutes-docs.git
+```
+
+### commit
+
+Lưu trữ nội dung hiện tại của index trong một "commit" mới. Điều này cho phép tạo ra thay đổi và một lời nhắn (ghi chú) tạo ra bởi người dùng.
+
+```bash
+# commit với một ghi chú
+$ git commit -m "Added multiplyNumbers() function to HelloWorld.c"
+```
+
+### diff
+
+Hiển thị sự khác biệt giữa một file trong thư mục hiện tại, index và commits.
+
+```bash
+# Hiển thị sự khác biệt giữa thư mục hiện tại và index
+$ git diff
+
+# Hiển thị khác biệt giữa index và commit mới nhất.
+$ git diff --cached
+
+# Hiển thị khác biệt giữa thư mục đang làm việc và commit mới nhất
+$ git diff HEAD
+```
+
+### grep
+
+Cho phép bạn tìm kiếm nhanh một repo.
+
+Các tinh chỉnh tùy chọn:
+
+```bash
+# Cảm ơn Travis Jeffery vì những lệnh này
+# Đặt số của dòng được hiển thị trong kết quả tìm kiếm grep
+$ git config --global grep.lineNumber true
+
+# Làm cho kết quả tìm kiếm dễ đọc hơn, bao gồm cả gom nhóm
+$ git config --global alias.g "grep --break --heading --line-number"
+```
+
+```bash
+# Tìm "variableName" trong tất cả các file Java
+$ git grep 'variableName' -- '*.java'
+
+# Tìm một dòng mà có chứa "arrayListName" và, "add" hoặc "remove"
+$ git grep -e 'arrayListName' --and \( -e add -e remove \)
+```
+
+Google để xem thêm các ví dụ
+[Git Grep Ninja](http://travisjeffery.com/b/2012/02/search-a-git-repo-like-a-ninja)
+
+### log
+
+Hiển thị các commit đến repo.
+
+```bash
+# Hiện tất cả các commit
+$ git log
+
+# Hiện X commit
+$ git log -n 10
+
+# Chỉ hiện các commit đã merge merge commits
+$ git log --merges
+```
+
+### merge
+
+"Trộn" các thay đổi từ commit bên ngoài vào trong nhánh hiện tại.
+
+```bash
+# Merge nhánh cụ thể vào nhánh hiện tại.
+$ git merge branchName
+
+# Luôn khởi tạo một merge commit khi trộn (merge)
+$ git merge --no-ff branchName
+```
+
+### mv
+
+Đặt lại tên hoặc di chuyển một file
+
+```bash
+# Đặt lại tên một file
+$ git mv HelloWorld.c HelloNewWorld.c
+
+# Di chuyển một file
+$ git mv HelloWorld.c ./new/path/HelloWorld.c
+
+# Buộc đặt lại tên hoặc di chuyển
+# "existingFile" đã tồn tại trong thự mục, sẽ bị ghi đè
+$ git mv -f myFile existingFile
+```
+
+### pull
+
+Kéo (tải) về từ một repo và merge nó vào nhánh khác.
+
+```bash
+# Cập nhật repo cục bộ của bạn, bằng cách merge các thay đổi mới
+# từ remote "origin" và nhánh "master".
+# git pull <remote> <branch>
+# git pull => hoàn toàn mặc định như => git pull origin master
+$ git pull origin master
+
+# Merge các thay đổi từ nhánh remote và rebase
+# các commit nhánh lên trên thư mục cục bộ, như: "git pull <remote> <branch>, git rebase <branch>"
+$ git pull origin master --rebase
+```
+
+### push
+
+Đẩy và trộn (mege) các tay đổi từ một nhánh đế một remote & nhánh.
+
+```bash
+# Push và merge các thay đổi từ repo cục bộ đến một
+# remote tên là "origin" và nhánh "master".
+# git push <remote> <branch>
+# git push => hoàn toàn defaults to => git push origin master
+$ git push origin master
+```
+
+### rebase (thận trọng)
+
+Lấy tất cả các thay đổi mà đã được commit trên một nhánh, và replay (?) chúng trên một nhánh khác.
+*Không rebase các commit mà bạn đã push đến một repo công khai*.
+
+```bash
+# Rebase experimentBranch lên master
+# git rebase <basebranch> <topicbranch>
+$ git rebase master experimentBranch
+```
+
+[Đọc Thêm.](http://git-scm.com/book/en/Git-Branching-Rebasing)
+
+### reset (thận trọng)
+
+Thiết lập lạo HEAD hiện tại đến một trạng thái cụ thể. Điều này cho phép bạn làm lại các merges,
+pulls, commits, thêm, and hơn nữa. Nó là một lệnh hay nhưng cũng nguy hiểm nếu bạn không
+biết mình đang làm gì.
+
+```bash
+# Thiết lập lại staging area, để trùng với commit mới nhất (để thư mục không thay đổi)
+$ git reset
+
+# Thiết lập lại staging area, để trùng với commit mới nhất, và ghi đè lên thư mục hiện tại
+$ git reset --hard
+
+# Di chuyển nhánh hiện tại đến một commit cụ thể (để thư mục không thay đổi)
+# tất cả thay đổi vẫn duy trì trong thư mục.
+$ git reset 31f2bb1
+
+# Di chuyển nhánh hiện tại lùi về một commit cụ thể
+# và làm cho thư mục hiện tại trùng (xóa các thay đổi chưa được commit và tất cả các commit
+# sau một commit cụ thể).
+$ git reset --hard 31f2bb1
+```
+
+### rm
+
+Ngược lại với git add, git rm xóa file từ tree đang làm việc.
+
+```bash
+# xóa HelloWorld.c
+$ git rm HelloWorld.c
+
+# Xóa file từ thư mục khác
+$ git rm /pather/to/the/file/HelloWorld.c
+```
+
+## Thông tin thêm
+
+* [tryGit - A fun interactive way to learn Git.](http://try.github.io/levels/1/challenges/1)
+
+* [git-scm - Video Tutorials](http://git-scm.com/videos)
+
+* [git-scm - Documentation](http://git-scm.com/docs)
+
+* [Atlassian Git - Tutorials & Workflows](https://www.atlassian.com/git/)
+
+* [SalesForce Cheat Sheet](https://na1.salesforce.com/help/doc/en/salesforce_git_developer_cheatsheet.pdf)
+
+* [GitGuys](http://www.gitguys.com/)
diff --git a/vi-vn/objective-c-vi.html.markdown b/vi-vn/objective-c-vi.html.markdown
new file mode 100644
index 00000000..f6296ec0
--- /dev/null
+++ b/vi-vn/objective-c-vi.html.markdown
@@ -0,0 +1,318 @@
+---
+
+language: Objective-C
+contributors:
+ - ["Eugene Yagrushkin", "www.about.me/yagrushkin"]
+ - ["Yannick Loriot", "https://github.com/YannickL"]
+lang: vi-vi
+filename: LearnObjectiveC-vi.m
+
+---
+
+Objective-C là ngôn ngữ lập trình chính được sử dụng bởi Apple cho các hệ điều hành OS X, iOS và các framework tương ứng của họ, Cocoa và Cocoa Touch.
+Nó là một ngôn ngữ lập trình mục đích tổng quát, hướng đối tượng có bổ sung thêm kiểu truyền thông điệp giống Smalltalk vào ngôn ngữ lập trình C.
+
+```objective-c
+// Chú thích dòng đơn bắt đầu với //
+
+/*
+Chú thích đa dòng trông như thế này.
+*/
+
+// Nhập các headers của framework Foundation với cú pháp #import
+#import <Foundation/Foundation.h>
+#import "MyClass.h"
+
+// Đầu vào chương trình của bạn là một hàm gọi là
+// main với một kiểu trả về kiểu integer.
+int main (int argc, const char * argv[])
+{
+ // Tạo một autorelease pool để quản lý bộ nhớ vào chương trình
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+
+ // Sử dụng hàm NSLog() để in ra các dòng lệnh vào console
+ NSLog(@"Hello World!"); // Print the string "Hello World!"
+
+ ///////////////////////////////////////
+ // Kiểu & Biến (Types & Variables)
+ ///////////////////////////////////////
+
+ // Khai báo số nguyên
+ int myPrimitive1 = 1;
+ long myPrimitive2 = 234554664565;
+
+ // Khai báo đối tượng
+ // Đặt dấu nháy * vào trước tên biến cho khai báo đối tượng strong
+ MyClass *myObject1 = nil; // Strong
+ id myObject2 = nil; // Weak
+ // %@ là một đối tượng
+ // 'miêu tả' ('desciption') là thông lệ để trình bày giá trị của các Đối tượng
+ NSLog(@"%@ và %@", myObject1, [myObject2 description]); // In ra "(null) và (null)"
+
+ // Chuỗi
+ NSString *worldString = @"World";
+ NSLog(@"Hello %@!", worldString); // In ra "Hello World!"
+
+ // Ký tự literals
+ NSNumber *theLetterZNumber = @'Z';
+ char theLetterZ = [theLetterZNumber charValue];
+ NSLog(@"%c", theLetterZ);
+
+ // Số nguyên literals
+ NSNumber *fortyTwoNumber = @42;
+ int fortyTwo = [fortyTwoNumber intValue];
+ NSLog(@"%i", fortyTwo);
+
+ NSNumber *fortyTwoUnsignedNumber = @42U;
+ unsigned int fortyTwoUnsigned = [fortyTwoUnsignedNumber unsignedIntValue];
+ NSLog(@"%u", fortyTwoUnsigned);
+
+ NSNumber *fortyTwoShortNumber = [NSNumber numberWithShort:42];
+ short fortyTwoShort = [fortyTwoShortNumber shortValue];
+ NSLog(@"%hi", fortyTwoShort);
+
+ NSNumber *fortyTwoLongNumber = @42L;
+ long fortyTwoLong = [fortyTwoLongNumber longValue];
+ NSLog(@"%li", fortyTwoLong);
+
+ // Dấu phẩy động (floating point) literals
+ NSNumber *piFloatNumber = @3.141592654F;
+ float piFloat = [piFloatNumber floatValue];
+ NSLog(@"%f", piFloat);
+
+ NSNumber *piDoubleNumber = @3.1415926535;
+ double piDouble = [piDoubleNumber doubleValue];
+ NSLog(@"%f", piDouble);
+
+ // BOOL literals
+ NSNumber *yesNumber = @YES;
+ NSNumber *noNumber = @NO;
+
+ // Đối tượng Mảng
+ NSArray *anArray = @[@1, @2, @3, @4];
+ NSNumber *thirdNumber = anArray[2];
+ NSLog(@"Third number = %@", thirdNumber); // In ra "Third number = 3"
+
+ // Đối tượng Từ điển
+ NSDictionary *aDictionary = @{ @"key1" : @"value1", @"key2" : @"value2" };
+ NSObject *valueObject = aDictionary[@"A Key"];
+ NSLog(@"Đối tượng = %@", valueObject); // In ra "Object = (null)"
+
+ ///////////////////////////////////////
+ // Toán Tử (Operators)
+ ///////////////////////////////////////
+
+ // Các toán tử cũng hoạt động giống như ngôn ngữ C
+ // Ví dụ:
+ 2 + 5; // => 7
+ 4.2f + 5.1f; // => 9.3f
+ 3 == 2; // => 0 (NO)
+ 3 != 2; // => 1 (YES)
+ 1 && 1; // => 1 (Logical and)
+ 0 || 1; // => 1 (Logical or)
+ ~0x0F; // => 0xF0 (bitwise negation)
+ 0x0F & 0xF0; // => 0x00 (bitwise AND)
+ 0x01 << 1; // => 0x02 (bitwise dịch trái (bởi 1))
+
+ /////////////////////////////////////////////
+ // Cấu Trúc Điều Khiển (Controls Structures)
+ /////////////////////////////////////////////
+
+ // Câu lệnh If-Else
+ if (NO)
+ {
+ NSLog(@"I am never run");
+ } else if (0)
+ {
+ NSLog(@"I am also never run");
+ } else
+ {
+ NSLog(@"I print");
+ }
+
+ // Câu lệnh Switch
+ switch (2)
+ {
+ case 0:
+ {
+ NSLog(@"I am never run");
+ } break;
+ case 1:
+ {
+ NSLog(@"I am also never run");
+ } break;
+ default:
+ {
+ NSLog(@"I print");
+ } break;
+ }
+
+ // Câu lệnh vòng lặp While
+ int ii = 0;
+ while (ii < 4)
+ {
+ NSLog(@"%d,", ii++); // ii++ tăng dần, sau khi sử dụng giá trị của nó.
+ } // => in ra "0,"
+ // "1,"
+ // "2,"
+ // "3,"
+
+ // Câu lệnh vòng lặp For
+ int jj;
+ for (jj=0; jj < 4; jj++)
+ {
+ NSLog(@"%d,", jj);
+ } // => in ra "0,"
+ // "1,"
+ // "2,"
+ // "3,"
+
+ // Câu lệnh Foreach
+ NSArray *values = @[@0, @1, @2, @3];
+ for (NSNumber *value in values)
+ {
+ NSLog(@"%@,", value);
+ } // => in ra "0,"
+ // "1,"
+ // "2,"
+ // "3,"
+
+ // Câu lệnh Try-Catch-Finally
+ @try
+ {
+ // Your statements here
+ @throw [NSException exceptionWithName:@"FileNotFoundException"
+ reason:@"Không Tìm Thấy Tập Tin trên Hệ Thống" userInfo:nil];
+ } @catch (NSException * e)
+ {
+ NSLog(@"Exception: %@", e);
+ } @finally
+ {
+ NSLog(@"Finally");
+ } // => in ra "Exception: Không Tìm Thấy Tập Tin trên Hệ Thống"
+ // "Finally"
+
+ ///////////////////////////////////////
+ // Đối Tượng (Objects)
+ ///////////////////////////////////////
+
+ // Tạo một thực thể đối tượng bằng cách phân vùng nhớ và khởi tạo đối tượng đó.
+ // Một đối tượng sẽ không thật sự hoạt động cho đến khi cả 2 bước alloc] init] được hoàn thành
+ MyClass *myObject = [[MyClass alloc] init];
+
+ // Mô hình lập trình hướng đối tượng của Objective-C dựa trên việc truyền thông điệp (message)
+ // và các thực thể đối tượng với nhau.
+ // Trong Objective-C một đối tượng không đơn thuần gọi phương thức; nó truyền thông điệp.
+ [myObject instanceMethodWithParameter:@"Steve Jobs"];
+
+ // Dọn dẹp vùng nhớ mà bạn đã dùng ở chương trình
+ [pool drain];
+
+ // Kết thúc chương trình
+ return 0;
+}
+
+///////////////////////////////////////
+// Lớp và Hàm (Classes & Functions)
+///////////////////////////////////////
+
+// Khai báo lớp của bạn ở một tập tin header (MyClass.h):
+// Cú pháp Khai Báo Lớp:
+// @interface ClassName : ParentClassName <ImplementedProtocols>
+// {
+// Khai báo biến thành viên;
+// }
+// -/+ (type) Khai báo method;
+// @end
+@interface MyClass : NSObject <MyProtocol>
+{
+ int count;
+ id data;
+ NSString *name;
+}
+// Ký hiệu (notation) tiện ích để tự động khởi tạo public getter và setter
+@property int count;
+@property (copy) NSString *name; // Sao chép đối tượng trong quá trình gán.
+@property (readonly) id data; // Chỉ khai báo phương thức getter.
+
+// Phương thức
++/- (return type)methodSignature:(Parameter Type *)parameterName;
+
+// dấu '+' cho phương thức lớp
++ (NSString *)classMethod;
+
+// dấu '-' cho phương thức thực thể
+- (NSString *)instanceMethodWithParameter:(NSString *)string;
+- (NSNumber *)methodAParameterAsString:(NSString*)string andAParameterAsNumber:(NSNumber *)number;
+
+@end
+
+// Thực thi các phương thức trong một tập tin thực thi (MyClass.m):
+
+@implementation MyClass
+
+// Gọi khi đối tượng được release
+- (void)dealloc
+{
+}
+
+// Phương thức khởi tạo (Constructors) là một cách để tạo các lớp
+// Đây là phương thức khởi tạo mặc định được gọi khi đối tượng được khởi tạo
+- (id)init
+{
+ if ((self = [super init]))
+ {
+ self.count = 1;
+ }
+ return self;
+}
+
++ (NSString *)classMethod
+{
+ return [[self alloc] init];
+}
+
+- (NSString *)instanceMethodWithParameter:(NSString *)string
+{
+ return @"New string";
+}
+
+- (NSNumber *)methodAParameterAsString:(NSString*)string andAParameterAsNumber:(NSNumber *)number
+{
+ return @42;
+}
+
+// Các phương thức được khai báo vào MyProtocol
+- (void)myProtocolMethod
+{
+ // câu lệnh
+}
+
+@end
+
+/*
+ * Một protocol khai báo các phương thức mà có thể thực thi bởi bất kỳ lớp nào.
+ * Các protocol chính chúng không phải là các lớp. Chúng chỉ đơn giản là định ra giao diện (interface)
+ * mà các đối tượng khác có trách nhiệm sẽ thực thi.
+ */
+@protocol MyProtocol
+ - (void)myProtocolMethod;
+@end
+
+
+
+```
+## Xem Thêm
+
++ [Wikipedia Objective-C](http://en.wikipedia.org/wiki/Objective-C)
+
++ Apple Docs':
+ + [Learning Objective-C](http://developer.apple.com/library/ios/referencelibrary/GettingStarted/Learning_Objective-C_A_Primer/)
+
+ + [Programming With Objective-C](https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html)
+
+ + [Object-Oriented Programming with Objective-C](https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/OOP_ObjC/Introduction/Introduction.html#//apple_ref/doc/uid/TP40005149)
+
+ + [Coding Guidelines for Cocoa](https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CodingGuidelines/CodingGuidelines.html)
+
++ [iOS For High School Students: Getting Started](http://www.raywenderlich.com/5600/ios-for-high-school-students-getting-started)
diff --git a/zh-cn/r-cn.html.markdown b/zh-cn/r-cn.html.markdown
new file mode 100644
index 00000000..8a542695
--- /dev/null
+++ b/zh-cn/r-cn.html.markdown
@@ -0,0 +1,540 @@
+---
+language: R
+contributors:
+ - ["e99n09", "http://github.com/e99n09"]
+ - ["isomorphismes", "http://twitter.com/isomorphisms"]
+translators:
+ - ["小柒", "http://weibo.com/u/2328126220"]
+ - ["alswl", "https://github.com/alswl"]
+filename: learnr.r
+---
+
+R 是一门统计语言。它有很多数据分析和挖掘程序包。可以用来统计、分析和制图。
+你也可以在 LaTeX 文档中运行 `R` 命令。
+
+```python
+# 评论以 # 开始
+
+# R 语言原生不支持 多行注释
+# 但是你可以像这样来多行注释
+
+# 在窗口里按回车键可以执行一条命令
+
+
+###################################################################
+# 不用懂编程就可以开始动手了
+###################################################################
+
+data() # 浏览内建的数据集
+data(rivers) # 北美主要河流的长度(数据集)
+ls() # 在工作空间中查看「河流」是否出现
+head(rivers) # 撇一眼数据集
+# 735 320 325 392 524 450
+length(rivers) # 我们测量了多少条河流?
+# 141
+summary(rivers)
+# Min. 1st Qu. Median Mean 3rd Qu. Max.
+# 135.0 310.0 425.0 591.2 680.0 3710.0
+stem(rivers) # 茎叶图(一种类似于直方图的展现形式)
+#
+# The decimal point is 2 digit(s) to the right of the |
+#
+# 0 | 4
+# 2 | 011223334555566667778888899900001111223333344455555666688888999
+# 4 | 111222333445566779001233344567
+# 6 | 000112233578012234468
+# 8 | 045790018
+# 10 | 04507
+# 12 | 1471
+# 14 | 56
+# 16 | 7
+# 18 | 9
+# 20 |
+# 22 | 25
+# 24 | 3
+# 26 |
+# 28 |
+# 30 |
+# 32 |
+# 34 |
+# 36 | 1
+
+
+stem(log(rivers)) # 查看数据集的方式既不是标准形式,也不是取log后的结果! 看起来,是钟形曲线形式的基本数据集
+
+# The decimal point is 1 digit(s) to the left of the |
+#
+# 48 | 1
+# 50 |
+# 52 | 15578
+# 54 | 44571222466689
+# 56 | 023334677000124455789
+# 58 | 00122366666999933445777
+# 60 | 122445567800133459
+# 62 | 112666799035
+# 64 | 00011334581257889
+# 66 | 003683579
+# 68 | 0019156
+# 70 | 079357
+# 72 | 89
+# 74 | 84
+# 76 | 56
+# 78 | 4
+# 80 |
+# 82 | 2
+
+
+hist(rivers, col="#333333", border="white", breaks=25) # 试试用这些参数画画 (译者注:给 river 做统计频数直方图,包含了这些参数:数据源,颜色,边框,空格)
+hist(log(rivers), col="#333333", border="white", breaks=25) #你还可以做更多式样的绘图
+
+# 还有其他一些简单的数据集可以被用来加载。R 语言包括了大量这种 data()
+data(discoveries)
+plot(discoveries, col="#333333", lwd=3, xlab="Year", main="Number of important discoveries per year")
+# 译者注:参数为(数据源,颜色,线条宽度,X 轴名称,标题)
+plot(discoveries, col="#333333", lwd=3, type = "h", xlab="Year", main="Number of important discoveries per year")
+
+
+# 除了按照默认的年份排序,我们还可以排序来发现特征
+sort(discoveries)
+# [1] 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2
+# [26] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3
+# [51] 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4
+# [76] 4 4 4 4 5 5 5 5 5 5 5 6 6 6 6 6 6 7 7 7 7 8 9 10 12
+
+stem(discoveries, scale=2) # 译者注:茎叶图(数据,放大系数)
+#
+# The decimal point is at the |
+#
+# 0 | 000000000
+# 1 | 000000000000
+# 2 | 00000000000000000000000000
+# 3 | 00000000000000000000
+# 4 | 000000000000
+# 5 | 0000000
+# 6 | 000000
+# 7 | 0000
+# 8 | 0
+# 9 | 0
+# 10 | 0
+# 11 |
+# 12 | 0
+
+max(discoveries)
+# 12
+
+summary(discoveries)
+# Min. 1st Qu. Median Mean 3rd Qu. Max.
+# 0.0 2.0 3.0 3.1 4.0 12.0
+
+
+
+
+#基本的统计学操作也不需要任何编程知识
+
+#随机生成数据
+round(runif(7, min=.5, max=6.5))
+# 译者注:runif 产生随机数,round 四舍五入
+# 1 4 6 1 4 6 4
+
+# 你输出的结果会和我们给出的不同,除非我们设置了相同的随机种子 random.seed(31337)
+
+
+#从标准高斯函数中随机生成 9 次
+rnorm(9)
+# [1] 0.07528471 1.03499859 1.34809556 -0.82356087 0.61638975 -1.88757271
+# [7] -0.59975593 0.57629164 1.08455362
+
+
+
+
+
+
+
+
+
+#########################
+# 基础编程
+#########################
+
+# 数值
+
+#“数值”指的是双精度的浮点数
+5 # 5
+class(5) # "numeric"
+5e4 # 50000 # 用科学技术法方便的处理极大值、极小值或者可变的量级
+6.02e23 # 阿伏伽德罗常数#
+1.6e-35 # 布朗克长度
+
+# 长整数并用 L 结尾
+5L # 5
+#输出5L
+class(5L) # "integer"
+
+# 可以自己试一试?用 class() 函数获取更多信息
+# 事实上,你可以找一些文件查阅 `xyz` 以及xyz的差别
+# `xyz` 用来查看源码实现,?xyz 用来看帮助
+
+# 算法
+10 + 66 # 76
+53.2 - 4 # 49.2
+2 * 2.0 # 4
+3L / 4 # 0.75
+3 %% 2 # 1
+
+# 特殊数值类型
+class(NaN) # "numeric"
+class(Inf) # "numeric"
+class(-Inf) # "numeric" # 在以下场景中会用到 integrate( dnorm(x), 3, Inf ) -- 消除 Z 轴数据
+
+# 但要注意,NaN 并不是唯一的特殊数值类型……
+class(NA) # 看上面
+class(NULL) # NULL
+
+
+# 简单列表
+c(6, 8, 7, 5, 3, 0, 9) # 6 8 7 5 3 0 9
+c('alef', 'bet', 'gimmel', 'dalet', 'he')
+c('Z', 'o', 'r', 'o') == "Zoro" # FALSE FALSE FALSE FALSE
+
+# 一些优雅的内置功能
+5:15 # 5 6 7 8 9 10 11 12 13 14 15
+
+seq(from=0, to=31337, by=1337)
+# [1] 0 1337 2674 4011 5348 6685 8022 9359 10696 12033 13370 14707
+# [13] 16044 17381 18718 20055 21392 22729 24066 25403 26740 28077 29414 30751
+
+letters
+# [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s"
+# [20] "t" "u" "v" "w" "x" "y" "z"
+
+month.abb # "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec"
+
+
+# Access the n'th element of a list with list.name[n] or sometimes list.name[[n]]
+# 使用 list.name[n] 来访问第 n 个列表元素,有时候需要使用 list.name[[n]]
+letters[18] # "r"
+LETTERS[13] # "M"
+month.name[9] # "September"
+c(6, 8, 7, 5, 3, 0, 9)[3] # 7
+
+
+
+# 字符串
+
+# 字符串和字符在 R 语言中没有区别
+"Horatio" # "Horatio"
+class("Horatio") # "character"
+substr("Fortuna multis dat nimis, nulli satis.", 9, 15) # "multis "
+gsub('u', 'ø', "Fortuna multis dat nimis, nulli satis.") # "Fortøna møltis dat nimis, nølli satis."
+
+
+
+# 逻辑值
+
+# 布尔值
+class(TRUE) # "logical"
+class(FALSE) # "logical"
+# 和我们预想的一样
+TRUE == TRUE # TRUE
+TRUE == FALSE # FALSE
+FALSE != FALSE # FALSE
+FALSE != TRUE # TRUE
+# 缺失数据(NA)也是逻辑值
+class(NA) # "logical"
+#定义NA为逻辑型
+
+
+
+# 因子
+# 因子是为数据分类排序设计的(像是排序小朋友们的年级或性别)
+levels(factor(c("female", "male", "male", "female", "NA", "female"))) # "female" "male" "NA"
+
+factor(c("female", "female", "male", "NA", "female"))
+# female female male NA female
+# Levels: female male NA
+
+data(infert) # 自然以及引产导致的不育症
+levels(infert$education) # "0-5yrs" "6-11yrs" "12+ yrs"
+
+
+
+# 变量
+
+# 有许多种方式用来赋值
+x = 5 # 这样可以
+y <- "1" # 更推荐这样
+TRUE -> z # 这样可行,但是很怪
+
+#我们还可以使用强制转型
+as.numeric(y) # 1
+as.character(x) # "5"
+
+# 循环
+
+# for 循环语句
+for (i in 1:4) {
+ print(i)
+}
+
+# while 循环
+a <- 10
+while (a > 4) {
+ cat(a, "...", sep = "")
+ a <- a - 1
+}
+
+# 记住,在 R 语言中 for / while 循环都很慢
+# 建议使用 apply()(我们一会介绍)来错做一串数据(比如一列或者一行数据)
+
+# IF/ELSE
+
+# 再来看这些优雅的标准
+if (4 > 3) {
+ print("Huzzah! It worked!")
+} else {
+ print("Noooo! This is blatantly illogical!")
+}
+
+# =>
+# [1] "Huzzah! It worked!"
+
+# 函数
+
+# 定义如下
+jiggle <- function(x) {
+ x + rnorm(x, sd=.1) #add in a bit of (controlled) noise
+ return(x)
+}
+
+# 和其他 R 语言函数一样调用
+jiggle(5) # 5±ε. 使用 set.seed(2716057) 后, jiggle(5)==5.005043
+
+#########################
+# 数据容器:vectors, matrices, data frames, and arrays
+#########################
+
+# 单维度
+# 你可以将目前我们学习到的任何类型矢量化,只要它们拥有相同的类型
+vec <- c(8, 9, 10, 11)
+vec # 8 9 10 11
+# 矢量的类型是这一组数据元素的类型
+class(vec) # "numeric"
+# If you vectorize items of different classes, weird coercions happen
+#如果你强制的将不同类型数值矢量化,会出现特殊值
+c(TRUE, 4) # 1 4
+c("dog", TRUE, 4) # "dog" "TRUE" "4"
+
+#我们这样来取内部数据,(R 的下标索引顺序 1 开始)
+vec[1] # 8
+# 我们可以根据条件查找特定数据
+which(vec %% 2 == 0) # 1 3
+# 抓取矢量中第一个和最后一个字符
+head(vec, 1) # 8
+tail(vec, 1) # 11
+#如果下标溢出或不存会得到 NA
+vec[6] # NA
+# 你可以使用 length() 获取矢量的长度
+length(vec) # 4
+
+# 你可以直接操作矢量或者矢量的子集
+vec * 4 # 16 20 24 28
+vec[2:3] * 5 # 25 30
+# 这里有许多内置的函数,来表现向量
+mean(vec) # 9.5
+var(vec) # 1.666667
+sd(vec) # 1.290994
+max(vec) # 11
+min(vec) # 8
+sum(vec) # 38
+
+# 二维(相同元素类型)
+
+#你可以为同样类型的变量建立矩阵
+mat <- matrix(nrow = 3, ncol = 2, c(1,2,3,4,5,6))
+mat
+# =>
+# [,1] [,2]
+# [1,] 1 4
+# [2,] 2 5
+# [3,] 3 6
+# 和 vector 不一样的是,一个矩阵的类型真的是 「matrix」,而不是内部元素的类型
+class(mat) # => "matrix"
+# 访问第一行的字符
+mat[1,] # 1 4
+# 操作第一行数据
+3 * mat[,1] # 3 6 9
+# 访问一个特定数据
+mat[3,2] # 6
+# 转置整个矩阵(译者注:变成 2 行 3 列)
+t(mat)
+# =>
+# [,1] [,2] [,3]
+# [1,] 1 2 3
+# [2,] 4 5 6
+
+# 使用 cbind() 函数把两个矩阵按列合并,形成新的矩阵
+mat2 <- cbind(1:4, c("dog", "cat", "bird", "dog"))
+mat2
+# =>
+# [,1] [,2]
+# [1,] "1" "dog"
+# [2,] "2" "cat"
+# [3,] "3" "bird"
+# [4,] "4" "dog"
+class(mat2) # matrix
+# Again, note what happened!
+# 注意
+# 因为矩阵内部元素必须包含同样的类型
+# 所以现在每一个元素都转化成字符串
+c(class(mat2[,1]), class(mat2[,2]))
+
+# 按行合并两个向量,建立新的矩阵
+mat3 <- rbind(c(1,2,4,5), c(6,7,0,4))
+mat3
+# =>
+# [,1] [,2] [,3] [,4]
+# [1,] 1 2 4 5
+# [2,] 6 7 0 4
+# 哈哈,数据类型都一样的,没有发生强制转换,生活真美好
+
+# 二维(不同的元素类型)
+
+# 利用 data frame 可以将不同类型数据放在一起
+dat <- data.frame(c(5,2,1,4), c("dog", "cat", "bird", "dog"))
+names(dat) <- c("number", "species") # 给数据列命名
+class(dat) # "data.frame"
+dat
+# =>
+# number species
+# 1 5 dog
+# 2 2 cat
+# 3 1 bird
+# 4 4 dog
+class(dat$number) # "numeric"
+class(dat[,2]) # "factor"
+# data.frame() 会将字符向量转换为 factor 向量
+
+# 有很多精妙的方法来获取 data frame 的子数据集
+dat$number # 5 2 1 4
+dat[,1] # 5 2 1 4
+dat[,"number"] # 5 2 1 4
+
+# 多维(相同元素类型)
+
+# 使用 arry 创造一个 n 维的表格
+# You can make a two-dimensional table (sort of like a matrix)
+# 你可以建立一个 2 维表格(有点像矩阵)
+array(c(c(1,2,4,5),c(8,9,3,6)), dim=c(2,4))
+# =>
+# [,1] [,2] [,3] [,4]
+# [1,] 1 4 8 3
+# [2,] 2 5 9 6
+#你也可以利用数组建立一个三维的矩阵
+array(c(c(c(2,300,4),c(8,9,0)),c(c(5,60,0),c(66,7,847))), dim=c(3,2,2))
+# =>
+# , , 1
+#
+# [,1] [,2]
+# [1,] 2 8
+# [2,] 300 9
+# [3,] 4 0
+#
+# , , 2
+#
+# [,1] [,2]
+# [1,] 5 66
+# [2,] 60 7
+# [3,] 0 847
+
+#列表(多维的,不同类型的)
+
+# R语言有列表的形式
+list1 <- list(time = 1:40)
+list1$price = c(rnorm(40,.5*list1$time,4)) # 随机
+list1
+
+# You can get items in the list like so
+# 你可以这样获得列表的元素
+list1$time
+# You can subset list items like vectors
+# 你也可以和矢量一样获取他们的子集
+list1$price[4]
+
+#########################
+# apply()函数家族
+#########################
+
+# 还记得 mat 么?
+mat
+# =>
+# [,1] [,2]
+# [1,] 1 4
+# [2,] 2 5
+# [3,] 3 6
+# Use apply(X, MARGIN, FUN) to apply function FUN to a matrix X
+# 使用(X, MARGIN, FUN)将函数 FUN 应用到矩阵 X 的行 (MAR = 1) 或者 列 (MAR = 2)
+# That is, R does FUN to each row (or column) of X, much faster than a
+# R 在 X 的每一行/列使用 FUN,比循环要快很多
+apply(mat, MAR = 2, myFunc)
+# =>
+# [,1] [,2]
+# [1,] 3 15
+# [2,] 7 19
+# [3,] 11 23
+# 还有其他家族函数 ?lapply, ?sapply
+
+# 不要被吓到,虽然许多人在此都被搞混
+# plyr 程序包的作用是用来改进 apply() 函数家族
+
+install.packages("plyr")
+require(plyr)
+?plyr
+
+#########################
+# 载入数据
+#########################
+
+# "pets.csv" 是网上的一个文本
+pets <- read.csv("http://learnxinyminutes.com/docs/pets.csv")
+pets
+head(pets, 2) # 前两行
+tail(pets, 1) # 最后一行
+
+# 以 .csv 格式来保存数据集或者矩阵
+write.csv(pets, "pets2.csv") # 保存到新的文件 pets2.csv
+# set working directory with setwd(), look it up with getwd()
+# 使用 setwd() 改变工作目录,使用 getwd() 查看当前工作目录
+
+# 尝试使用 ?read.csv 和 ?write.csv 来查看更多信息
+
+#########################
+# 画图
+#########################
+
+# 散点图
+plot(list1$time, list1$price, main = "fake data") # 译者注:横轴 list1$time,纵轴 wlist1$price,标题 fake data
+# 回归图
+linearModel <- lm(price ~ time, data = list1) # 译者注:线性模型,数据集为list1,以价格对时间做相关分析模型
+linearModel # 拟合结果
+# 将拟合结果展示在图上,颜色设为红色
+abline(linearModel, col = "red")
+# 也可以获取各种各样漂亮的分析图
+plot(linearModel)
+
+# 直方图
+hist(rpois(n = 10000, lambda = 5), col = "thistle") # 译者注:统计频数直方图
+
+# 柱状图
+barplot(c(1,4,5,1,2), names.arg = c("red","blue","purple","green","yellow"))
+
+# 可以尝试着使用 ggplot2 程序包来美化图片
+install.packages("ggplot2")
+require(ggplot2)
+?ggplot2
+
+```
+
+## 获得 R
+
+* 从 [http://www.r-project.org/](http://www.r-project.org/) 获得安装包和图形化界面
+* [RStudio](http://www.rstudio.com/ide/) 是另一个图形化界面