Skip to content

Commit f8e1579

Browse files
author
Rafael Mendonça França
committed
Revert "Merge pull request #3 from carlosgaldino/master"
Reason: Seems like github doesn't updated the pygment to GitHub Pages This reverts commit c770777, reversing changes made to 6ab2bde.
1 parent 22dd09f commit f8e1579

File tree

8 files changed

+689
-1042
lines changed

8 files changed

+689
-1042
lines changed

_includes/top.html

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
66
<title>{{ page.title }}</title>
77
<link rel="stylesheet" type="text/css" href="/css/style.css">
8-
<link rel="stylesheet" type="text/css" href="/css/syntax.css">
98
<link rel="shortcut icon" href="/images/logo/drop.png">
109
<meta name="viewport" content="width=device-width,initial-scale=1">
1110
<link rel="stylesheet" id="font-bitter-css" href="http://fonts.googleapis.com/css?family=Bitter&amp;ver=1" type="text/css" media="screen">
@@ -50,4 +49,4 @@ <h2 id="site-description">
5049
</h2>
5150
</div>
5251

53-
<div id="main">
52+
<div id="main">

css/syntax.css

-60
This file was deleted.

getting_started/1.markdown

+83-125
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,12 @@ If you don't use any of the distributions above, don't worry! Continue reading f
3131

3232
You can download and compile Elixir in few steps:
3333

34-
{% highlight console %}
35-
$ git clone https://github.com/elixir-lang/elixir.git
36-
$ cd elixir
37-
$ make test
34+
$ git clone https://github.com/elixir-lang/elixir.git
35+
$ cd elixir
36+
$ make test
3837

39-
$ bin/elixir -v
40-
Elixir 0.4.0.dev
41-
{% endhighlight %}
38+
$ bin/elixir -v
39+
Elixir 0.4.0.dev
4240

