-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
89 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,9 @@ | |
*.sublime-workspace | ||
|
||
*.sublime-project | ||
|
||
*.o | ||
|
||
examples/readdoubles2 | ||
|
||
examples/readdoubles1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,27 @@ | ||
Introduction | ||
================ | ||
|
||
It was mentioned that students can quickly master the D programming language without a detailed study using mostly its subset, which is close to the C PL. | ||
It was mentioned that students can quickly master the D programming language without a detailed study using mostly its subset, which is close to the C PL. | ||
|
||
Рассмотрим простую программу, которая считывает из файла 10 строк, содержащих по одному числу и | ||
печатает в стандартный выход эти же числа, но сдвинутые на математическое ожидание. | ||
|
||
Тогда как идиоматический D код выглядет достаточно непревычно: | ||
|
||
.. literalinclude:: ../../examples/readdoubles2.d | ||
:language: d | ||
:tab-width: 4 | ||
|
||
для многих незнакомых с языком D та же самая программа может быть реализована хоть и более грамоздким, | ||
но в тоже время более понятным способом: | ||
|
||
.. literalinclude:: ../../examples/readdoubles1.d | ||
:language: d | ||
:tab-width: 4 | ||
|
||
The present documentation is submitted to the rapid introduction to D for those who are already somehow familiar with the C language, and for those who for some reasons do not want to waste time on a consistent study of the language and related tools. | ||
|
||
If you decide to use the D language and related tools in your daily work, you should start immediately with the study of the `official page <http://dlang.org>`_ and of the book `"The D Programming Language" <http://erdani.com/index.php/books/tdpl/>`_ by Andrei Alexandrescu. | ||
If you decide to use the D language in your daily work, you should start immediately with the study of the `official page <http://dlang.org>`_ and of the book `"The D Programming Language" <http://erdani.com/index.php/books/tdpl/>`_ by Andrei Alexandrescu. | ||
|
||
Probably D is the most powerful of the present `system programming languages <http://en.wikipedia.org/wiki/System_programming_language>`_. | ||
`It is a dragon <http://thebird.nl/blog/D_Dragon.html>`_. Have a nice flight! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
12.234 | ||
234.12 | ||
3.2134 | ||
-123.432 | ||
2.454 | ||
324.234 | ||
0. | ||
2345. | ||
2 | ||
2.43 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "atmosphere_gm_charts", | ||
"dependencies": { | ||
"pyd": "~>0.9.4", | ||
}, | ||
"subConfigurations": { | ||
"pyd": "python34", | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import std.stdio; | ||
|
||
void main() { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import std.stdio; | ||
|
||
void main() | ||
{ | ||
File fin = File("10numbers.txt"); | ||
double[] sample; | ||
sample.length = 10; | ||
double mean = 0; | ||
for(int i = 0; i < sample.length; i++) | ||
{ | ||
fin.readf("%s", &sample[i]); | ||
if(!fin.eof) | ||
fin.readln(); | ||
mean += sample[i]; | ||
} | ||
mean /= sample.length; | ||
// prints one element per line | ||
for(int i = 0; i < sample.length; i++) | ||
{ | ||
writeln(sample[i] - mean); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import std.algorithm.iteration : map, each; | ||
import std.array : array; | ||
import std.conv : to; | ||
import std.range : takeExactly, tee; | ||
import std.stdio; | ||
|
||
void main() | ||
{ | ||
double mean = 0; | ||
auto sample = File("10numbers.txt") | ||
.byLine | ||
.takeExactly(10) | ||
.map!(to!double) | ||
.tee!((x){mean += x;}) | ||
.array; | ||
mean /= sample.length; | ||
// prints one element per line | ||
sample.map!(x => x - mean).each!writeln; | ||
} |