OpenLLM-France/wikimedia huggingface dataset:
# D (The Programming Language)/d2/Modules

| | Topics: | Language and Phobos - DGui (example placeholder - can be any library) | |
| Previous | Lessons: | 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - T | Next |

# Lesson 6: Modules

In this lesson, you will gain an understanding of D's module system. A module is a unit of code that contains definitions for variables, functions, and other D constructs that belong together. This is useful for creating reusable code. You've seen modules in every single lesson. In fact, all D source files are modules. The stdio module contains functions like writeln. The module stdio is written in a file called stdio.d at dmd/src/phobos/std/stdio.d. It contains code that is useful for console input and output and file input and output. It is within a package called std, which also contains modules such as std.algorithm or std.string, which you will learn about later. The Phobos library is just a big collection of modules that comes with a D compiler.

## Introductory Code

Compile like this: dmd main.d happy.d bye.d

## Concepts
### A Deeper Look at Imports

All D code is inside modules. In D programs, there has to be one module with a main function. If one module imports another module, the imported module's definitions becomes available to the first module. In the introductory code, the main module imported two other modules: module1 and byebye. However, when byebye was imported, only one function was imported: the sayBye function. The syntax for that is import modulename : identifier1, identifier2, identifier3;.

### Module Declarations

D source files can specify the name of the module and what package it belongs to with a module declaration, which goes at the beginning. For example, in the stdio module, there is this line:
That line specifies the name of the module (stdio) and the package it is located in (std). Each source file can only have a maximum of one module declaration. If there is none, the source file name (without the extension) becomes the module name.

### Visibility

Before the void in the definition of sad in module1, you see the modifier private. That means that the sad function cannot be imported. You wouldn't be able to do import module1 : sad, either. If you see a line that says private:, everything below that line is private. Likewise, if you see private { } , everything inside the curly brackets is private.

## Tips

* The name of the module does not have to relate to the names of the definitions within that module.
* The name of the module does not have to relate to the file name.
* There is also a public modifier, which is the opposite of the private modifier. Declarations marked by neither public nor private are public by default.
* All D source files are modules, even if there is no module declaration in the file.
# D (The Programming Language)/d2/Intro to Functions

| | Topics: | Language and Phobos - DGui (example placeholder - can be any library) | |
| Previous | Lessons: | 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - T | Next |

# Lesson 3: Intro to Functions

In this lesson, you see more of functions, which were used back in Lesson 1. If you are already familiar with another C-like language, you only need to skim this over.

## Concepts
### Functions

Functions allow you to write more organized code. With functions, you can write some code once, and then call it whenever you need to use that code.

### Function Syntax

Let's take a look at the syntax:
# D (The Programming Language)/d2/Pointers, Pass-By-Reference and Static Arrays

| | Topics: | Language and Phobos - DGui (example placeholder - can be any library) | |
| Previous | Lessons: | 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - T | Next |
| | Subpages: | What are Pointers? - What are Arrays? |

# Lesson 7: Pointers, Pass-By-Reference and Static Arrays

In this chapter, you will learn about how to use pointers and static arrays in D. You will also learn how to pass by reference without using pointers. The lesson text will not explain the concepts behind pointers and arrays, and it will assume that you have that knowledge from C or C++. D also has dynamic arrays and array slices, both of which will be covered in a later lesson.

## Introductory Code
### Pass By Reference

If you're a C++ programmer and you read the above thinking it's a step back from C++ references, then rejoice: while D supports pointers, it also supports better solutions for passing variables by reference to functions:
There is also special support for out parameters:
Using out, n in initializeNumber is default initialized at the beginning of the function.

### Using Static Arrays
## Concepts
### Reference and Dereference

The syntax in D is the same as C and C++. The operator & takes the reference of an object, and * dereferences.

### Pointer Types

In D, a pointer to typeA is:
and the code for declaring one is:

### Static Arrays