4341
If tests pass, you are ready to go. Otherwise, feel free to open an issue [in the issues tracker on Github](https://github.com/elixir-lang/elixir).
4442

@@ -51,110 +49,88 @@ If tests pass, you are ready to go. Otherwise, feel free to open an issue [in th
5149

5250
We can start Elixir interactive mode by running `bin/iex` in the same directory you compiled Elixir or by simply running `iex` if you installed it from a distribution. In interactive mode, we can type any Elixir expression. Let's warm up with some basic arithmetic expressions:
5351

54-
{% highlight iex %}
55-
iex> 1 + 1
56-
2
57-
iex> 10 - 5
58-
5
59-
iex> 10 / 2
60-
5.0
61-
{% endhighlight %}
52+
iex> 1 + 1
53+
2
54+
iex> 10 - 5
55+
5
56+
iex> 10 / 2
57+
5.0
6258

6359
Notice `10 / 2` returned a float `5.0` instead of an integer. This is expected, in Elixir the operator `/` always returns a float. In case you want to do integer division or get the division remainder, you can invoke the `div` and `rem` functions:
6460

65-
{% highlight iex %}
66-
iex> div(10, 2)
67-
5
68-
iex> div 10, 2
69-
5
70-
iex> rem 10, 3
71-
1
72-
{% endhighlight %}
61+
iex> div(10, 2)
62+
5
63+
iex> div 10, 2
64+
5
65+
iex> rem 10, 3
66+
1
7367

7468
In the example above, we called two functions called `div` and `rem`. Notice that parenthesis are not required in order to invoke a function. We are going to discuss more about it later. Let's move forward and see which other data types we have in Elixir:
7569

7670
## 1.3 Basic types
7771

7872
Some basic types are:
7973

80-
{% highlight iex %}
81-
iex> 1 # integer
82-
iex> 1.0 # float
83-
iex> :atom # atom / symbol
84-
iex> {1,2,3} # tuple
85-
iex> [1,2,3] # list
86-
{% endhighlight %}
74+
iex> 1 # integer
75+
iex> 1.0 # float
76+
iex> :atom # atom / symbol
77+
iex> {1,2,3} # tuple
78+
iex> [1,2,3] # list
8779

8880
Elixir also provides functions (note the dot between the variable and arguments when calling a function):
8981

90-
{% highlight iex %}
91-
# function
92-
iex> x = fn(a, b) -> a + b end
93-
#Fun<erl_eval.12.111823515>
94-
iex> x.(1, 2)
95-
3
96-
{% endhighlight %}
82+
# function
83+
iex> x = fn(a, b) -> a + b end
84+
#Fun<erl_eval.12.111823515>
85+
iex> x.(1, 2)
86+
3
9787

9888
And double-quoted strings:
9989

100-
{% highlight iex %}
101-
iex> "string"
102-
"string"
103-
{% endhighlight %}
90+
iex> "string"
91+
"string"
10492

10593
Strings in Elixir are UTF-8 binaries delimited by double quotes. A single-quoted string in Elixir is called a char list and is simply a list of characters:
10694

107-
{% highlight iex %}
108-
iex> 'string'
109-
'string'
110-
{% endhighlight %}
95+
iex> 'string'
96+
'string'
11197

11298
There is also string interpolation:
11399

114-
{% highlight iex %}
115-
iex> name = "world"
116-
iex> "hello #{name}"
117-
"hello world"
118-
{% endhighlight %}
100+
iex> name = "world"
101+
iex> "hello #{name}"
102+
"hello world"
119103

120104
We can use the `is_binary` and `is_list` helpers to detect if a given string is a binary (double-quoted) or a list (single-quoted):
121105

122-
{% highlight iex %}
123-
iex> is_binary "string"
124-
true
125-
iex> is_list "string"
126-
false
106+
iex> is_binary "string"
107+
true
108+
iex> is_list "string"
109+
false
127110

128-
iex> is_binary 'string'
129-
false
130-
iex> is_list 'string'
131-
true
132-
{% endhighlight %}
111+
iex> is_binary 'string'
112+
false
113+
iex> is_list 'string'
114+
true
133115

134116
Although they represent the same thing, double-quoted and single-quoted strings are different and best suited for different scenarios:
135117

136-
{% highlight iex %}
137-
iex> "string" == 'string'
138-
false
139-
{% endhighlight %}
118+
iex> "string" == 'string'
119+
false
140120

141121
Most of the cases, developers should use double-quoted strings as their representation is more compact. We are going to discuss this subject with more detail in the next chapter.
142122

143123
Elixir also provides `true` and `false` as booleans:
144124

145-
{% highlight iex %}
146-
iex> true
147-
true
148-
iex> is_boolean false
149-
true
150-
{% endhighlight %}
125+
iex> true
126+
true
127+
iex> is_boolean false
128+
true
151129

152130
Booleans are represented internally as atoms:
153131

154-
{% highlight iex %}
155-
iex> is_atom(true)
156-
true
157-
{% endhighlight %}
132+
iex> is_atom(true)
133+
true
158134

159135
Elixir also provides Port, References and PIDs as data types (usually used in process communication) but they are out of the scope of a getting started tutorial. For now, let's take a look at the basic operators in Elixir before we move on to the next chapter.
160136

@@ -164,88 +140,70 @@ As we saw earlier, Elixir provides `+`, `-`, `*`, `/` as arithmetic operators.
164140

165141
Elixir also provides `++` and `--` to manipulate lists:
166142

167-
{% highlight iex %}
168-
iex> [1,2,3] ++ [4,5,6]
169-
[1,2,3,4,5,6]
170-
iex> [1,2,3] -- [2]
171-
[1,3]
172-
{% endhighlight %}
143+
iex> [1,2,3] ++ [4,5,6]
144+
[1,2,3,4,5,6]
145+
iex> [1,2,3] -- [2]
146+
[1,3]
173147

174148
Since single-quoted strings are lists, we can also use `++` and `--` as operators to manipulate them:
175149

176-
{% highlight iex %}
177-
iex> 'some' ++ ' example'
178-
'some example'
179-
iex> 'some' -- 'oe'
180-
'sm'
181-
{% endhighlight %}
150+
iex> 'some' ++ ' example'
151+
'some example'
152+
iex> 'some' -- 'oe'
153+
'sm'
182154

183155
Notice that `++` and `--` cannot be used to manipulate double quoted strings, as they are binaries. That said, string concatenation is done via `<>`:
184156

185-
{% highlight iex %}
186-
iex> "foo" <> "bar"
187-
"foobar"
188-
{% endhighlight %}
157+
iex> "foo" <> "bar"
158+
"foobar"
189159

190160
Elixir also provides three boolean operators: `or`, `and` and `not`. Those operators are strict in the sense those operators expects only booleans (true or false) as arguments:
191161

192-
{% highlight iex %}
193-
iex> true and true
194-
true
195-
iex> false or is_atom(:example)
196-
true
197-
{% endhighlight %}
162+
iex> true and true
163+
true
164+
iex> false or is_atom(:example)
165+
true
198166

199167
Giving a non-boolean as argument will raise an exception:
200168

201-
{% highlight iex %}
202-
iex> 1 and true
203-
** (::ArgumentError) argument error
204-
{% endhighlight %}
169+
iex> 1 and true
170+
** (::ArgumentError) argument error
205171

206172
`or` and `and` are short-circuit operators. They just execute the right side in case the left side is not enough to determine the result:
207173

208-
{% highlight iex %}
209-
iex> false and error("This error will never be raised")
210-
false
174+
iex> false and error("This error will never be raised")
175+
false
211176

212-
iex> true or error("This error will never be raised")
213-
true
214-
{% endhighlight %}
177+
iex> true or error("This error will never be raised")
178+
true
215179

216180
> Note: If you are an Erlang developer, `and` and `or` in Elixir actually map to the `andalso` and `orelse` operators in Erlang.
217181
218182
Elixir also provides `==`, `!=`, `===`, `!===`, `<=`, `>=`, `<` and `>` as comparison operators:
219183

220-
{% highlight iex %}
221-
iex> 1 == 1
222-
true
223-
iex> 1 != 2
224-
true
225-
iex> 1 < 2
226-
true
227-
{% endhighlight %}
184+
iex> 1 == 1
185+
true
186+
iex> 1 != 2
187+
true
188+
iex> 1 < 2
189+
true
228190

229191
The difference between `==` and `===` is that the latter is more strict when comparing integers and floats:
230192

231-
{% highlight iex %}
232-
iex> 1 == 1.0
233-
true
234-
iex> 1 === 1.0
235-
false
236-
{% endhighlight %}
193+
iex> 1 == 1.0
194+
true
195+
iex> 1 === 1.0
196+
false
237197

238198
In Elixir, we can compare two different data types:
239199

240-
{% highlight iex %}
241-
iex> 1 < :atom
242-
true
243-
{% endhighlight %}
200+
iex> 1 < :atom
201+
true
244202

245203
The reason we can compare different data types is for pragmatism. Sorting algorithms don't need to worry about different data types in order to sort. The overall sorting order is defined below:
246204

247205
number < atom < reference < functions < port < pid < tuple < list < bit string
248206

249207
You actually don't need to memorize this ordering, it is important just to know an order exists.
250208

251-
Well, that is it for the introduction. In the next chapter, we are going to discuss some basic functions, data types conversions and a bit of control-flow.
209+
Well, that is it for the introduction. In the next chapter, we are going to discuss some basic functions, data types conversions and a bit of control-flow.

0 commit comments

Comments
 (0)