diff options
| -rw-r--r-- | de-de/bash-de.html.markdown | 223 | ||||
| -rw-r--r-- | de-de/git-de.html.markdown | 30 | ||||
| -rw-r--r-- | de-de/go-de.html.markdown | 20 | ||||
| -rw-r--r-- | es-es/markdown-es.html.markdown | 6 | ||||
| -rw-r--r-- | fr-fr/python-fr.html.markdown | 3 | ||||
| -rw-r--r-- | go.html.markdown | 3 | ||||
| -rw-r--r-- | haskell.html.markdown | 8 | ||||
| -rw-r--r-- | id-id/xml-id.html.markdown | 2 | ||||
| -rw-r--r-- | java.html.markdown | 11 | ||||
| -rw-r--r-- | javascript.html.markdown | 50 | ||||
| -rw-r--r-- | latex.html.markdown | 3 | ||||
| -rw-r--r-- | lua.html.markdown | 2 | ||||
| -rw-r--r-- | ms-my/coffeescript-my.html.markdown | 105 | ||||
| -rw-r--r-- | php.html.markdown | 2 | ||||
| -rw-r--r-- | r.html.markdown | 104 | ||||
| -rw-r--r-- | scala.html.markdown | 23 | 
16 files changed, 503 insertions, 92 deletions
| diff --git a/de-de/bash-de.html.markdown b/de-de/bash-de.html.markdown index fb9cd9d4..541d28bb 100644 --- a/de-de/bash-de.html.markdown +++ b/de-de/bash-de.html.markdown @@ -28,18 +28,50 @@ echo Hello, world!  echo 'Dies ist die erste Zeile'; echo 'Dies die zweite Zeile'  # Variablen deklariert man so: -VARIABLE="irgendein String" +Variable="irgendein String"  # Aber nicht so: -VARIABLE = "irgendein String" -# Bash wird VARIABLE für einen Befehl halten, den es ausführen soll. Es wird einen Fehler ausgeben,  +Variable = "irgendein String" +# Bash wird 'Variable' für einen Befehl halten, den es ausführen soll. Es wird einen Fehler ausgeben,   # weil es den Befehl nicht findet.  +# Und so auch nicht: +Variable= 'Some string' +# Bash wird 'Variable' wieder für einen Befehl halten, den es ausführen soll. Es wird einen Fehler ausgeben,  +# Hier wird der Teil 'Variable=' als nur für diesen einen Befehl gültige Zuweisung an die Variable gesehen. +  # Eine Variable wird so benutzt: -echo $VARIABLE -echo "$VARIABLE" -# Wenn du eine Variable selbst benutzt – ihr Werte zuweist, sie exportierst oder irgendetwas anders –,  +echo $Variable +echo "$Variable" +echo ${Variable} +# aber +echo '$Variable' +# Wenn du eine Variable selbst benutzt – ihr Werte zuweist, sie exportierst oder irgendetwas anderes –,   # dann über ihren Namen ohne $. Aber wenn du ihren zugewiesenen Wert willst, dann musst du $ voranstellen. +# Beachte: ' (Hochkomma) verhindert das Interpretieren der Variablen + +# Ersetzen von Zeichenketten in Variablen +echo ${Variable/irgendein/neuer} +# Ersetzt das erste Vorkommen von "irgendein" durch "neuer" + +# Teil einer Zeichenkette +Laenge=7 +echo ${Variable:0:Laenge} +# Gibt nur die ersten 7 Zeichen zurück + +# Standardwert verwenden +echo ${Foo:-"ErsatzWennLeerOderUngesetzt"} +# Das funktioniert mit nicht gesetzten Variablen (Foo=) und leeren Zeichenketten (Foo="") +# Die Zahl 0 (Foo=0) liefert 0. +# Beachte: der wert der Variablen wird nicht geändert + +# Eingebaute Variable (BUILTINS): +# Einige nützliche Beispiele +echo "Rückgabewert des letzten Befehls: $?" +echo "Die PID des skripts: $$" +echo "Anzahl der Argumente beim Aufruf: $#" +echo "Alle Argumente beim Aufruf: $@" +echo "Die Argumente in einzelnen Variablen: $1 $2..."  # Einen Wert aus der Eingabe lesen:  echo "Wie heisst du?" @@ -47,14 +79,30 @@ read NAME # Wir mussten nicht mal eine neue Variable deklarieren  echo Hello, $NAME!  # Wir haben die übliche if-Struktur: -if true +# 'man test' liefert weitere Informationen zu Bedingungen +if [ "$NAME" -ne $USER ]  then -    echo "Wie erwartet" +    echo "Dein Name ist nicht dein Login-Name"  else -    echo "Und dies nicht" +    echo "Dein Name ist dein Login-Name" +fi + +# Es gibt auch bedingte Ausführung +echo "immer ausgeführt" || echo "Nur ausgeführt wenn der erste Befehl fehlschlägt" +echo "immer ausgeführt" && echo "Nur ausgeführt wenn der erste Befehl Erfolg hat" + +# Um && und || mit if statements zu verwenden, braucht man mehrfache Paare eckiger Klammern: +if [ $NAME == "Steve" ] && [ $Alter -eq 15 ] +then +    echo "Wird ausgeführt wenn $NAME gleich 'Steve' UND $Alter gleich 15." +fi + +if [ $Name == "Daniya" ] || [ $Name == "Zach" ] +then +    echo "Wird ausgeführt wenn $NAME gleich 'Daniya' ODER $NAME gleich 'Zach'."  fi -# Ausdrücke werden im folgenden Format festgehalten: +# Ausdrücke haben folgendes Format:  echo $(( 10 + 5 ))  # Anders als andere Programmiersprachen ist Bash eine Shell – es arbeitet also im Kontext von Verzeichnissen. @@ -69,13 +117,60 @@ ls -l # Liste alle Dateien und Unterverzeichnisse auf einer eigenen Zeile auf  # txt-Dateien im aktuellen Verzeichnis auflisten:  ls -l | grep "\.txt" -# Befehle können innerhalb anderer Befehle mit $( ) erstetzt werden: +# Ein- und Ausgabe können umgeleitet werden (stdin, stdout, and stderr). +# Von stdin lesen bis "EOF" allein in einer Zeile auftaucht +# und die Datei hello.py mit den Zeilen zwischen den beiden "EOF" +# überschreiben: +cat > hello.py << EOF +#!/usr/bin/env python +from __future__ import print_function +import sys +print("#stdout", file=sys.stdout) +print("#stderr", file=sys.stderr) +for line in sys.stdin: +    print(line, file=sys.stdout) +EOF + +# Führe hello.py mit verschiedenen Umleitungen von +# stdin, stdout und stderr aus: +python hello.py < "input.in" +python hello.py > "output.out" +python hello.py 2> "error.err" +python hello.py > "output-and-error.log" 2>&1 +python hello.py > /dev/null 2>&1 +# Die Fehlerausgabe würde die Datei "error.err" überschreiben (falls sie existiert)  +# verwende ">>" um stattdessen anzuhängen: +python hello.py >> "output.out" 2>> "error.err" + +# Überschreibe output.out, hänge an error.err an und zähle die Zeilen beider Dateien: +info bash 'Basic Shell Features' 'Redirections' > output.out 2>> error.err +wc -l output.out error.err + +# Führe einen Befehl aus und gib dessen "file descriptor" (zB /dev/fd/123) aus +# siehe: man fd +echo <(echo "#helloworld") + +# Mehrere Arten, um output.out mit "#helloworld" zu überschreiben: +cat > output.out <(echo "#helloworld") +echo "#helloworld" > output.out +echo "#helloworld" | cat > output.out +echo "#helloworld" | tee output.out >/dev/null + +# Löschen der Hilfsdateien von oberhalb, mit Anzeige der Dateinamen +# (mit '-i' für "interactive" erfolgt für jede Date eine Rückfrage) +rm -v output.out error.err output-and-error.log + +# Die Ausgabe von Befehlen kann mit Hilfe von $( ) in anderen Befehlen verwendet weden:  # Der folgende Befehl zeigt die Anzahl aller Dateien und Unterverzeichnisse  # im aktuellen Verzeichnis an.  echo "Dieser Ordner beinhaltet $(ls | wc -l) Dateien und Verzeichnisse." +# Dasselbe kann man mit "backticks" `` erreichen, aber diese können +# nicht verschachtelt werden. $() ist die empfohlene Methode. +echo "Dieser Ordner beinhaltet `ls | wc -l` Dateien und Verzeichnisse." +  # Bash nutzt einen case-Ausdruck, der sich ähnlich wie switch in Java oder C++ verhält. -case "$VARIABLE" +case "$Variable"  in      # Liste der Fälle, die unterschieden werden sollen      0) echo "Hier ist eine Null." @@ -83,10 +178,106 @@ in      *) echo "Das ist nicht Null."  esac -# loops iterieren über die angegebene Zahl von Argumenten: -# Der Inhalt von $VARIABLE wird dreimal ausgedruckt. -for $VARIABLE in x y z +# 'for' Schleifen iterieren über die angegebene Zahl von Argumenten: +# Der Inhalt von $Variable wird dreimal ausgedruckt. +for $Variable in {1..3}  do -    echo "$VARIABLE" +    echo "$Variable"  done + +# Oder verwende die "traditionelle 'for'-Schleife": +for ((a=1; a <= 3; a++)) +do +    echo $a +done + +# Schleifen können auch mit Dateien arbeiten: +# 'cat' zeigt zuerst file1 an und dann file2 +for Variable in file1 file2 +do +    cat "$Variable" +done + +# .. oder mit der Ausgabe eines Befehls: +# Ausgabe des Inhalts jeder Datei, die von 'ls' aufgezählt wird +for Output in $(ls) +do +    cat "$Output" +done + +# while Schleife: +while [ true ] +do +    echo "Schleifenkörper..." +    break +done + +# Funktionen definieren +# Definition: +function foo () +{ +    echo "Argumente funktionieren wie bei skripts: $@" +    echo Und: $1 $2..." +    echo "Dies ist eine Funktion" +    return 0 +} + +# oder einfacher +bar () +{ +    echo "Auch so kann man Funktionen deklarieren!" +    return 0 +} + +# Aufruf der Funktion: +foo "My name is" $Name + +# Was du noch lernen könntest: +# Ausgabe der letzten 10 Zeilen von file.txt +tail -n 10 file.txt +# Ausgabe der ersten 10 Zeilen von file.txt +head -n 10 file.txt +# sortierte Ausgabe von file.txt +sort file.txt +# Mehrfachzeilen in sortierten Dateien unterdrücken +# oder (mit -d) nur diese ausgeben +uniq -d file.txt +# Ausgabe nur der ersten Spalte (vor dem ersten ',') +cut -d ',' -f 1 file.txt +# ersetze in file.txt jedes vorkommende 'gut' durch 'super' (versteht regex) +sed -i 's/gut/super/g' file.txt +# Ausgabe nach stdout aller Zeilen von file.txt, die auf eine regex passen +# Im Beispiel: Zeilen, die mit "foo" beginnen und mit "bar" enden +grep "^foo.*bar$" file.txt +# Mit der Option "-c" wird stattdessen die Anzahl der gefundenen Zeilen ausgegeben +grep -c "^foo.*bar$" file.txt +# verwende 'fgrep' oder 'grep -F' wenn du buchstäblich nach den Zeichen +# suchen willst, ohne sie als regex zu interpretieren +fgrep "^foo.*bar$" file.txt + +# Dokumentation über die in bash eingebauten Befehle +# bekommst du mit dem eingebauten Befehl 'help' +help +help help +help for +help return +help source +help . + +# Das bash-Handbuch liest du mit 'man' +apropos bash +man 1 bash +man bash + +# Dann gibt es noch das 'info' System (drücke ? um Hilfe angezeigt zu bekommen) +apropos info | grep '^info.*(' +man info +info info +info 5 info + +# info Dokumentation über bash: +info bash +info bash 'Bash Features' +info bash 6 +info --apropos bash  ``` diff --git a/de-de/git-de.html.markdown b/de-de/git-de.html.markdown index 43939129..dea329d5 100644 --- a/de-de/git-de.html.markdown +++ b/de-de/git-de.html.markdown @@ -18,12 +18,12 @@ Anmerkung des Übersetzers: Einige englische Begriffe wie *Repository*, *Commit*  ### Was ist Versionsverwaltung? -Eine Versionskontrolle erfasst die Änderungen einer Datei oder eines Verzeichnisses im Verlauf der Zeit. +Eine Versionsverwaltung erfasst die Änderungen einer Datei oder eines Verzeichnisses im Verlauf der Zeit.  ### Zentrale im Vergleich mit verteilter Versionverwaltung -* Zentrale Versionskontrolle konzentriert sich auf das Synchronisieren, Verfolgen und Sichern von Dateien. -* Verteilte Versionskontrolle konzentriert sich auf das Teilen der Änderungen. Jede Änderung hat eine eindeutige ID. +* Zentrale Versionsverwaltung konzentriert sich auf das Synchronisieren, Verfolgen und Sichern von Dateien. +* Verteilte Versionsverwaltung konzentriert sich auf das Teilen der Änderungen. Jede Änderung hat eine eindeutige ID.  * Verteilte Systeme haben keine vorbestimmte Struktur. Ein SVN-ähnliches, zentrales System wäre mit Git ebenso umsetzbar.  [Weiterführende Informationen](http://git-scm.com/book/en/Getting-Started-About-Version-Control) @@ -61,7 +61,7 @@ Der Index ist die die Staging-Area von Git. Es ist im Grunde eine Ebene, die Arb  ### Commit -Ein Commit ist ein Schnappschuss von Uderungen in deinem Arbeitsverzeichnis. Wenn du zum Beispiel 5 Dateien hinzugefügt und 2 andere entfernt hast, werden diese Änderungen im Commit (Schnappschuss) enthalten sein. Dieser Commit kann dann in andere Repositorys gepusht werden. Oder nicht! +Ein Commit ist ein Schnappschuss von Änderungen in deinem Arbeitsverzeichnis. Wenn du zum Beispiel 5 Dateien hinzugefügt und 2 andere entfernt hast, werden diese Änderungen im Commit (Schnappschuss) enthalten sein. Dieser Commit kann dann in andere Repositories gepusht werden. Oder nicht!  ### Branch @@ -69,7 +69,9 @@ Ein Branch, ein Ast oder Zweig, ist im Kern ein Pointer auf den letzten Commit,  ### HEAD und head (Teil des .git-Verzeichnisses) -HEAD ist ein Pointer auf den aktuellen Branch. Ein Repository hat nur einen *aktiven* HEAD. Ein head ist ein Pointer, der auf ein beliebige Zahl von heads zeigt. +HEAD ist ein Pointer auf den aktuellen Branch. Ein Repository hat nur einen *aktiven* HEAD.  + +Ein *head* ist ein Pointer, der auf einen beliebigen Commit zeigt.  Ein Repository kann eine beliebige Zahl von *heads* enthalten.  ### Konzeptionelle Hintergründe @@ -127,7 +129,7 @@ Zeigt die Unterschiede zwischen Index (im Grunde dein Arbeitsverzeichnis/-reposi  ```bash -# Zeigt den Branch, nicht-verfolgte Dateien, Uderungen und andere Unterschiede an +# Zeigt den Branch, nicht-verfolgte Dateien, Änderungen und andere Unterschiede an  $ git status  # Anderes Wissenswertes über git status anzeigen @@ -151,7 +153,7 @@ $ git add ./*.java  ### branch -Verwalte alle Branches. Du kannst sie mit diesem Befehl ansehen, bearbeiten, neue erschaffen oder löschen. +Verwalte alle Branches. Du kannst sie mit diesem Befehl ansehen, bearbeiten, neue erzeugen oder löschen.  ```bash  # Liste alle bestehenden Branches und Remotes auf @@ -186,7 +188,7 @@ $ git checkout -b newBranch  ### clone -Ein bestehendes Repository in ein neues Verzeichnis klonen oder kopieren. Es fügt außerdem für hedes geklonte Repo remote-tracking Branches hinzu. Du kannst auf diese Remote-Branches pushen. +Ein bestehendes Repository in ein neues Verzeichnis klonen oder kopieren. Es fügt außerdem für jedes geklonte Repository remote-tracking Branches hinzu. Du kannst auf diese Remote-Branches pushen.  ```bash  # Klone learnxinyminutes-docs @@ -288,16 +290,16 @@ $ git mv -f myFile existingFile  ### pull -Führe einen Pull, zieht alle Daten, eines Repositorys und f?? einen Merge mit einem anderen Branch durch. +Führe einen Pull (zieht alle Daten eines Repositories) aus und führt einen Merge mit einem anderen Branch durch.  ```bash -# Update deines lokalen Repos, indem ein Merge der neuen Uderungen -# von den remote-liegenden "origin"- und "master"-Branches durchgef?? wird. +# Update deines lokalen Repos, indem ein Merge der neuen Änderungen +# von den remote-liegenden "origin"- und "master"-Branches durchgeführt wird.  # git pull <remote> <branch>  # git pull => impliziter Verweis auf origin und master  $ git pull origin master -# F?? einen Merge von Uderungen eines remote-Branch und ein Rebase +# Führt einen Merge von Änderungen eines remote-Branch und ein Rebase  # des Branch-Commits im lokalen Repo durch. Wie: pull <remote> <branch>, git rebase <branch>"  $ git pull origin master --rebase  ``` @@ -337,8 +339,8 @@ $ git reset  # Setze die Staging-Area zurück, um dem letzten Commit zu entsprechen und überschreibe das Arbeitsverzeichnis  $ git reset --hard -# Bewegt die Spitze des Branches zu dem angegebenen Commit (das Verzeichnis bleibt unber??) -# Alle Uderungen bleiben im Verzeichnis erhalten +# Bewegt die Spitze des Branches zu dem angegebenen Commit (das Verzeichnis bleibt unberührt) +# Alle Änderungen bleiben im Verzeichnis erhalten  $ git reset 31f2bb1  # Bewegt die Spitze des Branches zurück zu dem angegebenen Commit diff --git a/de-de/go-de.html.markdown b/de-de/go-de.html.markdown index 7e61bf81..d3a192fe 100644 --- a/de-de/go-de.html.markdown +++ b/de-de/go-de.html.markdown @@ -25,7 +25,7 @@ aktive Community.     zeiliger Kommentar */  // Eine jede Quelldatei beginnt mit einer Paket-Klausel. -// "main" ist ein besonderer Pkaetname, da er ein ausführbares Programm +// "main" ist ein besonderer Paketname, da er ein ausführbares Programm  // einleitet, im Gegensatz zu jedem anderen Namen, der eine Bibliothek  // deklariert.  package main @@ -38,7 +38,7 @@ import (      "strconv"  // Zeichenkettenmanipulation  ) -// Es folgt die Definition einer Funktions, in diesem Fall von "main". Auch hier +// Es folgt die Definition einer Funktion, in diesem Fall von "main". Auch hier  // ist der Name wieder besonders. "main" markiert den Eintrittspunkt des  // Programms. Vergessen Sie nicht die geschweiften Klammern!  func main() { @@ -56,7 +56,7 @@ func beyondHello() {      var x int // Deklaration einer Variable, muss vor Gebrauch geschehen.      x = 3     // Zuweisung eines Werts.      // Kurze Deklaration: Benutzen Sie ":=", um die Typisierung automatisch zu -    // folgern, die Variable zu deklarieren und ihr einen Wert zu zuweisen. +    // folgern, die Variable zu deklarieren und ihr einen Wert zuzuweisen.      y := 4      // Eine Funktion mit mehreren Rückgabewerten. @@ -147,7 +147,7 @@ func learnFlowControl() {      if false {          // nicht hier      } else { -        // sonder hier! spielt die Musik +        // sondern hier! spielt die Musik      }      // Benutzen Sie ein "switch" Statement anstatt eine Anreihung von if-s @@ -166,7 +166,7 @@ func learnFlowControl() {      // Ab hier gilt wieder: x == 1      // For ist die einzige Schleifenform in Go, sie hat aber mehrere Formen: -    for { // Endloschleife +    for { // Endlosschleife          break    // nur ein Spaß          continue // wird nie ausgeführt      } @@ -263,10 +263,10 @@ func learnConcurrency() {      // Auslesen und dann Ausgeben der drei berechneten Werte.      // Man kann nicht im voraus feststellen in welcher Reihenfolge die Werte      // ankommen. -    fmt.Println(<-c, <-c, <-c) // mit dem Kannal rechts ist <- der Empfangs-Operator +    fmt.Println(<-c, <-c, <-c) // mit dem Kanal rechts ist <- der Empfangs-Operator -    cs := make(chan string)       // ein weiterer Kannal, diesmal für strings -    cc := make(chan chan string)  // ein Kannal für string Kannäle +    cs := make(chan string)       // ein weiterer Kanal, diesmal für strings +    cc := make(chan chan string)  // ein Kanal für string Kanäle      // Start einer neuen Goroutine, nur um einen Wert zu senden      go func() { c <- 84 }() @@ -283,7 +283,7 @@ func learnConcurrency() {          fmt.Println("wird nicht passieren.")      }      // Hier wird eine der beiden Goroutines fertig sein, die andere nicht. -    // Sie wird warten bis der Wert den sie sendet von dem Kannal gelesen wird. +    // Sie wird warten bis der Wert den sie sendet von dem Kanal gelesen wird.      learnWebProgramming() // Go kann es und Sie hoffentlich auch bald.  } @@ -301,7 +301,7 @@ func learnWebProgramming() {  // Methode implementieren: ServeHTTP  func (p pair) ServeHTTP(w http.ResponseWriter, r *http.Request) {      // Senden von Daten mit einer Methode des http.ResponseWriter -    w.Write([]byte("Sie habe Go in Y Minuten gelernt!")) +    w.Write([]byte("Sie haben Go in Y Minuten gelernt!"))  }  ``` diff --git a/es-es/markdown-es.html.markdown b/es-es/markdown-es.html.markdown index d90e3eb5..bc481df7 100644 --- a/es-es/markdown-es.html.markdown +++ b/es-es/markdown-es.html.markdown @@ -11,7 +11,7 @@ lang: es-es  Markdown fue creado por John Gruber en 2004. Su propósito es ser una sintaxis fácil de leer y escribir que se convierta  fácilmente a HTML (y, actualmente, otros formatos también). -¡Denme todo la retroalimentación que quieran! / ¡Sientanse en la libertad de hacer forks o pull requests! +¡Denme toda la retroalimentación que quieran! / ¡Sientanse en la libertad de hacer forks o pull requests!  ```markdown @@ -44,7 +44,7 @@ Esto es un h2  -------------  <!-- Estilos para texto plano --> -<!-- El texto puede ser fácilmente estilizaedo con italicas, negritas o tachado  +<!-- El texto puede ser fácilmente estilizado con italicas, negritas o tachado   usando markdown -->  *Este texto está en itálicas.* @@ -62,7 +62,7 @@ Markdown en Github, también tenemos: -->  ~~Este texto está tachado.~~ -<!-- Los párrafos son una o múltuples líneas de texto adyacentes separadas por  +<!-- Los párrafos son una o múltiples líneas de texto adyacentes separadas por   una o múltiples líneas en blanco-->  Este es un párrafo. Estoy escribiendo un párrafo, ¿No es divertido? diff --git a/fr-fr/python-fr.html.markdown b/fr-fr/python-fr.html.markdown index 3f6dcabb..d78291be 100644 --- a/fr-fr/python-fr.html.markdown +++ b/fr-fr/python-fr.html.markdown @@ -14,8 +14,7 @@ Je suis tombé amoureux de Python de par la clarté de sa syntaxe. C'est pratiqu  Vos retours sont grandement appréciés. Vous pouvez me contacter sur Twitter [@louiedinh](http://twitter.com/louiedinh) ou par e-mail: louiedinh [at] [google's email service] -NB: Cet artice s'applique spécifiquement à Python 2.7, mais devrait s'appliquer pour toute version Python 2.x -Vous pourrez bientôt trouver un article pour Python 3 en Français. Pour le moment vous pouvez jettez un coup d'oeil à l'article [Python 3 en Anglais](http://learnxinyminutes.com/docs/python3/). +N.B. : Cet article s'applique spécifiquement à Python 2.7, mais devrait s'appliquer pour toute version Python 2.x. Python 2.7 est en fin de vie et ne sera plus maintenu à partir de 2020, il est donc recommandé d'apprendre Python avec Python 3. Pour Python 3.x, il existe un autre [tutoriel pour Python 3](http://learnxinyminutes.com/docs/fr-fr/python3-fr/).  ```python  # Une ligne simple de commentaire commence par un dièse diff --git a/go.html.markdown b/go.html.markdown index a857a76c..dc684227 100644 --- a/go.html.markdown +++ b/go.html.markdown @@ -108,12 +108,13 @@ can include line breaks.` // Same string type.  	bs := []byte("a slice") // Type conversion syntax.  	// Because they are dynamic, slices can be appended to on-demand. -	// To append elements to a slice, built-in append() function is used. +	// To append elements to a slice, the built-in append() function is used.  	// First argument is a slice to which we are appending. Commonly,  	// the array variable is updated in place, as in example below.  	s := []int{1, 2, 3}		// Result is a slice of length 3.  	s = append(s, 4, 5, 6)	// Added 3 elements. Slice now has length of 6.  	fmt.Println(s) // Updated slice is now [1 2 3 4 5 6] +  	// To append another slice, instead of list of atomic elements we can  	// pass a reference to a slice or a slice literal like this, with a  	// trailing ellipsis, meaning take a slice and unpack its elements, diff --git a/haskell.html.markdown b/haskell.html.markdown index 369b1b20..08611e63 100644 --- a/haskell.html.markdown +++ b/haskell.html.markdown @@ -195,11 +195,11 @@ foo 5 -- 15  -- function composition  -- the (.) function chains functions together.  -- For example, here foo is a function that takes a value. It adds 10 to it, --- multiplies the result of that by 5, and then returns the final value. -foo = (*5) . (+10) +-- multiplies the result of that by 4, and then returns the final value. +foo = (*4) . (+10) --- (5 + 10) * 5 = 75 -foo 5 -- 75 +-- (5 + 10) * 4 = 60 +foo 5 -- 60  -- fixing precedence  -- Haskell has another operator called `$`. This operator applies a function  diff --git a/id-id/xml-id.html.markdown b/id-id/xml-id.html.markdown index c1e985aa..8b8d72ae 100644 --- a/id-id/xml-id.html.markdown +++ b/id-id/xml-id.html.markdown @@ -1,6 +1,6 @@  ---  language: xml -filename: learnxml.xml +filename: learnxml-id.xml  contributors:    - ["João Farias", "https://github.com/JoaoGFarias"]  translators: diff --git a/java.html.markdown b/java.html.markdown index 38c9e490..aae64ccf 100644 --- a/java.html.markdown +++ b/java.html.markdown @@ -450,6 +450,17 @@ class Bicycle {      protected int gear; // Protected: Accessible from the class and subclasses      String name; // default: Only accessible from within this package +    static String className; // Static class variable + +    // Static block  +    // Java has no implementation of static constructors, but +    // has a static block that can be used to initialize class variables  +    // (static variables).  +    // This block will be called when the class is loaded. +    static { +        className = "Bicycle"; +    } +      // Constructors are a way of creating classes      // This is a constructor      public Bicycle() { diff --git a/javascript.html.markdown b/javascript.html.markdown index a119be88..cce488e1 100644 --- a/javascript.html.markdown +++ b/javascript.html.markdown @@ -16,12 +16,8 @@ JavaScript isn't just limited to web browsers, though: Node.js, a project that  provides a standalone runtime for Google Chrome's V8 JavaScript engine, is  becoming more and more popular. -Feedback would be highly appreciated! You can reach me at -[@adambrenecki](https://twitter.com/adambrenecki), or -[adam@brenecki.id.au](mailto:adam@brenecki.id.au). -  ```js -// Comments are like C. Single-line comments start with two slashes, +// Comments are like C's. Single-line comments start with two slashes,  /* and multiline comments start with slash-star     and end with star-slash */ @@ -534,28 +530,32 @@ if (Object.create === undefined){ // don't overwrite it if it exists  ## Further Reading -The [Mozilla Developer -Network](https://developer.mozilla.org/en-US/docs/Web/JavaScript) provides -excellent documentation for JavaScript as it's used in browsers. Plus, it's a -wiki, so as you learn more you can help others out by sharing your own -knowledge. +The [Mozilla Developer Network][1] provides excellent documentation for +JavaScript as it's used in browsers. Plus, it's a wiki, so as you learn more you +can help others out by sharing your own knowledge. + +MDN's [A re-introduction to JavaScript][2] covers much of the concepts covered +here in more detail. This guide has quite deliberately only covered the +JavaScript language itself; if you want to learn more about how to use +JavaScript in web pages, start by learning about the [Document Object Model][3]. + +[Learn Javascript by Example and with Challenges][4] is a variant of this +reference with built-in challenges. -MDN's [A re-introduction to -JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/A_re-introduction_to_JavaScript) -covers much of the concepts covered here in more detail. This guide has quite -deliberately only covered the JavaScript language itself; if you want to learn -more about how to use JavaScript in web pages, start by learning about the -[Document Object -Model](https://developer.mozilla.org/en-US/docs/Using_the_W3C_DOM_Level_1_Core) +[JavaScript Garden][5] is an in-depth guide of all the counter-intuitive parts +of the language. -[Learn Javascript by Example and with Challenges](http://www.learneroo.com/modules/64/nodes/350) is a variant of this reference with built-in challenges. +[JavaScript: The Definitive Guide][6] is a classic guide and reference book. -[JavaScript Garden](http://bonsaiden.github.io/JavaScript-Garden/) is an in-depth -guide of all the counter-intuitive parts of the language. +In addition to direct contributors to this article, some content is adapted from +Louie Dinh's Python tutorial on this site, and the [JS Tutorial][7] on the +Mozilla Developer Network. -[JavaScript: The Definitive Guide](http://www.amazon.com/gp/product/0596805527/) is a classic guide / reference book. -In addition to direct contributors to this article, some content is adapted -from Louie Dinh's Python tutorial on this site, and the [JS -Tutorial](https://developer.mozilla.org/en-US/docs/Web/JavaScript/A_re-introduction_to_JavaScript) -on the Mozilla Developer Network. +[1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript +[2]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/A_re-introduction_to_JavaScript +[3]: https://developer.mozilla.org/en-US/docs/Using_the_W3C_DOM_Level_1_Core +[4]: http://www.learneroo.com/modules/64/nodes/350 +[5]: http://bonsaiden.github.io/JavaScript-Garden/ +[6]: http://www.amazon.com/gp/product/0596805527/ +[7]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/A_re-introduction_to_JavaScript diff --git a/latex.html.markdown b/latex.html.markdown index 9b7b4feb..31231a70 100644 --- a/latex.html.markdown +++ b/latex.html.markdown @@ -106,6 +106,9 @@ Here's how you state all y that belong to X, $\forall$ x $\in$ X. \\  % However, the math symbols only exist in math-mode.   % We can enter math-mode from text mode with the $ signs.  % The opposite also holds true. Variable can also be rendered in math-mode. +% We can also enter math mode with \[\] + +\[a^2 + b^2 = c^2 \]  My favorite Greek letter is $\xi$. I also like $\beta$, $\gamma$ and $\sigma$.  I haven't found a Greek letter that yet that LaTeX doesn't know about! diff --git a/lua.html.markdown b/lua.html.markdown index 0809215f..3d95c146 100644 --- a/lua.html.markdown +++ b/lua.html.markdown @@ -190,7 +190,7 @@ end  --------------------------------------------------------------------------------  -- A table can have a metatable that gives the table operator-overloadish --- behavior. Later we'll see how metatables support js-prototypey behavior. +-- behavior. Later we'll see how metatables support js-prototypey behaviour.  f1 = {a = 1, b = 2}  -- Represents the fraction a/b.  f2 = {a = 2, b = 3} diff --git a/ms-my/coffeescript-my.html.markdown b/ms-my/coffeescript-my.html.markdown new file mode 100644 index 00000000..9820a561 --- /dev/null +++ b/ms-my/coffeescript-my.html.markdown @@ -0,0 +1,105 @@ +--- +language: coffeescript +contributors: +  - ["Tenor Biel", "http://github.com/L8D"] +  - ["Xavier Yao", "http://github.com/xavieryao"] +filename: coffeescript-ms.coffee +translators: +    - ["hack1m", "https://github.com/hack1m"] +lang: ms-my +--- + +CoffeeScript adalah bahasa kecil yang menyusun/kompil satu-per-satu menjadi setara JavaScript, dan tidak ada interpretasi di runtime. +Sebagai salah satu pengganti kepada JavaScript, CoffeeScript mencuba yang terbaik untuk output kod JavaScript yang mudah dibaca, cantik-dicetak dan berfungsi lancar, yang mana berfungsi baik pada setiap runtime JavaScript. + +Lihat juga [Laman sesawang CoffeeScript](http://coffeescript.org/), yang mana ada tutorial lengkap untuk CoffeeScript. + +```coffeescript +# CoffeeScript adalah bahasa hipster. +# Ia beredar mengikut trend kebanyakkan bahasa moden. +# Jadi komen sama seperti Ruby dan Python, ia menggunakan simbol nombor. + +### +Blok komen seperti ini, dan ia terjemah terus ke '/ *'s dan '* /'s +untuk keputusan kod JavaScript. + +Sebelum meneruskan anda perlu faham kebanyakkan daripada +JavaScript adalah semantik. +### + +# Menetapkan: +number   = 42 #=> var number = 42; +opposite = true #=> var opposite = true; + +# Bersyarat: +number = -42 if opposite #=> if(opposite) { number = -42; } + +# Fungsi: +square = (x) -> x * x #=> var square = function(x) { return x * x; } + +fill = (container, liquid = "coffee") -> +  "Filling the #{container} with #{liquid}..." +#=>var fill; +# +#fill = function(container, liquid) { +#  if (liquid == null) { +#    liquid = "coffee"; +#  } +#  return "Filling the " + container + " with " + liquid + "..."; +#}; + +# Julat: +list = [1..5] #=> var list = [1, 2, 3, 4, 5]; + +# Objek: +math = +  root:   Math.sqrt +  square: square +  cube:   (x) -> x * square x +#=> var math = { +#    "root": Math.sqrt, +#    "square": square, +#    "cube": function(x) { return x * square(x); } +#   }; + +# Splats: +race = (winner, runners...) -> +  print winner, runners +#=>race = function() { +#    var runners, winner; +#    winner = arguments[0], runners = 2 <= arguments.length ? __slice.call(arguments, 1) : []; +#    return print(winner, runners); +#  }; + +# Kewujudan: +alert "I knew it!" if elvis? +#=> if(typeof elvis !== "undefined" && elvis !== null) { alert("I knew it!"); } + +# Pemahaman array: +cubes = (math.cube num for num in list) +#=>cubes = (function() { +#	  var _i, _len, _results; +#	  _results = []; +# 	for (_i = 0, _len = list.length; _i < _len; _i++) { +#		  num = list[_i]; +#		  _results.push(math.cube(num)); +#	  } +#	  return _results; +# })(); + +foods = ['broccoli', 'spinach', 'chocolate'] +eat food for food in foods when food isnt 'chocolate' +#=>foods = ['broccoli', 'spinach', 'chocolate']; +# +#for (_k = 0, _len2 = foods.length; _k < _len2; _k++) { +#  food = foods[_k]; +#  if (food !== 'chocolate') { +#    eat(food); +#  } +#} +``` + +## Sumber tambahan + +- [Smooth CoffeeScript](http://autotelicum.github.io/Smooth-CoffeeScript/) +- [CoffeeScript Ristretto](https://leanpub.com/coffeescript-ristretto/read) diff --git a/php.html.markdown b/php.html.markdown index cf9544b3..0504ced2 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -733,7 +733,7 @@ $cls = new SomeOtherNamespace\MyClass();  /**********************  * Late Static Binding  * -* / +*/  class ParentClass {      public static function who() { diff --git a/r.html.markdown b/r.html.markdown index 8896c5b0..8539b10e 100644 --- a/r.html.markdown +++ b/r.html.markdown @@ -3,6 +3,7 @@ language: R  contributors:      - ["e99n09", "http://github.com/e99n09"]      - ["isomorphismes", "http://twitter.com/isomorphisms"] +    - ["kalinn", "http://github.com/kalinn"]  filename: learnr.r  --- @@ -197,6 +198,14 @@ class(NaN) # "numeric"  # You can do arithmetic on two vectors with length greater than 1,  # so long as the larger vector's length is an integer multiple of the smaller  c(1,2,3) + c(1,2,3) # 2 4 6 +# Since a single number is a vector of length one, scalars are applied  +# elementwise to vectors +(4 * c(1,2,3) - 2) / 2 # 1 3 5 +# Except for scalars, use caution when performing arithmetic on vectors with  +# different lengths. Although it can be done,  +c(1,2,3,1,2,3) * c(1,2) # 1 4 3 2 2 6 +# Matching lengths is better practice and easier to read +c(1,2,3,1,2,3) * c(1,2,1,2,1,2)   # CHARACTERS  # There's no difference between strings and characters in R @@ -235,6 +244,9 @@ class(NA)	# "logical"  TRUE | FALSE	# TRUE  # AND  TRUE & FALSE	# FALSE +# Applying | and & to vectors returns elementwise logic operations +c(TRUE,FALSE,FALSE) | c(FALSE,TRUE,FALSE) # TRUE TRUE FALSE +c(TRUE,FALSE,TRUE) & c(FALSE,TRUE,TRUE) # FALSE FALSE TRUE  # You can test if x is TRUE  isTRUE(TRUE)	# TRUE  # Here we get a logical vector with many elements: @@ -665,15 +677,101 @@ write.csv(pets, "pets2.csv") # to make a new .csv file  ######################### +# Statistical Analysis +######################### + +# Linear regression! +linearModel <- lm(price  ~ time, data = list1) +linearModel # outputs result of regression +# => +# Call: +# lm(formula = price ~ time, data = list1) +#  +# Coefficients: +# (Intercept)         time   +#      0.1453       0.4943   +summary(linearModel) # more verbose output from the regression +# => +# Call: +# lm(formula = price ~ time, data = list1) +# +# Residuals: +#     Min      1Q  Median      3Q     Max  +# -8.3134 -3.0131 -0.3606  2.8016 10.3992  +# +# Coefficients: +#             Estimate Std. Error t value Pr(>|t|)     +# (Intercept)  0.14527    1.50084   0.097    0.923     +# time         0.49435    0.06379   7.749 2.44e-09 *** +# --- +# Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 +# +# Residual standard error: 4.657 on 38 degrees of freedom +# Multiple R-squared:  0.6124,	Adjusted R-squared:  0.6022  +# F-statistic: 60.05 on 1 and 38 DF,  p-value: 2.44e-09 +coef(linearModel) # extract estimated parameters +# => +# (Intercept)        time  +#   0.1452662   0.4943490  +summary(linearModel)$coefficients # another way to extract results +# => +#              Estimate Std. Error    t value     Pr(>|t|) +# (Intercept) 0.1452662 1.50084246 0.09678975 9.234021e-01 +# time        0.4943490 0.06379348 7.74920901 2.440008e-09 +summary(linearModel)$coefficients[,4] # the p-values  +# => +#  (Intercept)         time  +# 9.234021e-01 2.440008e-09  + +# GENERAL LINEAR MODELS +# Logistic regression +set.seed(1) +list1$success = rbinom(length(list1$time), 1, .5) # random binary +glModel <- glm(success  ~ time, data = list1,  +	family=binomial(link="logit")) +glModel # outputs result of logistic regression +# => +# Call:  glm(formula = success ~ time,  +#	family = binomial(link = "logit"), data = list1) +# +# Coefficients: +# (Intercept)         time   +#     0.17018     -0.01321   +#  +# Degrees of Freedom: 39 Total (i.e. Null);  38 Residual +# Null Deviance:	    55.35  +# Residual Deviance: 55.12 	 AIC: 59.12 +summary(glModel) # more verbose output from the regression +# => +# Call: +# glm(formula = success ~ time,  +#	family = binomial(link = "logit"), data = list1) + +# Deviance Residuals:  +#    Min      1Q  Median      3Q     Max   +# -1.245  -1.118  -1.035   1.202   1.327   +#  +# Coefficients: +#             Estimate Std. Error z value Pr(>|z|) +# (Intercept)  0.17018    0.64621   0.263    0.792 +# time        -0.01321    0.02757  -0.479    0.632 +#  +# (Dispersion parameter for binomial family taken to be 1) +# +#     Null deviance: 55.352  on 39  degrees of freedom +# Residual deviance: 55.121  on 38  degrees of freedom +# AIC: 59.121 +#  +# Number of Fisher Scoring iterations: 3 + + +#########################  # Plots  #########################  # BUILT-IN PLOTTING FUNCTIONS  # Scatterplots!  plot(list1$time, list1$price, main = "fake data") -# Regressions! -linearModel <- lm(price  ~ time, data = list1) -linearModel # outputs result of regression  # Plot regression line on existing plot  abline(linearModel, col = "red")  # Get a variety of nice diagnostics diff --git a/scala.html.markdown b/scala.html.markdown index 7f545196..192e03d7 100644 --- a/scala.html.markdown +++ b/scala.html.markdown @@ -278,21 +278,21 @@ val text = if (x == 10) "yeah" else "nope"  /////////////////////////////////////////////////  val a = Array(1, 2, 3, 5, 8, 13) -a(0) -a(3) +a(0)     // Int = 1 +a(3)     // Int = 5  a(21)    // Throws an exception  val m = Map("fork" -> "tenedor", "spoon" -> "cuchara", "knife" -> "cuchillo") -m("fork") -m("spoon") +m("fork")         // java.lang.String = tenedor +m("spoon")        // java.lang.String = cuchara  m("bottle")       // Throws an exception  val safeM = m.withDefaultValue("no lo se") -safeM("bottle") +safeM("bottle")   // java.lang.String = no lo se  val s = Set(1, 3, 7) -s(0) -s(1) +s(0)      // Boolean = false +s(1)      // Boolean = true  /* Look up the documentation of map here -   * http://www.scala-lang.org/api/current/index.html#scala.collection.immutable.Map @@ -313,15 +313,16 @@ s(1)  // Why have this?  val divideInts = (x: Int, y: Int) => (x / y, x % y) -divideInts(10, 3) // The function divideInts gives you the result and the remainder +// The function divideInts gives you the result and the remainder +divideInts(10, 3)    // (Int, Int) = (3,1)  // To access the elements of a tuple, use _._n where n is the 1-based index of  // the element -val d = divideInts(10, 3) +val d = divideInts(10, 3)    // (Int, Int) = (3,1) -d._1 +d._1    // Int = 3 -d._2 +d._2    // Int = 1  ///////////////////////////////////////////////// | 