Static arrays have fixed lengths. You declare them like this:
You can also do this:
Arrays are indexed starting with the number zero for the first element. The compiler will catch you if you attempt to access an element with an index greater than or equal to that array's length. You access elements of an array like this:
You can also fill an array with a single value, so that all of that array's elements equal that value:

### As Function Arguments

Look at this code:
The output is [1,2,3], not [2,2,3]. Why? It's because static arrays are copied whenever they are passed as arguments to a function. The arr in the addOne function is only a copy of array1. Rewrite it like this:
# D (The Programming Language)

Welcome to the D programming lesson-based wikibook, a free resource on the D programming language. This page links to lessons on programming in D.
Note: If you have some experience in D, you are welcome to contribute to this very unfinished book.
* This wikibook has a lesson-based structure, which is useful for teaching a programming language.

## The Lessons

| Introduction About D | The Language Lesson 1: Hello, World! Lesson 2: Types and Declarations Lesson 3: Functions Lesson 4: Types, Continued Lesson 5: Type Conversion Lesson 6: Modules Lesson 7: Pointers and Static Arrays Lesson 8: Strings and Dynamic Arrays Lesson 9: Slicing and a Deeper Look into Dynamic Arrays Lesson 10: Conditionals |
| DGui Lesson Texts Lesson 1 |
# D (The Programming Language)/Contributors
## Style Guides

* The Style Guide for the D/Phobos Lessons

## To Do List

* Finish the rest of the D (The Programming Language)/d2/.

## List of Contributors

Add yourself to this list if you have contributed to this wikibook:
* -- Jcao219 (discuss • contribs) 06:00, 22 June 2011 (UTC)

## Userbox

You may add this box to your user page.
| This user contributes to the D (The Programming Language) wikibook. | {{User:Jcao219/Userboxes/DTPLContributor}} |
# D (The Programming Language)/d2/Hello, World!

| Topics: | Language and Phobos - DGui (example placeholder - can be any library) | |
| Lessons: | 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - T | Next |
| Subpages: | String Formatting - Advanced Info about std.stdio's Write Functions |

# Lesson 1: Hello, World!

In this lesson, you will learn how to use the Phobos library to write to the console. Also, you will learn some about the structure of D programs.

## Introductory Code

We will start with the absolutely necessary Hello World example.

### Hello World
## Concepts

In this lesson we see the import statement, the main function, the Phobos standard library in use, and also a code comment.

### import std.stdio

The Phobos library contains the std.stdio module which in turn contains the writeln function (along with various other functions). In order to use that function, you must first import that module. Notice that statements in D end in a semicolon.

### void main

All executable D programs contain a main function. This function does not return a value, so it is declared "void" (Technically, this is an over-simplification. Return values of main will be explained in more detail later.) This function is executed when the program runs.
Function body code is enclosed in curly brackets. Although the indentation and whitespace is only for the reader, not for the compiler, make sure you indent and format your code properly and consistently; it's generally a good coding practice.

### writeln and the write family

