summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--fr-fr/make-fr.html.markdown268
-rw-r--r--id-id/xml-id.html.markdown79
-rw-r--r--inform7.html.markdown195
-rw-r--r--pt-br/javascript-pt.html.markdown6
-rw-r--r--swift.html.markdown2
-rw-r--r--zh-cn/lua-cn.html.markdown31
6 files changed, 562 insertions, 19 deletions
diff --git a/fr-fr/make-fr.html.markdown b/fr-fr/make-fr.html.markdown
new file mode 100644
index 00000000..5a1e03e7
--- /dev/null
+++ b/fr-fr/make-fr.html.markdown
@@ -0,0 +1,268 @@
+---
+language: make
+contributors:
+ - ["Robert Steed", "https://github.com/robochat"]
+translators:
+ - ["altaris", "https://github.com/altaris"]
+filename: Makefile-fr
+lang: fr-fr
+---
+
+Un makefile est un fichier qui définit un ensemble de règles liées entre elles
+pour créer une ou plusieurs cibles. L'idée est d'effectuer le moins de travail
+possible afin de mettre à jour la ou les cibles en fonction des dépendances.
+
+Écrit en un week-end par Stuart Feldman en 1976, le make et les
+makefiles sont encore très utilisés (principalement dans les systèmes Unix),
+malgré la concurrence et les critiques faites à son égard.
+
+Le programme make a plusieurs variantes. Dans ce tutoriel, nous utiliserons
+l'implémentation standard : GNU make.
+
+```make
+
+# Ceci est un commentaire.
+
+# Un makefile devrait être nommé "Makefile" (avec ou sans la
+# majuscule). Il peut alors être exécuté par `make <cible>`.
+# Ce nommage n'est toutefois pas obligatoire : utiliser
+# `make -f "fichier" <cible>`.
+
+# ATTENTION : l'indentation est quant à elle obligatoire, et se fait avec des
+# tabulations, pas avec des espaces !
+
+#-----------------------------------------------------------------------
+# Les basiques
+#-----------------------------------------------------------------------
+
+# Une règle. Elle ne sera exécutée que si fichier0.txt n'existe pas.
+fichier0.txt:
+ echo "truc" > fichier0.txt
+ # Même les commentaires sont transférés dans le terminal.
+
+# Cette règle ne sera exécutée que si fichier0.txt est plus récent que
+# fichier1.txt.
+fichier1.txt: fichier0.txt
+ cat fichier0.txt > fichier1.txt
+ # Utiliser la même syntaxe que dans un terminal.
+ @cat fichier0.txt >> fichier1.txt
+ # @ empêche l'affichage de la sortie texte d'une commande.
+ -@echo 'hello'
+ # - signifie que la règle devrait continuer à s'exécuter si cette commande
+ # échoue.
+
+# Une règle peut avoir plusieurs cibles et plusieurs dépendances.
+fichier2.txt fichier3.txt: fichier0.txt fichier1.txt
+ touch fichier2.txt
+ touch fichier3.txt
+
+# Make affichera un avertissement si le makefile comporte plusieurs règles pour
+# une même cible. Cependant les règles vides ne comptent pas, et peuvent être
+# utilisées pour ajouter des dépendances plus facilement.
+
+#-----------------------------------------------------------------------
+# Fausses règles
+#-----------------------------------------------------------------------
+
+# Une fausse règle est une règle qui ne correspond pas à un fichier.
+# Par définition, elle ne peut pas être à jour, et donc make l’exécutera à
+# chaque demande.
+all: maker process
+
+# La déclaration des règles peut être faite dans n'importe quel ordre.
+maker:
+ touch ex0.txt ex1.txt
+
+# On peut transformer une règle en fausse règle grâce à la cible spéciale
+# suivante :
+.PHONY: all maker process
+
+# Une règle dépendante d'une fausse règle sera toujours exécutée.
+ex0.txt ex1.txt: maker
+
+# Voici quelques exemples fréquents de fausses règles : all, make, clean,
+# install...
+
+#-----------------------------------------------------------------------
+# Variables automatiques et wildcards
+#-----------------------------------------------------------------------
+
+# Utilise un wildcard pour des noms de fichier
+process: fichier*.txt
+ @echo $^ # $^ est une variable contenant la liste des dépendances de la
+ # cible actuelle.
+ @echo $@ # $@ est le nom de la cible actuelle. En cas de cibles
+ # multiples, $@ est le nom de la cible ayant causé l'exécution
+ # de cette règle.
+ @echo $< # $< contient la première dépendance.
+ @echo $? # $? contient la liste des dépendances qui ne sont pas à jour.
+ @echo $+ # $+ contient la liste des dépendances avec d'éventuels
+ # duplicatas, contrairement à $^.
+ @echo $| # $| contient la liste des cibles ayant préséance sur la cible
+ # actuelle.
+
+# Même si la définition de la règle est scindée en plusieurs morceaux, $^
+# listera toutes les dépendances indiquées.
+process: ex1.txt fichier0.txt
+# Ici, fichier0.txt est un duplicata dans $+.
+
+#-----------------------------------------------------------------------
+# Pattern matching
+#-----------------------------------------------------------------------
+
+# En utilisant le pattern matching, on peut par exemple créer des règles pour
+# convertir les fichiers d'un certain format dans un autre.
+%.png: %.svg
+ inkscape --export-png $^
+
+# Make exécute une règle même si le fichier correspondant est situé dans un sous
+# dossier. En cas de conflit, la règle avec la meilleure correspondance est
+# choisie.
+small/%.png: %.svg
+ inkscape --export-png --export-dpi 30 $^
+
+# Dans ce type de conflit (même cible, même dépendances), make exécutera la
+# dernière règle déclarée...
+%.png: %.svg
+ @echo cette règle est choisie
+
+# Dans ce type de conflit (même cible mais pas les mêmes dépendances), make
+# exécutera la première règle pouvant être exécutée.
+%.png: %.ps
+ @echo cette règle n\'est pas choisie si *.svg et *.ps sont présents
+
+# Make a des règles pré établies. Par exemple, il sait comment créer la cible
+# *.o à partir de *.c.
+
+# Les makefiles plus vieux utilisent un matching par extension de fichier.
+.png.ps:
+ @echo cette règle est similaire à une règle par pattern matching
+
+# Utiliser cette règle spéciale pour déclarer une règle comme ayant un
+# matching par extension de fichier.
+.SUFFIXES: .png
+
+#-----------------------------------------------------------------------
+# Variables, ou macros
+#-----------------------------------------------------------------------
+
+# Les variables sont des chaînes de caractères.
+
+variable = Ted
+variable2="Sarah"
+
+echo:
+ @echo $(variable)
+ @echo ${variable2}
+ @echo $variable # Cette syntaxe signifie $(n)ame et non pas $(variable) !
+ @echo $(variable3) # Les variables non déclarées valent "" (chaîne vide).
+
+# Les variables sont déclarées de 4 manières, de la plus grande priorité à la
+# plus faible :
+# 1 : dans la ligne de commande qui invoque make,
+# 2 : dans le makefile,
+# 3 : dans les variables d’environnement du terminal qui invoque make,
+# 4 : les variables prédéfinies.
+
+# Assigne la variable si une variable d’environnement du même nom n'existe pas
+# déjà.
+variable4 ?= Jean
+
+# Empêche cette variable d'être modifiée par la ligne de commande.
+override variable5 = David
+
+# Concatène à une variable (avec un espace avant).
+variable4 +=gris
+
+# Assignations de variable pour les règles correspondant à un pattern
+# (spécifique à GNU make).
+*.png: variable2 = Sara # Pour toutes les règles correspondant à *.png, et tous
+ # leurs descendants, la variable variable2 vaudra
+ # "Sara".
+# Si le jeux des dépendances et descendances devient vraiment trop compliqué,
+# des incohérences peuvent survenir.
+
+# Certaines variables sont prédéfinies par make :
+affiche_predefinies:
+ echo $(CC)
+ echo ${CXX}
+ echo $(FC)
+ echo ${CFLAGS}
+ echo $(CPPFLAGS)
+ echo ${CXXFLAGS}
+ echo $(LDFLAGS)
+ echo ${LDLIBS}
+
+#-----------------------------------------------------------------------
+# Variables : le retour
+#-----------------------------------------------------------------------
+
+# Les variables sont évaluées à chaque instance, ce qui peut être coûteux en
+# calculs. Pour parer à ce problème, il existe dans GNU make une seconde
+# manière d'assigner des variables pour qu'elles ne soient évaluées qu'une seule
+# fois seulement.
+
+var := A B C
+var2 ::= $(var) D E F # := et ::= sont équivalents.
+
+# Ces variables sont évaluées procéduralement (i.e. dans leur ordre
+# d'apparition), contrairement aux règles par exemple !
+
+# Ceci ne fonctionne pas.
+var3 ::= $(var4) et fais de beaux rêves
+var4 ::= bonne nuit
+
+#-----------------------------------------------------------------------
+# Fonctions
+#-----------------------------------------------------------------------
+
+# Make a une multitude de fonctions. La syntaxe générale est
+# $(fonction arg0,arg1,arg2...).
+
+# Quelques exemples :
+
+fichiers_source = $(wildcard *.c */*.c)
+fichiers_objet = $(patsubst %.c,%.o,$(fichiers_source))
+
+ls: * src/*
+ @echo $(filter %.txt, $^)
+ @echo $(notdir $^)
+ @echo $(join $(dir $^),$(notdir $^))
+
+#-----------------------------------------------------------------------
+# Directives
+#-----------------------------------------------------------------------
+
+# Inclut d'autres makefiles.
+include meuh.mk
+
+# Branchements conditionnels.
+sport = tennis
+report:
+ifeq ($(sport),tennis) # Il y a aussi ifneq.
+ @echo 'jeu, set et match'
+else
+ @echo "C'est pas ici Wimbledon ?"
+endif
+
+truc = true
+ifdef $(truc) # Il y a aussi ifndef.
+ machin = 'salut'
+endif
+```
+
+## Quelques références
+
+### En français
+
++ [Introduction à Makefile (developpez.com)]
+(http://gl.developpez.com/tutoriel/outil/makefile/),
++ [Compilez sous GNU/Linux ! (openclassrooms)]
+(https://openclassrooms.com/courses/compilez-sous-gnu-linux).
+
+### En anglais
+
++ [Documentation de GNU make](https://www.gnu.org/software/make/manual/),
++ [Software carpentry tutorial](http://swcarpentry.github.io/make-novice/),
++ Learn C the hard way [ex2](http://c.learncodethehardway.org/book/ex2.html)
+[ex28](http://c.learncodethehardway.org/book/ex28.html).
diff --git a/id-id/xml-id.html.markdown b/id-id/xml-id.html.markdown
index 8b8d72ae..fedba711 100644
--- a/id-id/xml-id.html.markdown
+++ b/id-id/xml-id.html.markdown
@@ -5,19 +5,76 @@ contributors:
- ["João Farias", "https://github.com/JoaoGFarias"]
translators:
- ["Rizky Luthfianto", "https://github.com/rilut"]
+ - ["Ahmad Zafrullah", "https://github.com/23Pstars"]
lang: id-id
---
-XML adalah bahasa markup yang dirancang untuk menyimpan dan mengirim data.
+XML adalah bahasa markup yang dirancang untuk menyimpan dan mengirim data. XML mudah dibaca oleh manusia dan mesin.
Tidak seperti HTML, XML tidak menentukan bagaimana menampilkan atau format data, hanya membawanya.
-* Sintaks XML
+Terdapat perbedaan antara **konten** dan **markup**. Singkatnya, konten dapat berupa apapun dan markup adalah sebagai penentu.
+
+## Definisi dan Pendahuluan
+
+Dokumen XML pada dasarnya disusun oleh *elemen* yang dapat memiliki *atribut* untuk menjelaskan elemen tersebut dan dapat memiliki beberapa konten tekstual atau beberapa elemen sebagai anak-nya. Setiap dokumen XML hendaknya memiliki satu elemen akar, yang menjadi induk dari semua elemen dalam dokumen XML.
+
+Pengurai XML dirancang menjadi sangat ketat, dan akan berhenti melakukan penguraian terhadap dokumen yang cacat. Oleh karena itu semua dokumen XML harus mengikuti [Aturan Sintaks XML](http://www.w3schools.com/xml/xml_syntax.asp).
```xml
-<!-- Komentar di XML seperti ini -->
+<!-- Ini adalah komentar. Komentar harus memiliki dua tanda penghubung secara berurutan (-). -->
+<!-- Komentar dapat renggang
+ menjadi banyak baris -->
+
+<!-- Elemen -->
+<!-- Elemen merupakan komponen dasar dari XML. Ada dua tipe dari elemen, kosong: -->
+<elemen1 atribut="nilai" /> <!-- Elemen kosong tidak memiliki konten apapun -->
+<!-- dan tidak-kosong: -->
+<elemen2 atribut="nilai">Konten</elemen2>
+<!-- Nama elemen hanya dapat berupa huruf dan angka saja. -->
+
+<kosong /> <!-- Elemen yang terdiri dari tag elemen kosong… -->
+<!-- …tidak memiliki content apapun dan murni markup. -->
+
+<tidakkosong> <!-- Atau, elemen ini memiliki tag pembuka… -->
+ <!-- …suatu konten… -->
+</tidakkosong> <!-- dan sebuah tag penutup. -->
+
+<!-- Nama elemen merupakan *case sensitive*. -->
+<elemen />
+<!-- …tidak sama dengan elemen sebelumnya -->
+<eLEMEN />
+
+<!-- Atribut -->
+<!-- Sebuah atribut merupakan hubungan kunci-nilai yang terdapat pada elemen. -->
+<elemen atribut="nilai" lainnya="nilaiLainnya" banyakNilai="daftar nilai ber-spasi" />
+<!-- Sebuah atribut digunakan hanya sekali dalam sebuah elemen. Dan hanya memiliki satu nilai.
+ Salah satu solusi untuk mengatasi permasalahan tersebut adalah dengan menggunakan daftar nilai ber-spasi. -->
+
+<!-- Elemen bersarang -->
+<!-- Konten dari sebuah elemen dapat berupa elemen lainnya:: -->
+<ayah>
+ <anak>Teks</anak>
+ <oranglain />
+</ayah>
+<!-- Mengikuti standar tatanan pohon. Setiap elemen disebut *node*.
+ Induk yang berada satu tingkat diatasnya disebut *parent*, keturunan yang berada satu tingkat dibawahnya disebut *children*.
+ Elemen yang berada pada *parent* yang sama disebut Saudara (*siblings*). -->
+
+<!-- XML mempertahankan spasi. -->
+<anak>
+ Teks
+</anak>
+<!-- …tidak sama dengan -->
+<anak>Teks</anak>
+```
+
+
+## Dokumen XML
+```xml
<?xml version="1.0" encoding="UTF-8"?>
+<!-- XML prolog, boleh tidak digunakan namun direkomendasikan untuk digunakan. -->
<tokobuku>
<buku category="MEMASAK">
<judul lang="en">Everyday Italian</judul>
@@ -65,7 +122,7 @@ Tidak seperti HTML, XML tidak menentukan bagaimana menampilkan atau format data,
```
-* Dokumen yang well-formated & Validasi
+## Dokumen yang well-formated & Validasi
Sebuah dokumen XML disebut well-formated jika sintaksisnya benar.
Namun, juga mungkin untuk mendefinisikan lebih banyak batasan dalam dokumen,
@@ -128,3 +185,17 @@ Dengan alat ini, Anda dapat memeriksa data XML di luar logika aplikasi.
</buku>
</tokobuku>
```
+## Kompatibilitas DTD dan Definisi Skema XML
+
+Dukungan untuk DTD dapat ditemukan dimana-mana karena sudah sangat lama. Namun sayangnya, fitur XML terkini seperti *namespaces* tidak didukung oleh DTD. XML Xchema Definitions (XSDs) bertujuan untuk mengganti DTD dalam mendefinisikan tatabahasa dokumen XML.
+
+## Sumber
+
+* [Validasi dokumen XML](http://www.xmlvalidation.com)
+
+## Bacaan lainnya
+
+* [XML Schema Definitions Tutorial](http://www.w3schools.com/schema/)
+* [DTD Tutorial](http://www.w3schools.com/xml/xml_dtd_intro.asp)
+* [XML Tutorial](http://www.w3schools.com/xml/default.asp)
+* [Using XPath queries to parse XML](http://www.w3schools.com/xml/xml_xpath.asp)
diff --git a/inform7.html.markdown b/inform7.html.markdown
new file mode 100644
index 00000000..7f1da0e0
--- /dev/null
+++ b/inform7.html.markdown
@@ -0,0 +1,195 @@
+---
+language: Inform7
+contributors:
+ - ["Hyphz", "http://github.com/hyphz/"]
+filename: LearnInform.Inform
+---
+Inform 7 is a natural language based language created by Graham Nelson and Emily Short for writing text adventures, but also potentially usable for other text based applications, especially data backed ones.
+
+```
+"LearnInform" by Hyphz
+
+[This is a comment.]
+
+[Inform 7 is a language designed for building text adventures.
+It can be used for other purposes too, although the default
+library builds a text adventure. Inform 7 is object oriented.]
+
+[This creates a class by subclassing. "Value" is the universal subclass,
+but "object" is the most basic that behaves like an OO object.]
+A datablock is a kind of object.
+
+[Classes can have properties.]
+A datablock can be broken. [This creates a boolean property.]
+A datablock is usually not broken. [This sets its default value.]
+A datablock can be big or small. [This creates an enumerated property.]
+A datablock is usually small. [This sets its default value.]
+A datablock has a number called the sequence number. [This creates a typed property.]
+A datablock has some text called the name. ["Some text" means a string.]
+A datablock has a datablock called the chain. [Declared classes become types.]
+
+[This creates a global named instance.]
+Block1 is a datablock.
+The sequence number of Block1 is 1.
+The name of Block1 is "Block One."
+
+[Functions and procedures are defined as "phrases".]
+To do the thing everyone does with their first program:
+ say "Hello World.". [Full stop indicates the end, indent indicates the scope.]
+
+To dump (the block - a datablock): [That's how we create a parameter.]
+ say the sequence number of the block;
+ say the name of the block;
+ if the block is broken, say "(Broken)".
+
+To toggle (the block - a datablock):
+ if the block is broken: [Conditional.]
+ now the block is not broken; [Updating a property.]
+ else:
+ now the block is broken.
+
+[Multiple parameters.]
+To fix (the broken block - a datablock) using (the repair block - a datablock):
+ if the broken block is not broken, stop; [Comma for a non indented single command.]
+ if the repair block is broken, stop;
+ now the sequence number of the broken block is the sequence number of the repair block;
+ now the broken block is not broken.
+
+[Because of its text adventure origins, Inform 7 doesn't generally allow objects
+to be created dynamically, although there's a language extension that enables it.]
+Block2 is a datablock.
+Block2 is broken.
+The sequence number of Block2 is 2.
+The name of Block2 is "Block two."
+
+To demonstrate calling a phrase with two parameters:
+ Let the second block be block2; [Local pointer variable.]
+ fix the second block using Block1;
+ say the sequence number of the second block. [1.]
+
+[Lists.]
+To show how to use list types:
+ let the list be a list of datablocks;
+ add Block1 to the list;
+ add Block2 to the list;
+ say the list; ["Block1 and Block2"]
+ [Membership.]
+ if Block1 is listed in the list:
+ say "Block1 is there.";
+ [Loop.]
+ repeat with the block running through the list:
+ dump the block; [1 Block One. 1 Block Two.]
+ [Remember block two's sequence number was changed above.]
+ let X be entry 2 of the list; [Counting starts at 1.]
+ dump X; ["1 Block two."]
+ remove X from the list;
+ say the list. [Block1]
+
+[Here's how we define a function and do arithmetic.]
+
+To decide which number is the sum of all numbers up to (X - a number) (this is summing up):
+ let the total so far be a number;
+ repeat with the current number running from 1 to X:
+ now the total so far is the total so far + the current number;
+ decide on the total so far. [This is the return statement.]
+
+[ We have higher order functions too. ]
+
+To demonstrate a higher order function:
+ say summing up applied to {1, 2, 3, 4}.
+
+To decide which number is the result of applying (phrase - phrase A -> A) twice to (B - a value of kind A):
+ let b1 be phrase applied to B;
+ let b2 be phrase applied to b1;
+ decide on b2.
+
+To demonstrate defining a higher order function:
+ let X be 5;
+ say the result of applying summing up twice to X.
+
+[ Rulebooks allow a number of functions which apply to the same type under different conditions to be stacked. ]
+
+Datablock validation rules is a datablock based rulebook.
+
+A datablock validation rule for a broken datablock: rule fails.
+A datablock validation rule for a datablock (called the block):
+ dump the block;
+ rule succeeds.
+
+To demonstrate invoking a rulebook:
+ follow datablock validation rules for Block1;
+ follow datablock validation rules for Block2.
+
+[ Objects can also have relations, which resemble those in a relational database. ]
+A dog is a kind of thing.
+Rover is a dog.
+The kennel is a container. [This is a built in base class.]
+Rover is in the kennel. [This creates an inbuilt relation called "containment".]
+
+[We can create relations by declaring their type.]
+
+Guide dog ownership relates one dog to one person. [One-to-one.]
+Property ownership relates various things to one person. [Many-to-one.]
+Friendship relates various people to various people. [Many-to-many.]
+
+[To actually use them we must assign verbs or prepositions to them.]
+
+The verb to own means the property ownership relation.
+The verb to be the guide dog of means the guide dog ownership relation.
+The verb to be guided by means the reversed guide dog ownership relation.
+The verb to be friends with means the friendship relation.
+
+Edward is a person. A person can be blind. Edward is blind.
+Edward is guided by Rover.
+Benny is a person. Edward is friends with Benny.
+
+To demonstrate looking something up with a relation:
+ repeat with the dog running through things that are the guide dog of Edward:
+ say the dog;
+ repeat with the friend running through things that are friends with Edward:
+ say the friend.
+
+[We can also define relations that exist procedurally.]
+
+Helpfulness relates a person (called the helper) to a person (called the helpee) when the helpee is blind and the helper is not blind.
+The verb to be helpful to means the helpfulness relation.
+To demonstrate using a procedural relation:
+ repeat with the helper running through people that are helpful to Edward:
+ say the helper.
+
+
+[ Interface to the text adventure harness to allow the above code to be run. ]
+Tutorial room is a room.
+"A rather strange room full of buttons. Push them to run the exercises, or turn on the robot to run them all."
+A button is a kind of thing. A button is fixed in place.
+
+The red button is a button in tutorial room.
+Instead of pushing the red button, do the thing everyone does with their first program.
+The green button is a button in tutorial room.
+Instead of pushing the green button, demonstrate calling a phrase with two parameters.
+The blue button is a button in tutorial room.
+Instead of pushing the blue button, show how to use list types.
+The cyan button is a button in tutorial room.
+Instead of pushing the cyan button, say the sum of all numbers up to 5.
+The purple button is a button in tutorial room.
+Instead of pushing the purple button, demonstrate a higher order function.
+The black button is a button in tutorial room.
+Instead of pushing the black button, demonstrate defining a higher order function.
+The white button is a button in tutorial room.
+Instead of pushing the white button, demonstrate invoking a rulebook.
+The puce button is a button in tutorial room.
+Instead of pushing the puce button, demonstrate looking something up with a relation.
+The orange button is a button in tutorial room.
+Instead of pushing the orange button, demonstrate using a procedural relation.
+
+The robot is an object in tutorial room.
+Instead of switching on the robot:
+ say "The robot begins to frantically flail its arms about.";
+ repeat with button running through buttons in the tutorial room:
+ say "The robot randomly hits [the button].";
+ try pushing button.
+```
+
+##Ready For More?
+
+* [Inform 7](http://www.inform7.com/)
diff --git a/pt-br/javascript-pt.html.markdown b/pt-br/javascript-pt.html.markdown
index 6424214e..59c6890e 100644
--- a/pt-br/javascript-pt.html.markdown
+++ b/pt-br/javascript-pt.html.markdown
@@ -519,13 +519,13 @@ if (Object.create === undefined){ // Não o sobrescreve se já existir
## Leitura Adicional
O [Mozilla Developer
-Network](https://developer.mozilla.org/en-US/docs/Web/JavaScript) dispõe de uma
+Network](https://developer.mozilla.org/pt-BR/docs/Web/JavaScript) dispõe de uma
excelente documentação sobre Javascript e seu uso nos browsers. E mais,
é uma wiki, portanto conforme você vai aprendendo, mais você pode ir ajudando
os outros compartilhando do seu conhecimento.
[Uma re-introdução do JavaScript pela MDN]
-(https://developer.mozilla.org/en-US/docs/Web/JavaScript/A_re-introduction_to_JavaScript)
+(https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/A_re-introduction_to_JavaScript)
cobre muito dos conceitos abordados aqui em mais detalhes. Este guia fala
somente sobre a linguagem JavaScript em si; se você quiser aprender mais
sobre e como usar o JavaScript em páginas na web, comece aprendendo sobre
@@ -542,5 +542,5 @@ profundo de todas as partes do JavaScript.
/ livro de referência.
Parte desse artigo foi adaptado do tutorial de Python do Louie Dinh que está
-nesse site e do [Tutorial de JS](https://developer.mozilla.org/en-US/docs/Web/JavaScript/A_re-introduction_to_JavaScript)
+nesse site e do [Tutorial de JS](https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/A_re-introduction_to_JavaScript)
da Mozilla Developer Network.
diff --git a/swift.html.markdown b/swift.html.markdown
index 46996526..46768375 100644
--- a/swift.html.markdown
+++ b/swift.html.markdown
@@ -392,7 +392,7 @@ testTryStuff()
public class Shape {
public func getArea() -> Int {
- return 0;
+ return 0
}
}
diff --git a/zh-cn/lua-cn.html.markdown b/zh-cn/lua-cn.html.markdown
index 098d0ab5..f7065445 100644
--- a/zh-cn/lua-cn.html.markdown
+++ b/zh-cn/lua-cn.html.markdown
@@ -91,10 +91,10 @@ until num == 0
-- 2. 函数。
----------------------------------------------------
-function fib(n)
- if n < 2 then return 1 end
- return fib(n - 2) + fib(n - 1)
-end
+function fib(n)
+ if n < 2 then return n end
+ return fib(n - 2) + fib(n - 1)
+end
-- 支持闭包及匿名函数:
function adder(x)
@@ -129,9 +129,11 @@ function f(x) return x * x end
f = function (x) return x * x end
-- 这些也是等价的:
-local function g(x) return math.sin(x) end
-local g; g = function (x) return math.sin(x) end
--- 'local g'使得g可以自引用。
+local function g(x) return math.sin(x) end
+local g; g = function (x) return math.sin(x) end
+-- 以上均因'local g',使得g可以自引用。
+local g = function(x) return math.sin(x) end
+-- 等价于 local function g(x)..., 但函数体中g不可自引用
-- 顺便提下,三角函数以弧度为单位。
@@ -210,7 +212,7 @@ f2 = {a = 2, b = 3}
metafraction = {}
function metafraction.__add(f1, f2)
- sum = {}
+ local sum = {}
sum.b = f1.b * f2.b
sum.a = f1.a * f2.b + f2.a * f1.b
return sum
@@ -273,7 +275,7 @@ eatenBy = myFavs.animal -- 可以工作!感谢元表
Dog = {} -- 1.
function Dog:new() -- 2.
- newObj = {sound = 'woof'} -- 3.
+ local newObj = {sound = 'woof'} -- 3.
self.__index = self -- 4.
return setmetatable(newObj, self) -- 5.
end
@@ -307,7 +309,7 @@ mrDog:makeSound() -- 'I say woof' -- 8.
LoudDog = Dog:new() -- 1.
function LoudDog:makeSound()
- s = self.sound .. ' ' -- 2.
+ local s = self.sound .. ' ' -- 2.
print(s .. s .. s)
end
@@ -328,7 +330,7 @@ seymour:makeSound() -- 'woof woof woof' -- 4.
-- 如果有必要,子类也可以有new(),与基类相似:
function LoudDog:new()
- newObj = {}
+ local newObj = {}
-- 初始化newObj
self.__index = self
return setmetatable(newObj, self)
@@ -340,7 +342,9 @@ end
--[[ 我把这部分给注释了,这样脚本剩下的部分可以运行
+```
+```lua
-- 假设文件mod.lua的内容类似这样:
local M = {}
@@ -411,4 +415,9 @@ lua-users.org上的[Lua简明参考](http://lua-users.org/files/wiki_insecure/us
* <a href="http://lua-users.org/wiki/IoLibraryTutorial">io library</a>
* <a href="http://lua-users.org/wiki/OsLibraryTutorial">os library</a>
+顺便说一下,整个文件是可运行的Lua;
+保存为 learn-cn.lua 用命令 `lua learn.lua` 启动吧!
+
+本文首次撰写于 [tylerneylon.com](http://tylerneylon.com) 同时也有 [github gist](https://gist.github.com/tylerneylon/5853042) 版.
+
使用Lua,欢乐常在!