mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-11-22 12:32:09 +03:00
Compare commits
11 Commits
ecd3ff7a8d
...
ee23630e77
Author | SHA1 | Date | |
---|---|---|---|
|
ee23630e77 | ||
|
3c1b4e752d | ||
|
be43ada53d | ||
|
33e459864c | ||
|
54fbf0a948 | ||
|
fa95b37b6f | ||
|
572827b39f | ||
|
5d0fe40db8 | ||
|
77e2233bf3 | ||
|
ccdb3504c9 | ||
|
addac71ee9 |
@ -3,7 +3,7 @@ category: framework
|
||||
framework: AngularJS
|
||||
contributors:
|
||||
- ["Walter Cordero", "http://waltercordero.com"]
|
||||
filename: learnangular.html
|
||||
filename: learnangular.txt
|
||||
---
|
||||
|
||||
## AngularJS Tutorial.
|
||||
|
@ -1,7 +1,7 @@
|
||||
---
|
||||
language: HTML
|
||||
lang: ar-ar
|
||||
filename: learnhtml-tf.html
|
||||
filename: learnhtml-tf.txt
|
||||
contributors:
|
||||
- ["Christophe THOMAS", "https://github.com/WinChris"]
|
||||
translators:
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
language: HTML
|
||||
filename: html-ca.md
|
||||
filename: html-ca.txt
|
||||
contributors:
|
||||
- ["Christophe THOMAS", "https://github.com/WinChris"]
|
||||
translators:
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
language: HQ9+
|
||||
filename: hq9+-de.html
|
||||
filename: hq9+-de.txt
|
||||
contributors:
|
||||
- ["Alexey Nazaroff", "https://github.com/rogaven"]
|
||||
translators:
|
||||
|
@ -4,7 +4,7 @@ contributors:
|
||||
- ["Christophe THOMAS", "https://github.com/WinChris"]
|
||||
translators:
|
||||
- ["Dennis Keller", "https://github.com/denniskeller"]
|
||||
filename: learnhtml-de.html
|
||||
filename: learnhtml-de.txt
|
||||
lang: de-de
|
||||
---
|
||||
|
||||
|
@ -6,7 +6,6 @@ contributors:
|
||||
- ["Divay Prakash", "https://github.com/divayprakash"]
|
||||
translators:
|
||||
- ["caminsha", "https://github.com/caminsha"]
|
||||
filename: processing-de.md
|
||||
lang: de-de
|
||||
---
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
category: framework
|
||||
filename: learnshutit-de.html
|
||||
filename: learnshutit-de.py
|
||||
framework: ShutIt
|
||||
contributors:
|
||||
- ["Ian Miell", "http://ian.meirionconsulting.tk"]
|
||||
|
@ -2,7 +2,7 @@
|
||||
language: CSS
|
||||
contributors:
|
||||
- ["Kostas Bariotis", "http://kostasbariotis.com"]
|
||||
filename: css-gr.html.markdown
|
||||
filename: css-gr.css
|
||||
lang: el-gr
|
||||
---
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
language: HTML
|
||||
filename: learnhtml-gr.html
|
||||
filename: learnhtml-gr.txt
|
||||
contributors:
|
||||
- ["Dimitri Kokkonis", "https://github.com/kokkonisd"]
|
||||
lang: el-gr
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
language: JSON
|
||||
filename: json-gr.html.markdown
|
||||
filename: json-gr.json
|
||||
contributors:
|
||||
- ["Anna Harren", "https://github.com/iirelu"]
|
||||
- ["Marco Scannadinari", "https://github.com/marcoms"]
|
||||
|
@ -4,7 +4,7 @@ contributors:
|
||||
- ["Joao Pedrosa", "https://github.com/jpedrosa/"]
|
||||
translators:
|
||||
- ["Jorge Antonio Atempa", "http://www.twitter.com/atempa09"]
|
||||
filename: dart-es.md
|
||||
filename: dart-es.dart
|
||||
lang: es-es
|
||||
---
|
||||
|
||||
|
@ -5,7 +5,7 @@ contributors:
|
||||
translators:
|
||||
- ["Jhoon Saravia", "https://github.com/jhoon"]
|
||||
lang: es-es
|
||||
filename: groovy-es.html
|
||||
filename: groovy-es.groovy
|
||||
---
|
||||
|
||||
Groovy - Un lenguaje dinámico para la plataforma Java. [Leer más aquí](http://www.groovy-lang.org/).
|
||||
|
@ -4,7 +4,7 @@ contributors:
|
||||
- ["Adit Bhargava", "http://adit.io"]
|
||||
translators:
|
||||
- ["Jorge Antonio Atempa", "http://www.twitter.com/atempa09"]
|
||||
filename: haskell-es.md
|
||||
filename: haskell-es.hs
|
||||
lang: es-es
|
||||
---
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
language: HQ9+
|
||||
filename: hq9+-es.html
|
||||
filename: hq9+-es.txt
|
||||
contributors:
|
||||
- ["Alexey Nazaroff", "https://github.com/rogaven"]
|
||||
translators:
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
language: HTML
|
||||
filename: learnhtml-es.html
|
||||
filename: learnhtml-es.txt
|
||||
contributors:
|
||||
- ["Christophe THOMAS", "https://github.com/WinChris"]
|
||||
translators:
|
||||
|
@ -3,7 +3,7 @@ language: Wolfram
|
||||
lang: es-es
|
||||
contributors:
|
||||
- ["Daniel Caballero", "http://github.com/danielcaballero796/"]
|
||||
filename: learnwolfram-es.md
|
||||
filename: learnwolfram-es.nb
|
||||
---
|
||||
|
||||
Wolfram es un lenguaje subyacente originalmente utilizado en Mathematica, pero ahora esta disponible para su uso en múltiples contextos.
|
||||
|
@ -41,7 +41,7 @@ program example ! declare a program called example.
|
||||
real :: v, x ! WARNING: default initial values are compiler dependent!
|
||||
real :: a = 3, b = 2E12, c = 0.01
|
||||
integer :: i, j, k = 1, m
|
||||
real, parameter :: PI = 3.1415926535897931 ! declare a constant.
|
||||
real, parameter :: PI = 3.14159265 ! declare a constant.
|
||||
logical :: y = .TRUE., n = .FALSE. ! boolean type.
|
||||
complex :: w = (0, 1) ! sqrt(-1)
|
||||
character(len=3) :: month ! string of 3 characters.
|
||||
@ -461,10 +461,10 @@ end module fruity
|
||||
! to express loop-level parallelism
|
||||
|
||||
integer :: i
|
||||
real :: array(100)
|
||||
real :: array(10)
|
||||
|
||||
DO CONCURRENT (i = 1:size(array))
|
||||
array(i) = sqrt(i**i)
|
||||
array(i) = sqrt(real(i)**i)
|
||||
END DO
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
language: HTML
|
||||
filename: learnhtml-fr.html
|
||||
filename: learnhtml-fr.txt
|
||||
contributors:
|
||||
- ["Christophe THOMAS", "https://github.com/WinChris"]
|
||||
lang: fr-fr
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
language: HTML
|
||||
filename: learnhtml-he.html
|
||||
filename: learnhtml-he.txt
|
||||
contributors:
|
||||
- ['Christophe THOMAS', 'https://github.com/WinChris']
|
||||
translators:
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
language: HQ9+
|
||||
filename: hq9+.html
|
||||
filename: hq9+.txt
|
||||
contributors:
|
||||
- ["Alexey Nazaroff", "https://github.com/rogaven"]
|
||||
---
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
language: HQ9+
|
||||
filename: hq9+-id.html
|
||||
filename: hq9+-id.txt
|
||||
contributors:
|
||||
- ["Alexey Nazaroff", "https://github.com/rogaven"]
|
||||
translators:
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
language: reStructuredText (RST)
|
||||
filename: rst-id.html
|
||||
filename: rst-id.rst
|
||||
contributors:
|
||||
- ["DamienVGN", "https://github.com/martin-damien"]
|
||||
- ["Andre Polykanine", "https://github.com/Oire"]
|
||||
|
@ -3,7 +3,7 @@ language: Rust
|
||||
contributors:
|
||||
- ["Carlo Milanesi", "http://github.com/carlomilanesi"]
|
||||
lang: it-it
|
||||
filename: rust-it.html.markdown
|
||||
filename: rust-it.rs
|
||||
---
|
||||
|
||||
Rust è un linguaggio di programmazione sviluppato da Mozilla Research.
|
||||
|
@ -225,7 +225,7 @@ public class LearnJava {
|
||||
String fooString = "My String Is Here!";
|
||||
|
||||
// Text blocks
|
||||
vat textBlock = """
|
||||
var textBlock = """
|
||||
This is a <Text Block> in Java
|
||||
""";
|
||||
|
||||
|
@ -13,70 +13,168 @@ filename: learnlua.lua
|
||||
multi-line comment.
|
||||
--]]
|
||||
|
||||
print("Hello, Lua")
|
||||
|
||||
----------------------------------------------------
|
||||
-- 1. Variables and flow control.
|
||||
---- Variables, Data Types, and some operations ----
|
||||
----------------------------------------------------
|
||||
|
||||
num = 42 -- Numbers can be integer or floating point.
|
||||
-- integer and float values --
|
||||
num1 = 42
|
||||
num2 = 10.5
|
||||
|
||||
s = 'walternate' -- Immutable strings like Python.
|
||||
t = "double-quotes are also fine"
|
||||
u = [[ Double brackets
|
||||
start and end
|
||||
multi-line strings.]]
|
||||
-- Mathematical Operations :
|
||||
print(num1 + num2) -- Addition
|
||||
print(num1 - num2) -- Subtraction
|
||||
print(num1 * num2) -- Multiplication
|
||||
print(num1 / num2) -- Division
|
||||
print(num1 // num2) -- floor Division (round down to the closest integer)
|
||||
print(num1 % num2) -- Modulus (gives the remainder of num1/num2)
|
||||
print(num1 ^ num2) -- Exponentiation
|
||||
|
||||
|
||||
-- string values --
|
||||
str1 = 'single quotes string'
|
||||
str2 = "double quotes string"
|
||||
str3 = [[ multi
|
||||
line
|
||||
string]]
|
||||
|
||||
-- string concatenation is done using two dots :
|
||||
print(str1 .. str2)
|
||||
|
||||
|
||||
-- nil values (the absence of a value) --
|
||||
-- an undefined variable returns nil
|
||||
print(undefined_variable)
|
||||
-- a previously defined variable can be undefined with nil :
|
||||
t = 4
|
||||
t = nil -- Undefines t; Lua has garbage collection.
|
||||
|
||||
-- Blocks are denoted with keywords like do/end:
|
||||
|
||||
-- Boolean values --
|
||||
a = true
|
||||
b = false
|
||||
|
||||
-- note : other than writing false, you can write nil to represent a false value, you can't however write 0 or '' like in other languages.
|
||||
|
||||
-- boolean operations :
|
||||
print(not a)
|
||||
print(a and b)
|
||||
print(a or b)
|
||||
|
||||
|
||||
-- Variables are global by default
|
||||
-- to make them local you write :
|
||||
local variable_name = variable_value
|
||||
|
||||
|
||||
----------------------------------------------------
|
||||
------------ Standard Input and Output -------------
|
||||
----------------------------------------------------
|
||||
|
||||
-- Input :
|
||||
io.read() -- allow the user to input data through the console
|
||||
|
||||
-- example :
|
||||
print("write your name :")
|
||||
name = io.read() -- takes the user input and stores it in a variable named "name"
|
||||
print("Your name is " .. name)
|
||||
|
||||
-- Output :
|
||||
--[[
|
||||
The io.write() function is used to print text or data to the standard output (usually the console) without automatically adding a newline at the end. Unlike print()
|
||||
]]
|
||||
|
||||
io.write("Hello, Lua")
|
||||
|
||||
-- you can add a new line with \n if you want
|
||||
io.write("Hello, Lua\n")
|
||||
-- or a tab with -t, or a backslash (\) with \\
|
||||
|
||||
|
||||
----------------------------------------------------
|
||||
------------------ If Statements -------------------
|
||||
----------------------------------------------------
|
||||
-- Blocks of code are enclosed between key words like
|
||||
-- then/end or do/end
|
||||
|
||||
-- syntax :
|
||||
-- if (condition is true) then (do this) end
|
||||
|
||||
-- if (condition is true) then (do this)
|
||||
-- elseif (this condition is true) then (do this instead)
|
||||
-- else (if no condition is true, do this) end
|
||||
|
||||
--example :
|
||||
if true then
|
||||
print('something')
|
||||
end
|
||||
|
||||
if false then
|
||||
print('nothing')
|
||||
end
|
||||
|
||||
-- comparison operations :
|
||||
a == b -- Equality
|
||||
a ~= b -- Inequality
|
||||
a > b -- greater than
|
||||
a >= -- greater or equal to
|
||||
a < b -- less than
|
||||
a >= -- less or equal to
|
||||
-- alongside the (not, and, or) operations we learned earlier
|
||||
|
||||
----------------------------------------------------
|
||||
------------------- while loops --------------------
|
||||
----------------------------------------------------
|
||||
num = 0
|
||||
|
||||
while num < 50 do
|
||||
num = num + 1 -- No ++ or += type operators.
|
||||
print(num)
|
||||
num = num + 1
|
||||
end
|
||||
|
||||
-- If clauses:
|
||||
if num > 40 then
|
||||
print('over 40')
|
||||
elseif s ~= 'walternate' then -- ~= is not equals.
|
||||
-- Equality check is == like Python; ok for strs.
|
||||
io.write('not over 40\n') -- Defaults to stdout.
|
||||
else
|
||||
-- Variables are global by default.
|
||||
thisIsGlobal = 5 -- Camel case is common.
|
||||
-- note : this language doesn't have ++ or -- or += or -= operations like in some other languages.
|
||||
|
||||
-- How to make a variable local:
|
||||
local line = io.read() -- Reads next stdin line.
|
||||
----------------------------------------------------
|
||||
-------------------- for loops ---------------------
|
||||
----------------------------------------------------
|
||||
-- syntax :
|
||||
-- for (variable_name) = (start_value , end_value , step) do (something) end
|
||||
-- note : both the start_value and end_value are included in the range.
|
||||
-- note : the step value is optional, and it's default value is +1
|
||||
|
||||
-- String concatenation uses the .. operator:
|
||||
print('Winter is coming, ' .. line)
|
||||
-- examples :
|
||||
for i = 1, 10 do
|
||||
print(i)
|
||||
end
|
||||
|
||||
-- Undefined variables return nil.
|
||||
-- This is not an error:
|
||||
foo = anUnknownVariable -- Now foo = nil.
|
||||
|
||||
aBoolValue = false
|
||||
|
||||
-- Only nil and false are falsy; 0 and '' are true!
|
||||
if not aBoolValue then print('it was false') end
|
||||
|
||||
-- 'or' and 'and' are short-circuited.
|
||||
-- This is similar to the a?b:c operator in C/js:
|
||||
ans = aBoolValue and 'yes' or 'no' --> 'no'
|
||||
|
||||
karlSum = 0
|
||||
for i = 1, 100 do -- The range includes both ends.
|
||||
karlSum = karlSum + i
|
||||
for j = 10, 1, -1 do
|
||||
print(j)
|
||||
end
|
||||
|
||||
-- Use "100, 1, -1" as the range to count down:
|
||||
fredSum = 0
|
||||
for j = 100, 1, -1 do fredSum = fredSum + j end
|
||||
for j = 10, 1, -2 do
|
||||
print(j)
|
||||
end
|
||||
|
||||
-- In general, the range is begin, end[, step].
|
||||
----------------------------------------------------
|
||||
---------------- repeat until loops ----------------
|
||||
----------------------------------------------------
|
||||
|
||||
-- Another loop construct:
|
||||
--[[The repeat, until loop in Lua is similar to the do, while loop in other languages. It repeatedly executes a block of code until a specified condition becomes true. Unlike the while loop, the repeat ... until loop will always execute at least once, since the condition is checked after each iteration.]]
|
||||
|
||||
-- syntax :
|
||||
repeat
|
||||
print('the way of the future')
|
||||
num = num - 1
|
||||
until num == 0
|
||||
-- code to execute
|
||||
until condition
|
||||
|
||||
-- example
|
||||
k = 10
|
||||
|
||||
repeat
|
||||
print(k)
|
||||
k = k - 1
|
||||
until k == 0
|
||||
|
||||
|
||||
----------------------------------------------------
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
language: HTML
|
||||
filename: learnhtml-nl.html
|
||||
filename: learnhtml-nl.txt
|
||||
contributors:
|
||||
- ["Christophe THOMAS", "https://github.com/WinChris"]
|
||||
translators:
|
||||
|
@ -5,7 +5,7 @@ contributors:
|
||||
- ["Mathias Bynens", "http://mathiasbynens.be/"]
|
||||
translators:
|
||||
- ["Petru Dimitriu", "http://petru-dimitriu.github.io"]
|
||||
filename: bf-ro.html
|
||||
filename: bf-ro.bf
|
||||
lang: ro-ro
|
||||
---
|
||||
|
||||
|
@ -5,7 +5,7 @@ contributors:
|
||||
translators:
|
||||
- ["Petru Dimitriu", "http://petru-dimitriu.github.io"]
|
||||
lang: ro-ro
|
||||
filename: haskell-ro.html
|
||||
filename: haskell-ro.hs
|
||||
---
|
||||
|
||||
Haskell este un limbaj de programare practic, pur funcțional.
|
||||
|
@ -8,18 +8,21 @@ filename: learnforth-ru.fs
|
||||
lang: ru-ru
|
||||
---
|
||||
|
||||
Форт создан Чарлзом Муром в 70-е годы. Это императивный, стековый язык программирования и среда исполнения программ. Использовался в таких проектах как Open Firmware. Продолжает применятся в проектах. Применяется в НАСА.
|
||||
Форт создан Чарлзом Муром в 70-е годы. Это императивный, стековый язык
|
||||
программирования и среда исполнения программ. Использовался в таких проектах
|
||||
как Open Firmware. Продолжает применяться в проектах. Применяется в НАСА.
|
||||
|
||||
Внимание: этот материал использует реализацию Форта - Gforth, но большая часть написанного будет работать в других средах.
|
||||
Внимание: этот материал использует реализацию Форта - Gforth, но большая часть
|
||||
написанного будет работать в других средах.
|
||||
|
||||
|
||||
```forth
|
||||
\ Это комментарий
|
||||
( Это тоже комментарий, но используется для предоределённых слов )
|
||||
( Это тоже комментарий, но используется для предопределённых слов )
|
||||
|
||||
\ --------------------------------- Прекурсор --------------------------------
|
||||
|
||||
\ Всё программирование на Форте заключается в манипулировании
|
||||
\ Всё программирование на Форте заключается в манипулировании
|
||||
\ параметрами на стеке.
|
||||
5 2 3 56 76 23 65 \ ok
|
||||
|
||||
@ -31,7 +34,7 @@ lang: ru-ru
|
||||
|
||||
\ ---------------------------- Базовая арифметика ----------------------------
|
||||
|
||||
\ Арифметика (фактически все ключевые слова требуют данных) - это манипуляция
|
||||
\ Арифметика (фактически все ключевые слова требуют данных) - это манипуляция
|
||||
\ данными на стеке.
|
||||
5 4 + \ ok
|
||||
|
||||
@ -51,10 +54,10 @@ lang: ru-ru
|
||||
|
||||
\ --------------------------- Манипуляции со стеком ---------------------------
|
||||
|
||||
\ Естественно, когда мы работаем со стеком, то используем
|
||||
\ Естественно, когда мы работаем со стеком, то используем
|
||||
\ больше полезных методов:
|
||||
|
||||
3 dup - \ дублировать верхний элемент в стеке
|
||||
3 dup - \ дублировать верхний элемент в стеке
|
||||
\ (1-й становится эквивалентным 2-му): 3 - 3
|
||||
2 5 swap / \ поменять местами верхний элемент со 2-м элементом: 5 / 2
|
||||
6 4 5 rot .s \ сменять по очереди 3-и верхних элемента: 4 5 6
|
||||
@ -63,20 +66,20 @@ lang: ru-ru
|
||||
|
||||
\ ------------------ Более продвинутые манипуляции со стеком ------------------
|
||||
|
||||
1 2 3 4 tuck \ дублировать верхний елемент стека во вторую позицию:
|
||||
1 2 3 4 tuck \ дублировать верхний элемент стека во вторую позицию:
|
||||
\ 1 2 4 3 4 ok
|
||||
1 2 3 4 over \ диблировать второй елемент наверх стека:
|
||||
1 2 3 4 over \ дублировать второй элемент наверх стека:
|
||||
\ 1 2 3 4 3 ok
|
||||
1 2 3 4 2 roll \ *переместить* элемент в заданной позиции наверх стека:
|
||||
\ 1 3 4 2 ok
|
||||
1 2 3 4 2 pick \ *дублировать* элемент в заданной позиции наверх:
|
||||
1 2 3 4 2 pick \ *дублировать* элемент в заданной позиции наверх:
|
||||
\ 1 2 3 4 2 ok
|
||||
|
||||
\ Внимание! Обращения к стеку индексируются с нуля.
|
||||
|
||||
\ --------------------------- Создание новых слов -----------------------------
|
||||
|
||||
\ Определение новых слов через уже известные. Двоеточие `:` переводит Форт
|
||||
\ Определение новых слов через уже известные. Двоеточие `:` переводит Форт
|
||||
\ в режим компиляции выражения, которое заканчивается точкой с запятой `;`.
|
||||
: square ( n -- n ) dup * ; \ ok
|
||||
5 square . \ 25 ok
|
||||
@ -86,15 +89,15 @@ see square \ : square dup * ; ok
|
||||
|
||||
\ -------------------------------- Зависимости --------------------------------
|
||||
|
||||
\ -1 == true, 0 == false. Однако, некоторые ненулевые значения
|
||||
\ -1 == true, 0 == false. Однако, некоторые ненулевые значения
|
||||
\ обрабатываются как true:
|
||||
42 42 = \ -1 ok
|
||||
12 53 = \ 0 ok
|
||||
|
||||
\ `if` это компилируемое слово. `if` <stuff to do> `then` <rest of program>.
|
||||
: ?>64 ( n -- n ) dup 64 > if ." Больше чем 64!" then ;
|
||||
: ?>64 ( n -- n ) dup 64 > if ." Больше чем 64!" then ;
|
||||
\ ok
|
||||
100 ?>64
|
||||
100 ?>64
|
||||
\ Больше чем 64! ok
|
||||
|
||||
\ Else:
|
||||
@ -119,7 +122,7 @@ myloop
|
||||
: one-to-12 ( -- ) 12 0 do i . loop ; \ ok
|
||||
one-to-12 \ 0 1 2 3 4 5 6 7 8 9 10 11 12 ok
|
||||
|
||||
\ `?do` работает подобным образом, за исключением пропуска начального
|
||||
\ `?do` работает подобным образом, за исключением пропуска начального
|
||||
\ и конечного значения индекса цикла.
|
||||
: squares ( n -- ) 0 ?do i square . loop ; \ ok
|
||||
10 squares \ 0 1 4 9 16 25 36 49 64 81 ok
|
||||
@ -139,13 +142,13 @@ variable age \ ok
|
||||
\ Затем мы запишем число 21 в переменную 'age' (возраст) словом `!`.
|
||||
21 age ! \ ok
|
||||
|
||||
\ В заключении мы можем напечатать значение переменной прочитав его словом `@`,
|
||||
\ которое добавит значение на стек или использовать слово `?`,
|
||||
\ В заключении мы можем напечатать значение переменной прочитав его словом `@`,
|
||||
\ которое добавит значение на стек или использовать слово `?`,
|
||||
\ что бы прочитать и распечатать в одно действие.
|
||||
age @ . \ 21 ok
|
||||
age ? \ 21 ok
|
||||
|
||||
\ Константы объявляются аналогично, за исключем того, что мы не должны
|
||||
\ Константы объявляются аналогично, за исключем того, что мы не должны
|
||||
\ беспокоиться о выделении адреса в памяти:
|
||||
100 constant WATER-BOILING-POINT \ ok
|
||||
WATER-BOILING-POINT . \ 100 ok
|
||||
@ -155,7 +158,7 @@ WATER-BOILING-POINT . \ 100 ok
|
||||
\ Создание массива похоже на объявление переменной, но нам нужно выделить
|
||||
\ больше памяти.
|
||||
|
||||
\ Вы можете использовать слова `2 cells allot` для создания массива
|
||||
\ Вы можете использовать слова `2 cells allot` для создания массива
|
||||
\ размером 3 элемента:
|
||||
variable mynumbers 2 cells allot \ ok
|
||||
|
||||
@ -165,7 +168,7 @@ mynumbers 3 cells erase \ ok
|
||||
\ В качестве альтернативы мы можем использовать `fill`:
|
||||
mynumbers 3 cells 0 fill
|
||||
|
||||
\ или мы можем пропустить все слова выше и инициализировать массив
|
||||
\ или мы можем пропустить все слова выше и инициализировать массив
|
||||
\ нужными значениями:
|
||||
create mynumbers 64 , 9001 , 1337 , \ ok (the last `,` is important!)
|
||||
|
||||
@ -205,7 +208,7 @@ mynumbers 1 of-arr ? \ 20 ok
|
||||
|
||||
\ ---------------- Операции над числами с плавающей точкой --------------------
|
||||
|
||||
\ Многие фортовцы стараются избегать использование слов с вещественными числами.
|
||||
\ Многие фортовцы стараются избегать использования слов с вещественными числами.
|
||||
8.3e 0.8e f+ f. \ 9.1 ok
|
||||
|
||||
\ Обычно мы просто используем слово 'f', когда обращаемся к вещественным числам:
|
||||
@ -215,7 +218,7 @@ myfloatingvar f@ f. \ 4.4 ok
|
||||
|
||||
\ ---------- В завершение несколько полезных замечаний и слов -----------------
|
||||
|
||||
\ Указание несуществующего слова очистит стек. Тем не менее, есть специальное
|
||||
\ Указание несуществующего слова очистит стек. Тем не менее, есть специальное
|
||||
\ слово для этого:
|
||||
clearstack
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
language: HTML
|
||||
filename: learnhtml-ru.html
|
||||
filename: learnhtml-ru.txt
|
||||
contributors:
|
||||
- ["Christophe THOMAS", "https://github.com/WinChris"]
|
||||
translators:
|
||||
|
@ -91,7 +91,7 @@ false.class #=> FalseClass
|
||||
2 <= 2 #=> true
|
||||
2 >= 2 #=> true
|
||||
|
||||
# Combined comparison operator (returns `1` when the first argument is greater,
|
||||
# Combined comparison operator (returns `1` when the first argument is greater,
|
||||
# `-1` when the second argument is greater, and `0` otherwise)
|
||||
1 <=> 10 #=> -1 (1 < 10)
|
||||
10 <=> 1 #=> 1 (10 > 1)
|
||||
@ -259,8 +259,8 @@ else
|
||||
'else, also optional'
|
||||
end
|
||||
|
||||
# If a condition controls invocation of a single statement rather than a block of code
|
||||
# you can use postfix-if notation
|
||||
# If a condition controls invocation of a single statement rather than a block
|
||||
# of code you can use postfix-if notation
|
||||
warnings = ['Patronimic is missing', 'Address too short']
|
||||
puts("Some warnings occurred:\n" + warnings.join("\n")) if !warnings.empty?
|
||||
|
||||
@ -268,7 +268,7 @@ puts("Some warnings occurred:\n" + warnings.join("\n")) if !warnings.empty?
|
||||
puts("Some warnings occurred:\n" + warnings.join("\n")) unless warnings.empty?
|
||||
|
||||
# Loops
|
||||
# In Ruby, traditional `for` loops aren't very common. Instead, these
|
||||
# In Ruby, traditional `for` loops aren't very common. Instead, these
|
||||
# basic loops are implemented using enumerable, which hinges on `each`.
|
||||
(1..5).each do |counter|
|
||||
puts "iteration #{counter}"
|
||||
@ -279,9 +279,10 @@ for counter in 1..5
|
||||
puts "iteration #{counter}"
|
||||
end
|
||||
|
||||
# The `do |variable| ... end` construct above is called a 'block'. Blocks are similar
|
||||
# to lambdas, anonymous functions or closures in other programming languages. They can
|
||||
# be passed around as objects, called, or attached as methods.
|
||||
# The `do |variable| ... end` construct above is called a 'block'. Blocks are
|
||||
# similar to lambdas, anonymous functions or closures in other programming
|
||||
# languages. They can be passed around as objects, called, or attached as
|
||||
# methods.
|
||||
#
|
||||
# The 'each' method of a range runs the block once for each element of the range.
|
||||
# The block is passed a counter as a parameter.
|
||||
@ -415,19 +416,20 @@ surround { puts 'hello world' }
|
||||
#=> hello world
|
||||
#=> }
|
||||
|
||||
# Blocks can be converted into a 'proc' object, which wraps the block
|
||||
# and allows it to be passed to another method, bound to a different scope,
|
||||
# or manipulated otherwise. This is most common in method parameter lists,
|
||||
# where you frequently see a trailing '&block' parameter that will accept
|
||||
# the block, if one is given, and convert it to a 'Proc'. The naming here is
|
||||
# convention; it would work just as well with '&pineapple'.
|
||||
# Blocks can be converted into a 'proc' object, which wraps the block and allows
|
||||
# it to be passed to another method, bound to a different scope, or manipulated
|
||||
# otherwise. This is most common in method parameter lists, where you frequently
|
||||
# see a trailing '&block' parameter that will accept the block, if one is given,
|
||||
# and convert it to a 'Proc'. The naming here is convention; it would work just
|
||||
# as well with '&pineapple'.
|
||||
def guests(&block)
|
||||
block.class #=> Proc
|
||||
block.call(4)
|
||||
end
|
||||
|
||||
# The 'call' method on the Proc is similar to calling 'yield' when a block is
|
||||
# present. The arguments passed to 'call' will be forwarded to the block as arguments.
|
||||
# The 'call' method on the Proc is similar to calling 'yield' when a block is
|
||||
# present. The arguments passed to 'call' will be forwarded to the block as
|
||||
# arguments.
|
||||
|
||||
guests { |n| "You have #{n} guests." }
|
||||
# => "You have 4 guests."
|
||||
@ -443,7 +445,7 @@ end
|
||||
upcased = ['Watch', 'these', 'words', 'get', 'upcased'].map(&:upcase)
|
||||
puts upcased
|
||||
#=> ["WATCH", "THESE", "WORDS", "GET", "UPCASED"]
|
||||
|
||||
|
||||
sum = [1, 2, 3, 4, 5].reduce(&:+)
|
||||
puts sum
|
||||
#=> 15
|
||||
@ -472,7 +474,7 @@ def best(first, second, third, *others)
|
||||
puts "There were #{others.count} other participants."
|
||||
end
|
||||
|
||||
best *ranked_competitors
|
||||
best *ranked_competitors
|
||||
#=> Winners are John, Sally, and Dingus.
|
||||
#=> There were 2 other participants.
|
||||
|
||||
@ -480,9 +482,9 @@ best *ranked_competitors
|
||||
5.even? #=> false
|
||||
5.odd? #=> true
|
||||
|
||||
# By convention, if a method name ends with an exclamation mark, it does something destructive
|
||||
# like mutate the receiver. Many methods have a ! version to make a change, and
|
||||
# a non-! version to just return a new changed version.
|
||||
# By convention, if a method name ends with an exclamation mark, it does
|
||||
# something destructive like mutate the receiver. Many methods have a ! version
|
||||
# to make a change, and a non-! version to just return a new changed version.
|
||||
company_name = "Dunder Mifflin"
|
||||
company_name.upcase #=> "DUNDER MIFFLIN"
|
||||
company_name #=> "Dunder Mifflin"
|
||||
@ -516,7 +518,8 @@ class Human
|
||||
@name
|
||||
end
|
||||
|
||||
# The above functionality can be encapsulated using the attr_accessor method as follows.
|
||||
# The above functionality can be encapsulated using the attr_accessor method
|
||||
# as follows.
|
||||
attr_accessor :name
|
||||
|
||||
# Getter/setter methods can also be created individually like this.
|
||||
|
@ -3,7 +3,7 @@ category: framework
|
||||
framework: ShutIt
|
||||
contributors:
|
||||
- ["Ian Miell", "http://ian.meirionconsulting.tk"]
|
||||
filename: learnshutit.html
|
||||
filename: learnshutit.py
|
||||
---
|
||||
|
||||
## ShutIt
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
language: HTML
|
||||
filename: learnhtml-vi.html
|
||||
filename: learnhtml-vi.txt
|
||||
contributors:
|
||||
- ["Christophe THOMAS", "https://github.com/WinChris"]
|
||||
translators:
|
||||
|
@ -58,6 +58,7 @@ The syntax for tables is [very complicated](https://en.wikipedia.org/wiki/Help:T
|
||||
```
|
||||
|
||||
which renders to
|
||||
|
||||
| **column title A** | **column title B** |
|
||||
|---|---|
|
||||
| cell A1 | cell B1 |
|
||||
@ -120,6 +121,7 @@ If a word is interrupted by a link, it is "blended" into the link. For example,
|
||||
To suppress this behavior, use `<nowiki>`. For example, `[[micro-]]<nowiki />second` renders to [micro-](https://en.wikipedia.org/wiki/micro-)second.
|
||||
|
||||
There are three kinds of external linking. The third kind is preferred:
|
||||
|
||||
| wikitext | renders to |
|
||||
|----|----|
|
||||
| `https://www.wikipedia.org` | [https://www.wikipedia.org](https://www.wikipedia.org) |
|
||||
|
@ -3,7 +3,7 @@ category: framework
|
||||
framework: AngularJS
|
||||
contributors:
|
||||
- ["Walter Cordero", "http://waltercordero.com"]
|
||||
filename: learnangular-cn.html
|
||||
filename: learnangular-cn.txt
|
||||
translators:
|
||||
- ["Jiang Haiyun", "http://www.atjiang.com"]
|
||||
lang: zh-cn
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
language: HTML
|
||||
filename: learnhtml-cn.html
|
||||
filename: learnhtml-cn.txt
|
||||
contributors:
|
||||
- ["Christophe THOMAS", "https://github.com/WinChris"]
|
||||
translators:
|
||||
|
@ -5,7 +5,7 @@ contributors:
|
||||
- ["David Pedersen", "http://lonelyproton.com/"]
|
||||
- ["James Baker", "http://www.jbaker.io/"]
|
||||
- ["Leo Zovic", "http://langnostic.inaimathi.ca/"]
|
||||
filename: standard-ml-cn.html
|
||||
filename: standard-ml-cn.sml
|
||||
translators:
|
||||
- ["Buqian Zheng", "https://github.com/zhengbuqian"]
|
||||
lang: zh-cn
|
||||
|
Loading…
Reference in New Issue
Block a user