writeln is for writing to the standard output (console in this case). You can supply a string such as "Hello, World!" as an argument, and that string will be printed out. There are four basic flavors of this function: With or without formatting, and with or without a trailing newline. To demonstrate how they work, all of the following are equivalent (although the first and thirds ones don't flush stdout on Windows):

### /* I am a comment */

The first few lines of this program are comments. They are ignored by the compiler. Block comments are enclosed in /* */. Line comments continue after // .
This is an example of a line comment:
D also supports nested block comments, enclosed in /+ +/:
This is different from ordinary block comments which behave just like in C:

## Tips

* writeln is different from write because it adds a newline to the end.
# Electromagnetic radiation/Gamma rays

Electromagnetic radiation: 11. Gamma rays
These have a wavelength of 0.01 nm or less, hence photon energies exceed 100keV. They were discovered by Henri Becquerel in 1898 as a form of radioactivity. (He discovered three types, which he called alpha, beta and gamma, hence the name. However, alpha and beta are particles, not electromagnetic rays.)
Gamma rays are even more dangerous to living things than are X-rays, and are sometimes used to sterilise equipment since they can kill virtually all bacteria and viruses.
There is no lower boundary to the wavelength hence no upper bound to frequency or photon energy. In October 2011, photons with energies exceeding 100 billion eV, i.e. over a million times the lower limit, were detected from the Crab pulsar.
# Electromagnetic radiation/Microwaves

Electromagnetic radiation: 6. Microwaves
Microwaves in radio telecommunications are the very shortest wavelengths usable for communication. They have wavelength 1mm to 30 cm, or frequency 1–300 GHz.
An important frequency is 1420 MHz (wavelength 21.1 cm). Interstellar hydrogen radiates at this frequency, making it a very useful frequency for radio astronomers.
Microwaves have only fairly recently been regarded as distinct from very short wavelength radio waves. Their recognition is probably due to the popularity of microwave ovens. In fact, these ovens typically use frequencies of 300 MHz to 1 GHz, or wavelengths 30 cm to 100 cm, frequencies in the lower half of the UHF band hence slightly below the radio telecommunications definition.
# Electromagnetic radiation/Introduction

Electromagnetic radiation: 1. Introduction
Electromagnetic radiation is any form of energy-carrying radiation created by the interaction of electric and magnetic fields. It comes in many different types, although the differences between them are quantitative rather than qualitative. This book lists the different types that are generally recognised.
Electromagnetic radiation is a wave, so has a wavelength λ and a frequency ν. It is also composed of particles called photons, and each photon has an energy E. These three quantities are related, and any of them may be used to define the type of radiation.
The properties of electromagnetic radiation were first investigated by James Clerk Maxwell in 1864. He realised that in a vacuum they would travel at the speed of light, and he correctly deduced that light is radiation of this form.
# Electromagnetic radiation/Radio

Electromagnetic radiation: 5. Radio
The existence of radio waves was predicted by James Clerk Maxwell in 1864. Their properties were investigated by Heinrich Hertz (after whom the hertz is named) in 1885-9.
With the splitting-off of microwaves as a separate band, radio waves are now regarded as having wavelengths exceeding 30 cm, frequencies below 1 GHz. There is no upper limit to the wavelength hence no lower limit to the frequency. The standard divisions are:
* Ultra high frequency (UHF): Frequencies of 300 MHz to 3 GHz, hence wavelengths of 10 cm to 1m. This overlaps with the microwave region.
* Very high frequency (VHF): Frequencies of 30 MHz to 300 MHz, hence wavelengths of 1m to 10m.
* High frequency (HF): Frequencies of 3 MHz to 30 MHz, hence wavelengths of 10m to 100 m.
* Medium frequency (MF): Frequencies of 300 kHz to 3 MHz, hence wavelengths of 100m to 1 km. These are also called hectometric waves (hectometre = 100m).
* Low frequency (LF): Frequencies of 30 kHz to 300 kHz, hence wavelengths of 1 km to 10 km.
* Very low frequency (VLF): Frequencies of 10 kHz to 30 kHz, hence wavelengths of 10 km to 30 km.
* Ultra low frequency (ULF): Frequencies of 300 Hz to 10 kHz, hence wavelengths of 30 km to 1000 km; these are mainly used for long-distance underwater transmission.
* Extremely low frequency (ELF): The lowest frequencies (below 300 Hz; wavelength > 1000 km).
Sometimes a division by wavelength is used:
* Short wave (SW): Wavelengths of 10-200m hence frequencies of 1.5-33 MHz; there are several sub-bands.
* Medium wave (MW): Wavelengths of 200-1000m hence frequencies of 300 kHz-1.5 MHz.
* Long wave (LW): Wavelengths > 1000m hence frequencies < 300 kHz.
Other terms found are:
* Frequency modulation (FM): This is not a frequency band, but a way of coding the audio signal onto a radio wave. However, quite a high frequency is necessary for FM to work well, and in practice frequencies of close to 100 MHz (wavelength 3m, the middle of the VHF band) are used.
* Digital radio: Again, this is not a frequency band. Typically, frequencies of the order of 200 MHz (wavelength 1.5m, towards the short wavelength or high frequency end of the VHF band) are used.
* Decametric: Wavelengths of 10-30m (decametre = 10m) hence frequencies of 10-33 MHz. The planet Jupiter radiates strongly at these wavelengths.
# Electromagnetic radiation/Infra-red

Electromagnetic radiation: 7. Infra-red
Infra-red radiation, the first non-visible electromagnetic radiation to be discovered, was discovered by William Herschel in 1800.
It has wavelengths below 1mm, down to where they start to become visible (about 700 nm). Thus the frequency range is from 300 GHz up to about 430 THz. Shorter wavelengths are near infra-red; middle ones are mid infra-red; longer ones are far infra-red.
The longest wavelengths (0.1-1mm, 300 GHz-3THz) are sometimes regarded as a distinct band called Submillimetre radiation (from their wavelength) or Terahertz radiation (from their frequency). They can penetrate through some objects opaque to visible light, but can be used to produce images, so are a safe alternative to some uses of X-rays.
# Electromagnetic radiation/Ultraviolet (UV)

Electromagnetic radiation; 9. Ultraviolet (UV)
Ultraviolet radiation was discovered by Johann Wilhelm Ritter in 1801.
There are several terms used.
* Near ultraviolet: 400-300 nm
* Middle ultraviolet: 300-200 nm
* Extreme or far ultraviolet: 200-100 nm
* Vacuum ultraviolet is UV with wavelengths shorter than about 150-200 nm. Such wavelengths are strongly absorbed by air, especially oxygen, so are best used in a vacuum. However, it is possible to use pure nitrogen rather than a vacuum.
UVA, UVB, UVC are terms used to assess how dangerous the UV is to human skin.
* UVA: 320-400 nm: Not absorbed by the ozone layer in the atmosphere; fairly harmless.
* UVB: 280-320 nm: Partly absorbed by ozone layer; more dangerous, especially where there is a "hole" in the ozone layer so more radiation can penetrate to ground level.
* UVC: 100-280 nm: Totally absorbed by ozone layer and atmospheric oxygen; most dangerous.
Short-wave UV, X-ray and gamma-ray radiation are sometimes lumped together as ionising radiation, because the photons are energetic enough to knock electrons out of atoms, ionising them. Such radiation is dangerous to living things, because the ionisation can disrupt biochemical processes and even cause cancer. Alpha and beta particles can also be called ionising radiation.
# Electromagnetic radiation/Units of measurenent

Electromagnetic radiation: 2. Units of measurement
Scientists usually use SI units. The unit of frequency is the hertz (Hz), one cycle per second, named after Heinrich Hertz. For our purposes, we shall use much higher frequencies. One thousand Hz is a kHz (kilohertz); one thousand kHz is a MHz (megahertz); one thousand MHz is a GHz (gigahertz); one thousand GHz is a THz (terahertz).
The SI unit of length is the metre (m). One thousand metres is a kilometre (km). One hundredth of a metre is a centimetre (cm); one thousandth is a millimetre (mm), one millionth is a micrometre (μm, often called a micron and written μ). A thousandth of a micrometre is called a nanometre (nm). A tenth of a nm (10$^{−10}$ m) is known as an Angstrom unit or Angstrom (Å). The use of cm and Angstrom is discouraged in the SI system, because in that system multiples or submultiples of the basic unit (metres in this case) should only be used in powers of 1,000. However, many scientists like them.
The SI unit of energy is the Joule (J). However, there is a much smaller unit, the electron volt (eV). Again, its use is discouraged in the SI system, since its ratio to the Joule is not a power of 10. However, in some branches of physics it is a natural unit to use. The eV is the energy gained by an electron in passing through a potential difference of one volt. Since the charge on an electron is 1.60218 x 10$^{−19}$ Coulombs, an eV is 1.60218 x 10$^{−19}$ J. A keV is 1000 eV and a MeV is 1000 keV.
As will be discussed later, either frequency or wavelength may be used for radio waves. Wavelength is usually used for infrared, visible and ultraviolet (expressed in nm or Å), and photon energy for X-rays and gamma rays (expressed in keV or MeV).
# Electromagnetic radiation/Relationships

Electromagnetic radiation: 3. Relationships
By definition, wavelength x frequency = speed. Since the speed of light c = 2.997458 x 10$^8$ m/s, we have
    λ ν = c
Also, by Planck's law,
    E = h ν
where h is Planck's constant 6.62607 x 10$^{−34}$ Js.
It follows that a photon with an energy of 1eV has a frequency of 1 eV/h = 2.41799 x 10$^{14}$ Hz or about 242 THz and a wavelength of c.h/1 eV = 1.23984 x 10$^{−6}$ m or about 1,240 nm or 12,400Å. As will be seen below, that would put the photon in the infrared range. In practice, photon energies are never quoted for such long wavelengths because they are so low that the photon nature of the radiation is unimportant.
# Electromagnetic radiation/Visible light

Electromagnetic radiation: 8. Visible light
This is of course the most familiar form of electromagnetic radiation. It covers wavelengths of around 400-700 nm (frequencies of 430-750 THz); different people have different limits. The range of wavelengths that a person can detect has is nothing to do with colour blindness, which refers to the ability to perceive differences in frequency as colour rather than ability to detect the radiation.
The longest wavelengths correspond to red, then orange, yellow, green, blue, indigo and violet are shorter and shorter. There is no sharp division into different colours; they merge gradually into each other as the wavelength increases.
This is a relatively narrow band, covering a factor of no more than two in wavelength or frequency. However, it is comparatively well defined.
It has been reported that some people who have had cataracts removed can see shorter wavelengths than other people, because they get replacement lenses in their eyes that are more transparent to these wavelengths than natural lenses. A well-documented case is the astronomer Walter Scott Houston.
# Foundations and Current Issues of Early Childhood Education/Chapter 8

8.1 School Role in Early Childhood Health Version 1
8.2 School Role in Early Childhood Health Version 2
8.3 *School Role in Early Childhood Health Version 3
# Foundations and Current Issues of Early Childhood Education/Chapter 7

7.1 Reggio Emilia Version 1
7.2 *Reggio Emilia Version 2
7.3 Reggio Emilia Version 3
# EverQuest II/Crafting Reference/Recipes/Breaded Flounder
## Produces

* bland breaded flounder
* savory breaded flounder
* baked breaded flounder
* delectable breaded flounder

## Used in the following recipes

This item is not used in any recipes.
# EverQuest II/Crafting Reference/Recipes/Geomancy Essentials Volume 1

This book contains the following recipes.

## Refine

* Electrum Bar
* Iron Bar
* Turquoise Gem

## Interim

* Electrum Ornament
* Electrum Setting
* Electrum Sheet
* Faceted Turquoise
* Iron Arrow Head
* Iron Buckle
* Iron Chain Links
* Iron Crossguard
* Iron Edge
* Iron Hammer Head
* Iron Hook
* Iron Plate
* Iron Pommel
* Iron Rings
* Iron Sheet
* Iron Shod
* Iron Spike
* Iron Strut
* Iron Stud

## Finish

None.
# EverQuest II/Crafting Reference/Recipes/Barley Malted Milk
## Description

Brewing various materials together to make barley malted milk.

## Produces

* watery barley malted milk
* chilled barley malted milk
* barley malted milk
* refeshing barley malted milk

## Used in the following recipes

* Jumjum Milk
# EverQuest II/Crafting Reference/Recipes/Candied Jumjum
## Description

Cooking various materials together to make candied jumjum.

## Produces

* bland candied jumjum
* savory candied jumjum
* candied jumjum
* delectable candied jumjum

## Used in the following recipes

* Chocolate Covered Jumjum
* Chocolate Jumjum Cake
* Dried Jumjum
* Jumjum Cheesecake
* Jumjum Muffins
* Jumjum Pie
* Pecan-jumjum Trail Mix
# EverQuest II/Crafting Reference/Recipes/Black Coffee
## Description

Make Black Coffee

## Produces

* Black Coffee