text:
Cookbook:Haddock

| Basic foodstuffs | Seafood | Fish

Haddock is a type of white-fleshed fish in the cod family. It is found in the North Atlantic region, and it features heavily in the cuisine of the surrounding regions. It may be sold fresh, frozen, or smoked. It is rarely preserved by salting.

Smoked Haddock
Haddock may be smoked to preserve it and give it flavor. One variety of smoked haddock is Finnan haddie, which is cold-smoked over peat. Arbroath smokie is hot-smoked.

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

title: Cookbook:Haddock


text:
Cookbook:Pike

Pike is a variety of freshwater or brackish fish found in the northern hemisphere. It is white-fleshed and mild tasting.

Pike Recipes
A selection of recipes featuring pike includes:

 * Fish Stew of Alsace (Matelote de poissons d'Alsace)

title: Cookbook:Pike


text:
Cookbook:Carp

Carp are a group of freshwater fish native to Europe and Asia and introduced to the Americas.

Characteristics
Several varieties of carp are consumed as food, including bighead, common/Eurasian, mud/dace, grass, silver, and black carps. Bighead and silver carp may also be called copi. They are often farmed or caught in Asia, but tend primarily to be wild-caught in the Americas where they are invasive in local waterways.

The exact characteristics of the fish will depend largely on the quality of the water, their specific diet, and how they are prepared after catching. In general, carp skin is thick and scaly, and the dense flaky flesh is white with lots of bones, somewhat comparable to that of tilapia. Common carp flesh is darker and more strongly flavored.

Selection and storage
Carp should be cooked and eaten as soon as possible.

Preparation
If you catch the fish yourself, you'll want to immediately bleed the fish and get it on ice as soon as possible. After skinning and filleting, you'll want to remove the "mud vein", which is a darker and sometimes stronger-tasting strip of flesh running down the center of the fillet. Individually deboning is tedious, and the best way to deal with them is to either grind the flesh or to score it about 0.5–1 cm deep before cooking —the latter method allows hot oil or cooking liquid to penetrate further and soften the bones.

Use
Carp, especially bighead and silver varieties, are popular and widely cultivated in Asia. It also forms the basis of some traditional European dishes like gefilte fish and carp soups. Carp has historically not been popular in the Americas, though efforts to popularize them are ongoing. It is especially well suited to frying, as it holds up well and the hot oil softens the bones.

title: Cookbook:Carp


text:
Rust for the Novice Programmer/Basic Maths Testing Program/String to Number

Converting a String to a Number
So now we have read a String out of the standard input. But we want to convert it into a number. To do this, we use the following function inside i32: The src is the string we are converting into a number. The radix is the base of the number we want to convert to. We only want to use base 10 since that's what people will type in. Also the function returns a Result indicating that this function can fail. We could use .unwrap on the result but this means the program would crash if the user ever typed in anything that couldn't be converted to a number. Instead we want to handle the error properly, and if the user input can't be converted to a number we should ask the user to enter again. Here's what that looks like: Note that we loop while the result is an error, so the unwrap at the end will always be safe. Also we have to clear the buffer between each go. Now let's test this and see how it works! What is 35 - 23? 5 Invalid number, please re-enter: 12 Invalid number, please re-enter: 6 Invalid number, please re-enter: Oh dear. Note that we use Ctrl-C to escape the program when it's in a loop like this. But what's the problem? Why can't it parse the string as a number properly? Well let's add a debug println! statement to see what the value of buffer is right before it gets parsed: println!("buffer: {:?}", buffer); Then when we run it, it prints out: What is 35 - 23? 10 buffer: "10\r\n" Invalid number, please re-enter: What are those characters at the end of the string? Well essentially since we have to press Enter to submit the number, this adds a newline to standard input which is included in the buffer. Another annoying thing is that what the newline is depends on your operating system, generally Windows use "\r\n" while other operating systems use "\n". We want to handle both cases, so we will add a line to replace all of these characters with empty strings, so our function becomes: Now our function works, when we run it we get these results: What is 35 - 23? test Invalid number, please re-enter: 1s3r Invalid number, please re-enter: 10 And the program exits as we expect!

Next: checking whether the user inputted number matches the expected number


text:
Transportation Deployment Casebook/2022/Cuba

Overview
XX

Quantitative Analysis
XX

S-Curve
XX

Mode
XX

Prior to the streetcar
XX

Invention of the mode
XX

Early Market Development
XX

Policy during the birthing stage
XX

Growth
XX

Development
XX


text:
Chess Opening Theory/1. e4/1...e5/2. Nf3/2...Nf6/3. Nc3/3...Bb4/4. Bc4

d65.rd3,rd5


text:
User talk:2A02:A210:99C0:5480:A98E:7369:AFC5:5771

A page you recently created, 4. Bc4, has been moved to Chess Opening Theory/1. e4/1...e5/2. Nf3/2...Nf6/3. Nc3/3...Bb4/4. Bc4 because it should be part of that books. When creating new pages please ensure they are created within an existing book.--ЗAНИA talk 03:10, 13 March 2022 (UTC)


text:
Oberon/ETH Oberon/Tutorial/DataConversion

Data conversion tools

[ Text | Contents | Index | Master index]

Objective
Learn how to exchange ASCII and Unix text files via FTP, e-mail or diskette.

Estimated time: 5 minutes.

Text conversions
Among the files that you might encounter on some FTP sites are Unix ASCII text files which use 0AX where Oberon uses 0DX. The conversion involves changing these LFs to CRs. If you open a text and find that it is shown interspersed with small rectangular boxes (representing the LFs), you can be sure that a Unix ASCII text is involved.

EditTools.OpenUnix fileName | ^ opens a document viewer displaying the named Unix ASCII file converted to Oberon System 3 text.

EditTools.StoreUnix [*] stores the marked Oberon text document as a Unix ASCII file. The file name is taken from the document's name plate. If the command is executed from within a document, the document itself is implied: it must not necessarily be marked and the "*" is not required.

Exercise:

Access "ftp://nuchem.nsrl.rochester.edu/pub/Oberon/B2Project/" and download (in binary) [Get ^] Version.0.4.ascii

then convert it with: EditTools.OpenUnix Version.0.4.ascii ~

which you may now store as an Oberon System 3 text document.

Among the files that you might want to convert are MS DOS ASCII text files which use 0DX 0AX where Oberon uses 0DX. The conversion involves changing the CR/LF pairs to single CRs. If you open a text and find that it is shown with small rectangular boxes (representing the LFs) at the beginning of each line, you can be sure that an MS DOS ASCII text is involved.

EditTools.OpenAscii fileName | ^ opens a document viewer displaying the named MS DOS ASCII file converted to Oberon System 3 text.

EditTools.StoreAscii [*] stores the marked text document as an MS DOS ASCII file. The file name is taken from the document's name plate. If the command is executed from within a document, the document itself is implied: it must not necessarily be marked and the "*" is not required.

You may verify that with the typical and very central _OBERON.INI file, called Registry, used by Oberon for Windows and by MacOberon. But, be careful not to damage this essential file and exercise with a copy of it.

You may easily verify the content of the files with the Hex.Open fileName | ^ command.

Index
E

EditTools.OpenAscii EditTools.OpenUnix EditTools.StoreAscii EditTools.StoreUnix

H

Hex.Open

T

text conversion

Revised, 01 Dec 1996 Installed on 30 05 1997


text:
Chess Opening Theory/1. e4/1...e5/2. Bc4/2...b5

= Bishop's Opening - Sideline 2... b5?!: The Anderssen Counter-Gambit = This ancient move from the romantic era was Adolf Anderssen’s favourite. Black tries to emulate Evan’s Gambit, but White can refute the risky gambit by acting early.

Theory table
.

'''1. e4 e5 2. Bc4 b5?!'''


text:
User:Ontomoly

MGB books network ****

title: User:Ontomoly


text:
User talk:Ontomoly

Discussion bot page *****

title: User talk:Ontomoly


text:
Transportation Deployment Casebook/2022/British Columbia

The streetcar
A streetcar (North American English) is a rail-based passenger transportation system which primarily operates within the public right of way on urban streets. As the precursor to modern light rail systems with longer articulated vehicles and dedicated rights of way, early streetcars were generally single cars that used steel tracks set within the pavement and shared street space with other vehicles.

In North America, an interurban was a type of streetcar system that operated longer distances between urban areas. While they had some differences to streetcars such as multiple carriages and freight carrying capacity, interurbans essentially used the same technology as streetcar systems and operated on tracks within the public right of way of rural roads.

The essential technological characteristics of British Columbia’s streetcars and interurbans are:

 * The railway – a system of steel wheels on steel tracks at a fixed width guided by flanges which minimise the rolling resistance of vehicles and subsequently the effort required to move them ; and
 * Electric traction – a drive system using electric motors powered by a pantograph connected to overhead wires

Although early streetcar systems used horses or steam as propulsion systems, those in British Columbia used electric traction from the outset.

British Columbia
British Columbia is located on Canada’s west coast east of the province of Alberta and between the US states of Alaska to the north and Washington to the South. The province’s geography is dominated by mountainous regions including the Coast Mountains in the west and the Canadian Rocky Mountains taking up most of the interior. Owing to this geography, British Columbia’s population and major settlements are concentrated in the south-west including the capital city of Victoria on the southern tip of Vancouver Island and the relatively flat Lower Mainland region including Metropolitan Vancouver and other smaller cities.

Streetcars and interurbans played an important role in the economic and urban development of British Columbia, enabling fledgling colonial towns to grow beyond walking distance and supporting larger, cheaper homes for workers in growing ‘streetcar suburbs’. Interurbans also played a pivotal role in connecting the settlements of Vancouver and New Westminster (today considered part of Metropolitan Vancouver) with passenger and freight services. Although passenger service between towns and new commuter suburbs was the primary market for the systems, the interurbans in particular were advantageous for farmers to deliver goods to the cities as they were much more efficient than horse-drawn carriage.

Transportation before the streetcar
European settlement across Canada has been historically tied to the development of transportation networks. Although New Westminster was established as the first urban centre in 1859, Vancouver became the most important city as a strategic port with the arrival of the Canadian Pacific Railway in 1886. Prior to the advent of electric streetcars, other cities had used horse-drawn omnibus services and later horse-drawn or in some cases steam powered streetcars as their primary means of local transportation. Montreal and Toronto had horse-drawn streetcars in use since 1861, supplemented by horse-drawn omnibus carriages. As British Columbia’s settlements were barely fledgling frontier towns by the time electric streetcars arrived in 1890, horse-drawn streetcars were never implemented leaving horse-drawn carriage (known as hackney coaches) as the primary means of transportation.

As Vancouver replaced New Westminster as the most important settlement, there was a growing need for transportation of passengers and goods between the two towns, while Vancouver in particular experienced rapid growth as a port city established by the Canadian Pacific Railway, creating a need for new housing for workers within commuting distance.

Invention of the streetcar
Frank J. Sprague, nicknamed the “Father of Electric Traction,” is popularly credited as the inventor of the electric streetcar systems that proliferated in the late 19th century. Although the initial technology for streetcars was already in place in the form of guided steel wheels and steel rails, it was Sprague’s contributions to refining the design of the electric motor, regenerative braking and power supply that enabled the deployment of streetcars powered by electric traction.

Sprague was initially employed by Thomas Edison to pioneer electric lighting, however Sprague became more interested in power and resigned to establish the Sprague Electric Railway & Motor Company in 1884, which was the first two develop a constant-speed non-sparking motor with fixed brushes that could maintain a constant rotation speed under different loads. Sprague also improved the efficiency of these motors by developing a method of regenerating power to the supply system through braking – particularly useful for railways with steep gradients.

The other technology critical to the electric streetcar’s deployment is overhead power supply using wires and a pantograph. Although Sprague improved upon the design and is sometimes credited with their invention, the first trolley poll was developed by Charles Joseph Van Depoele in 1874 and presented at the Toronto Industrial Exhibition in 1885.

Early electric streetcars were first deployed in Alabama, Pennsylvania in 1886 and Nebraska in 1887, however the Richmond Union Passenger Railway was the first large-scale deployment to use Sprague’s innovative designs for electric motors and overhead power. Sprague’s company was bought out by Edison to support production, and within two years there were 110 electric streetcar systems using his equipment across North America, Italy and Germany. Existing horse-drawn streetcars were converted to electric traction in most North American cities, which British Columbia capitalised on the new technology to establish its first systems.

Early market development
Early streetcar and interurban lines in British Columbia addressed distinct market niches. Streetcars arrived early during Vancouver’s development as a port city at the Western terminus of the Canadian Pacific Railway just four years earlier. As the city was experiencing rapid growth, Marchetti’s Constant limited the area available for workers’ housing to roughly 2.5km from the city centre. The faster travel speed of streetcars compared to walking expanded this catchment to 7.5km, allowing for the expansion of the city. In both Vancouver and Victoria, streetcar lines fuelled real estate speculation creating new ‘streetcar suburbs’ with commercial strips and cheap housing for workers.

Interurban lines served a different market niche, as they were originally established to connect existing urban centres such as Vancouver and New Westminster. While serving this existing market of intercity travel with a more attractive experience than the hackney coach, they also served a new and unintended market of freight from farmland along the route. While passenger services were always given priority, farmers quickly learned that electric interurbans with multiple carriages were far more economical for transporting produce to markets than horse-drawn carriages.

Birthing phase
British Columbia’s first streetcars were deployed in 1890 as electric traction systems using Edison and Sprague’s equipment first deployed in 1888 (discussed above). The first system opened in Victoria on the 22nd of February 1890 in Victoria, a 5-mile line with four wooden cars competed by the local National Electric Tramway and Lighting Company Limited. Just four months later, Vancouver’s first streetcar line was opened by the Vancouver Electric Railway and Light Company Limited. The next year in October 1891, the first local streetcar line in New Westminster and an interurban line to Vancouver were opened by the Westminster and Vancouver Tramway Company.

These three companies were commercially owned and operated at a profit and didn’t benefit from any government support besides the discounted rate of $1 per year charged by the City of Vancouver for the use of public streets. There was negligible network expansion for the first few years until all three companies experienced financial difficulty and eventually collapsed before being brought together as the Consolidated Railway and Light Company, which itself went bankrupt in 1895. The networks then re-emerged in 1897 as the British Columbia Electric Railway Company (BCERC) which successfully owned, operated and expanded the streetcar and interurban networks until their eventual closure in the 1950’s.

Separately, the Nelson Electric Tramway Company Limited established a 4-mile streetcar line in 1899 in Nelson, BC, a small town in the Southern Interior of the province.

Growth phase
BCERC was initially hesitant to expand the networks after repeated market failures of its predecessors and government policy ruling out bailouts. The growth of the network began in earnest between 1900 and 1910, lasting until the beginning of the 1920’s. During this period, Victoria’s streetcar network expanded to include 10 streetcar lines and an interurban line to Saanich in the north. Similarly, streetcar and interurban lines expanded into the 1920’s in the Lower Mainland, matching and in some cases preceding the cities’ urban development. The total length of the system jumped in 1905 and 1910 when BCERC leased and electrified existing freight lines from Canadian Pacific to open interurbans to Richmond and Chilliwack. Although written histories discuss expansion of streetcar and interurban lines "into the 1920's", no sources have been found for system expansion beyond the year 1920.

At some point between 1911 and 1914, Nelson’s single streetcar line was extended from 4-miles to 5.5-miles.

Maturity and decline
Streetcars in British Columbia began to reach maturity around 1918 to 1920 in terms of system length, although their popularity and ridership increased into the early 1920's. While urban development continued and demand for transit remained strong, automobiles were becoming more popular and motor buses run by rival companies were beginning to compete with streetcars and interurbans. In 1924, BCERC responded to this market competition by establishing the British Columbia Rapid Transit Company to purchase competing motorised passenger and freight services in the Lower Mainland. While this secured the financial success of the company, in practice it meant the end of investment in streetcars and the beginning of the decline phase. By the 1930’s and in the midst of the Great Depression, streetcar patronaged declined and public opinion faltered as the fleet aged. By the 1940’s and 50’s, BCERC was faced with considerable investment to replace the ageing fleet and track assets so instead decided to launch a 10-year “rails to rubber” transition to convert all streetcar lines to trolleybuses. Vancouver’s last streetcar was removed in 1955, followed by the final interurban in 1958. Incredibly, the birth, growth, maturity and decline of British Columbia’s streetcars took place entirely by commercial enterprise with no government funding or intervention.

Reinventing streetcars
Following the decline of streetcars in the mid-20th century, modern light rail systems have experienced a resurgence in the last two decades. Beginning with Portland, Oregon in 1986, dozens of North American cities have implemented new light rail or streetcar systems in their central areas. Modern streetcar systems are being implemented for very different reasons to their predecessors. While 20th century streetcars expanded accessibility compared with previous modes, modern streetcars often offer little to no travel time or coverage benefits over existing bus services. Instead, they tend to be located in dense urban areas with the goal of supporting urban renewal and creating walkable, attractive cities. These changing drivers indicate a reinvention of streetcars from a primary means of accessibility to an instrument for placemaking and economic development. With that in mind, modern streetcar systems will likely exhibit different characteristics such as service quality, passenger comfort and urban design as opposed to system length and service coverage.

* There is no evidence

Methodology: the life-cycle model
The life-cycle model divides the behaviour of a transport system over time into three phases: birth, growth and maturity. The three phases can be estimated using an S-curve using the three-parameter function:

S(t)= Smax/[1+exp(-b(t-t0)]

where:

 * S(t) is the status measure, (e.g. passenger-km travelled, miles of track)
 * t is time (usually in years),
 * t0 is the inflection time (year in which 1/2 K is achieved),
 * Smax is saturation status level, and
 * b is a coefficient.

As the saturation status level (Smax) of British Columbia’s streetcar networks is not known, a range of values have been tested in a linear regression spreadsheet model with the best value selected based on their t-statistic and R squared values.

For the purpose of this analysis, system lengths in miles of track at various years have been sourced from the McGraw Electric Railway Manual – the red book of American Street Railway Investments. Although it would have been desirable to separate streetcar lines from interurban lines, multiple changes in company structure and inconsistent reporting formats have made it difficult to separate the two with consistent results. Years with missing data have been linearly interpolated, using footnotes to separate interurban lines from urban expansion where possible. Additionally, Vancouver and New Westminster have been analysed as a single system due to reporting changes combining or reallocating system length between the two divisions over time.


text:
User talk:Boris1951zz

Welcome, Boris1951zz!

If you have any questions, you can ask in the assistance reading room or possibly contact me personally.

--ЗAНИA talk 06:49, 14 March 2022 (UTC)

FONT tags...
Hi Can you please stop using HTML font tags in the Postage Meter Catalogs.. There are deprecated and will eventually be removed from both HTML and the mediwaiki backend?

It would also be much appreciated if you could provide a style guide, so that other contributors can know what styles are being used for the Catalogs, to ensure consistency and enable consistent de-lints to be made. ShakespeareFan00 (discuss • contribs) 10:48, 29 November 2023 (UTC)

Something I don't understand...
Why are there two pages with roughly similar content (mostly the lede to PPS-A, but ever so slightly different page-titles?

Being:- United_States_Postage_Meter_Stamp_Catalog/GROUP_PPS_-_Private_Parcel_Service_stamps and United_States_Postage_Meter_Stamp_Catalog/GROUP_PPS_–_Private_Parcel_Service_stamps respectively.

Shouldn't these be merged to a Common title ?

(I'm still considering leaving Wikibooks once concerns are resolved.) ShakespeareFan00 (discuss • contribs) 09:42, 5 June 2024 (UTC)

 * I was not aware of the duplications, the original page is https://en.wikibooks.org/wiki/United_States_Postage_Meter_Stamp_Catalog/GROUP_PPS_%E2%80%93_Private_Parcel_Service_stamps, can the partial page (the first URL) be deleted
 * withour effecting the second ?
 * Thank you Boris1951zz (discuss • contribs) 20:35, 5 June 2024 (UTC)

 * It certainly can be, but you'd need to ask someone with administrator rights, to do so.ShakespeareFan00 (discuss • contribs) 21:57, 5 June 2024 (UTC)

FONT Tags..
FONT tags are like SPAN's, you can't nest wikitext links, tables, images, some types of paragraph break, or indeed anything that generates block-like content within them. font/top and font/end were templates specially written to meet the specific use case and formatting need in those instances. ShakespeareFan00 (discuss • contribs) 19:44, 5 June 2024 (UTC)

FONT tags are deprecated in HTML5 anyway. What would be ideal is the creation as a US Postage Meter Styles template. The template itself would only contain a templatestyles line, with US Postage Meter Styles/styles.css containing CSS classes that could be used across all the Books pages, with the approriate desired formatting set up in a single place, rather than scattered in countless FONT tags. This is the approach that was used on Wikisource, until it because possible to define styles for Index: pages (from the Proofread Page extension). directly. You would then be able to use a much more meaningful  when you need to make a star or letter red., you could also potentially set font-sizes this way as well. If you need more help with this ask other Wikibooks contributors for technical assistance with "TemplateStyles".

Your comments lead me to do a lot of digging to determine if any content had actually gone missing ( I care about that as you clearly also do.). ShakespeareFan00 (discuss • contribs) 19:44, 5 June 2024 (UTC)

 * i admit I was using the formatting from the previous editor, i will work to use the manner you used in some of the corrections that seemed reasonable, however the logic of the orginal formatting is so much more direct than the second way,
 * I also have not found an adequate definition of lint and what the lintbot was trying to detect, and what the connection to whitespace is, also keep in mind that if whitespace is the open space in listings, then some of that can
 * be explained by attempts to maintain a presentable and legible formatting when downloaded in a PDF or print form.
 * Thank you Boris1951zz (discuss • contribs) 20:42, 5 June 2024 (UTC)

title: User talk:Boris1951zz


text:
User talk:193.63.77.112

--Xania talk 11:01, 14 March 2022 (UTC)

Temporary Editing Block
You cannot edit for 3 days due to disruptive editing. You are welcome to contribute constructively when editing privileges are restored. You may appeal this action with a reasonable argument by adding the text below.

--Xania   talk 10:27, 15 March 2022 (UTC)

title: User talk:193.63.77.112


text:
Cookbook:Tortilla

A tortilla is a thin, round, unleavened Latin American flatbread made of corn or wheat. It should not be confused with the Spanish omelet also called tortilla.

Characteristics
All types of tortilla are very thin and flexible enough to be folded and sometimes rolled. Traditional corn tortillas are made entirely from ground nixtamalized corn, although some mass-produced corn tortillas may have wheat added to the dough. Corn tortillas tend to be less flexible but more flavorful than wheat ones. Wheat tortillas are made from wheat flour and water, sometimes incorporating fat or chemical leavening. Flour tortillas tend to be bigger, more absorbent, and more flexible than corn tortillas, but they have less flavor.

Production
Traditional corn tortilla dough is made by boiling dried corn kernels with limewater (calcium hydroxide). The softened cooked corn is then ground to make a dough called masa. Wheat tortilla dough is made by kneading together wheat flour, water, and salt, with the option of including fat or baking powder.

Both kinds of dough can then be shaped and flattened into thin discs, often using a tortilla press. The tortillas are then cooked in a pan or over a griddle or other sheet of hot metal. Mass-produced tortillas may be cooked over a flame using a conveyor belt.

Use
Tortillas have a wide variety of uses. They can be used as utensils to scoop stews or sauces, and fried tortillas are made into tortilla chips (totopos), which are used to scoop a variety of dips. Tortillas can be sandwiched with cheese and fried to make quesadillas, or they can enclose fillings to make tacos, burritos, chalupas, and fajitas. They can also be layered with fillings and baked to make enchiladas.

Recipes

 * Tortilla (Corn)
 * Tortilla (Wheat)
 * Tortilla recipes

title: Cookbook:Tortilla


text:
Chess Opening Theory/1. e4/1...e5/2. Bc4/2...Qg5

= Bishop's Opening - Sideline 2... Qg5? = 2…Qg5? does not have a variation name. It is a very suspicious move with the idea to threaten the White pawn g2.

However, involving the Black queen so early in the opening violates the most basic principles of opening strategy, such as developing before the knights and the bishops as well as castling the king to a safe place.

White must act energetically to punish the Black wrong opening conception. Thus, by playing '''3. Nf3!''', White achieves a significant advantage because the Black queen will be threatened and attacked by the White pieces. Losing precious time, Black will soon get inferior and strategically lost.

Theory table
.

'''1. e4 e5 2. Bc4 Qg5?'''


text:
User talk:122.171.20.167

You cannot edit for 3 days due to disruptive editing. You are welcome to contribute constructively when editing privileges are restored. You may appeal this action with a reasonable argument by adding the text below.

--Xania talk 04:21, 15 March 2022 (UTC)

title: User talk:122.171.20.167


text:
User talk:Olddog55

Welcome, Olddog55!

No News is Good News...

Thanks.

title: User talk:Olddog55


text:
User talk:MahammadRafiAuthor

You cannot edit indefinitely due to disruptive editing. You may appeal this action with a reasonable argument by adding the text below.

title: User talk:MahammadRafiAuthor


text:
Rust for the Novice Programmer/Basic Maths Testing Program/Checking the Numbers

Checking the numbers
Now, we wish to verify whether the number the user inputted is equal to the result of the operator on the two numbers. First, let's calculate the number. To do this, it makes sense to have the two numbers and the operator as part of a struct, since those 3 values are all used together often and it is convenient to have them all together so we can define functions on the struct for cleaner code. Let's define the struct like so: struct MathsQuestion { left: i32, right: i32, operator: Operator, } Often with structs, it is convenient to define a new function that makes it convenient to construct the struct. We can do this like so: impl MathsQuestion { fn new(left: i32, right: i32, operator: Operator) -> MathsQuestion { MathsQuestion { left, right, operator, }    } } Note that since the names of the variables are the same as the names of the fields in the struct, we don't need to write out left: left, right: right, operator: operator, This is a nice convenience. Also we are using implicit return with no semicolon, so we don't need to write return.

Now we can change our print_question function to be a method on this new struct, so we add the following function inside the impl MathsQuestion {} block: fn print(&self) { println!("What is {} {} {}?", self.left, self.operator, self.right); } Now we can write a function on the MathsQuestion struct to calculate the result, this function is again inside the impl MathsQuestion {} block: fn calc_result(&self) -> i32 { match self.operator { Operator::Addition => self.left + self.right, Operator::Subtraction => self.left - self.right, } }

And now we can change our main function to: fn main { let question = MathsQuestion::new(35, 23, Operator::Subtraction); question.print; let val = wait_for_input; let result = question.calc_result; if val == result { println!("You got it correct! Well done!"); } else { println!("Incorrect! The correct answer was {}", result); } } And now it works! If we enter 12(which is 35 - 23) we get the correct message, if we enter any other number we get the incorrect message!

Next: We make the generated numbers random using external crates


text:
Rust for the Novice Programmer/Basic Maths Testing Program/Randomness and External crates

Randomness and External Crates
It makes no sense to just ask the same question over and over again, so what we want to do is randomise the numbers and the operator that the user has to calculate the result of. However, we have an issue since generating random numbers isn't in the standard library. This means we have to use an external library to get what we want, this has some advantages and disadvantages:

Advantages

 * More options, could find a library that has the right trade-off between simplicity/configurability/performance/integrability that you want.
 * Often less conservative about making changes so more likely to take risks and experiment.
 * Does more opinionated things about more specific operations.

Disadvantages

 * Code isn't as rigorously checked, so is more likely(but not always) to be less secure, less performant, less consistent.
 * Code will most likely be much less well documented so it can be harder to find what you want.

These are just guidelines and there definitely are exceptional community made libraries but you should take care. Also libraries in Rust are called crates; the pun is that we are using cargo to ship crates :p. For our project, we are going to use the fastrand crate since it is very simple and fast and we don't need the bells and whistles of other crates. To do this, we open our project folder and open the 'Cargo.toml' file in a text editor. Inside you will see this: [package] name = "maths-problems" version = "0.1.0" edition = "2021"

 * 1) See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies] What we want to do is add under the [dependencies] line a new line that says fastrand = "1.7" Different crates have different versions so it is always good to specify what version of the crate we want to avoid confusion. Now if we run using cargo, we can see it will take a bit longer to compile since it has to download and compile the fastrand crate and all the crates it uses. It will still run the same since we haven't used fastrand for anything yet.

Using it is dead easy though, let's add a function that creates a random maths question: //inside impl MathsQuestion fn new_random -> MathsQuestion { let left = fastrand::i32(-50..=50); let right = fastrand::i32(-50..=50); let operator = if fastrand::bool { Operator::Addition } else { Operator::Subtraction };    MathsQuestion::new(left, right, operator) } We use ranges to get the values for the fastrand::i32 function, between -50 and 50 inclusive. fastrand::bool just returns a boolean with equal odds. Now we can use this in our main function to generate the question: let question = MathsQuestion::new_random; And now when we run it, we get random questions as we want!

Next: Full annotated source code and possible extensions