OpenLLM-France/wikimedia huggingface dataset:
# Non-nerd's Guide to Computers/basic components
## What's in a Computer?

Ask a pedant, or nerd (most are both) what the 'computer' is, and they will reply 'the Central Processing Unit' (CPU) - and the rest of the machine is considered 'peripheral'. However, as a lowest common denominator, every computer contains half a dozen essential components (plus a few more to enhance and add new functionality). Take one of those away, and the machine simply won't turn on (or if it does, you won't get very far with it).
Here's a quick list of what you absolutely need:
* The motherboard (or 'mainboard') - the core component onto which all other components and peripherals connect;
* The hard drive (or 'hard disk') - on which the computer's data, operating system (Windows, Mac OS X or Linux) and your personal files are stored;
* The RAM (Random Access Memory) - the computer's temporary storage; this is where the computer 'parks' data whilst it's working with it;
* The CPU (or Central Processing Unit, aka the 'Processor') - the brain of the computer, usually obscured by a large fan and heatsink as they generate a lot of heat during operation;
* The video card (or 'graphics card') - this creates all the graphics you see on-screen, be it a spreadsheet, this WikiBook, a game or a film;
* The sound card - this outputs every sound you hear from your computer, as well as 'digitising' incoming sounds from a microphone;
* The optical drive (DVD, Blu-Ray etc) and various other 'peripherals' like memory card readers and any specialist equipment like TV cards;
* The power supply - the substation providing continuous, regulated power to every component inside your computer; and
* The connecting cables - most computers contain several dozen power, data and monitoring cables, all colour coded and with specific connectors to avoid inadvertent misconnections.
This Book could go on and on listing every connector and screw (and there are many hundreds of permutations of memory, processors, hard drives and motherboards – it is not 'one size fits all') but these are the fundamental components of any working computer. We'll discuss these parts, one by one, in the following subsections, starting with the very first part: the motherboard.
# Non-nerd's Guide to Computers/motherboard
## The Motherboard: From Whence All Connections Came

What exactly IS a motherboard? Let's take a quick example through a figure of speech. Think about mail service. Who delivers and picks up the mail? The mail carrier of course! He or she is given mail and drives around putting someone's mail in its appropriate mailbox, allowing people to communicate, and picks up mail already in the mailbox. The mail carrier is the equivalent of a motherboard. The motherboard is basically a mail carrier which allows all the components of a computer to communicate through exchanging data. The motherboard directs all this data, sending it to the appropriate places to be taken care of. Without a motherboard, computers would be lost, sending letters without an address. Since there is no way for each component to discern where data goes, it would be a mess and would not work.
# Non-nerd's Guide to Computers
## Table of Contents

* About This Wikibook (aug 24 2011)
* What is a Computer? (aug 24 2011)
* The Essential Components (aug 24 2011)
** The Motherboard (From Whence All Connections Came) (aug 24 2011)
** The Hard Drive (Talkin' 'Bout a Revolution) (aug 24 2011)
** The CPU (At the Heart of the Process) (aug 24 2011)
* Operating Systems (aug 24 2011)
** GNU/Linux, and all its variants (aug 24 2011)
** Windows (aug 24 2011)
** Apple Mac OS (aug 24 2011)
** Mobile OSes (aug 24 2011)
* Appendices (aug 24 2011)
* Further Reading (aug 24 2011)
* Thanks (aug 24 2011)
# Non-nerd's Guide to Computers/definition
## What is a Computer?

If you are not reading this from printed paper, you will – without a shadow of a doubt – be using a computer (most likely taking the form of a desktop, laptop or portable mobile device) to read this WikiBook. Pretty much everything around you that's mechanical is a computer. You may say, "No way! My old wooden grandfather clock is not a computer," but you would be wrong — computers are 'general purpose machines that process data according to a set of (temporarily or permanently) internally stored instructions.'
A computer (or computing device) is, fundamentally, 'a programmable general purpose electronic device capable of performing multiple functions.' Or, in non-nerd terms, 'anything that performs defined functions automatically according to instructions it has already been given.'
So, that clock is indeed a computer: its 'set of instructions' is its internal timekeeping mechanism, cogs, springs, weights and all. The fact that its program happens to be one which is predictable in its expected output makes no difference (the gradual rotation of the hands around the clock face every twenty-four hours, or the fact that it self-regulates its output – the hands' movement – to once per second).
Whilst the example of a clock may be more reminiscent of the very first computer (Charles Babbage's Difference Engine) the concepts employed are identical. Practically anything electromechanical could be considered a 'computer'.

## This Book's definition of a Computer

When most people talk about 'computers', they are implicitly referring to Personal Computers (PCs) - those wondrous devices that allow us to communicate, read, write and learn with the help of about a dozen common components all working harmoniously to send, receive, process and display information of every type imaginable. For consistency, whenever this Book mentions a 'computer', it is referring to a Personal Computer (to avoid any confusion possibly arising from the more specialist 'computing systems' or 'computational devices'.)
But what's in a computer? Read on to find out...

### See also

For those requiring rather more information - Computer Hardware
basic components →
# Non-nerd's Guide to Computers/hd
## The Hard Drive (Talkin' 'Bout a Revolution)

The Hard Drive is the storage for your computer. In robot stories, the robot stores things in its "Memory Bank" which would probably be a hard drive. You can think of it as a filing cabinet, with files, programs, and other information. Hard drives are measured by the amount of bytes they can hold. A byte is equivalent to one character. If you need to store more data, there are external hard drives that plug into your computer, or are remotely accessible. For example, flash drives (sometimes referred to as thumb drives) plug into a computer’s USB port and can store data like pictures or music. This type of storage is small and portable, making it ideal for people who need to access the same information on different computers. Remote storage is another option for those who need to store data somewhere other than a hard drive. Cloud storage is a form of remote storage where users store information online using a website. Most cloud storage sources are password protected, which offers a level of security that doesn’t come with a flash drive.
# Managing Groups and Teams/Noted Contributors

Eric Dolan, UC Davis MBA program
Brian Gyoerkoe, UC Davis MBA program
Brandon Meredith, UC Davis MBA program
Paul Nasman, UC Davis MBA program
# Managing Groups and Teams/Introduction
## Foreword

It is often remarked that groups are everywhere, whether in our social lives, our work lives, or even our families. In each of these situations, sets of individuals decide to work collectively to achieve particular goals.
However, although groups are everywhere and we participate in them constantly, we do not understand them very well. Many of us can tell stories of groups that seemed perfect for a given task, but which failed. And we all have reasons (or excuses) that explain such failures.
But our experiences in groups suffer precisely because we are with them.
The study of groups as a phenomenon that is unique and different from other social phenomena is very active, reflecting both the importance it has and how much we still don't know about groups. S M Rizwsan Clinical Psychologist ANF

## About this Book

In this book, we take a challenge-based approach to dealing with groups. Many other books provide conceptual and descriptive treatments of groups and teams. Here we will take a prescriptive perspective, one that focuses on the "how to" of managing a group or a team. This prescriptive perspective, however, will be rooted in social science.

## About Wikibooks and Wikimedia

* Wikibooks, a Wikipedia article about Wikibooks and its history.
* Wikimedia Foundation, a Wikipedia article about the non-profit parent organization of Wikibooks.
* Frequently asked questions about Wikibooks.
Communication →
# Thread-safe Copy-on-write
### Intent

Allow objects to be quickly accessed in a concurrent safe manner without necessary copying, preferably without locks.

### Motivation

Many applications allow for configuration changes in runtime but concurrently applying changes to the system requires fast synchronization primitives. Ubiquitous mutual exclusion that might block the executing thread is not a viable solution for latency sensitive applications like game engines. This idiom is an alternative to popular mutual exclusion in situation where reads are common and writes are rare. The reading path is fast and never blocks but incremental writes might require mutual exclusion.

### Details

This implementation relies on a fact that library folly provides lock free atomic shared pointer. Not all libraries provide lock free smart pointer, even if atomic specialization is available. Namely c++ standard library does not provide lock free atomic pointers. Following code would not evaluate to true.

### References

* ↑ Timour, Doumler. "A Lock-free Atomic shared_ptr ACCU 2022" (PDF).
* wikipedia:Copy-on-write
# Type Erasure
### Intent

To provide a type-neutral container that interfaces a variety of concrete types.

### Also Known As

"Variant" (not to be confused with std::variant). This technique is used inside std::any and std::function.

### Motivation

It is often useful to have a variable which can contain more than one type. Type Erasure is a technique to represent a variety of concrete types through a single generic interface.

### Implementation and Example

Type Erasure is achieved in C++ by encapsulating a concrete implementation in a generic wrapper and providing virtual accessor methods to the concrete implementation via a generic interface.
The key components in this example interface are var, inner_base and inner classes:
The var class holds a pointer to the inner_base class. Concrete implementations on inner (such as inner<int> or inner<std::string>) inherit from inner_base. The var representation will access the concrete implementations through the generic inner_base interface. To hold arbitrary types of data a little more scaffolding is needed:
The utility of an erased type is to assign multiple typed values to it so an assignment operator achieves just that:
Creating an erased type and assigning it various values isn't of much use unless you can interrogate it. One useful method is to query for the underlying type info:
Here the var class forwards calls of Type to it's inner_base interface which is overridden by the concrete inner<_Ty> subclass which ultimately returns the underlying type. This technique of forwarding accessor methods to a virtual interface which is overridden by concrete implementations is expanded for a fully useful generic type.
# Virtual Constructor
### Intent

To create a copy of an object or a new object without knowing its concrete type.

### Also Known As

Factory Method of initialization

### Motivation

Uses of calling member functions in a class hierarchy polymorphically are well known in the object-oriented programming community. It is a way of implementing the is-a (or more practically, behaves-as-a) relationship. Sometimes it is useful to call life-cycle management (creation, copy, and destruction) functions of a class hierarchy polymorphically.
C++ natively supports polymorphic destruction of objects using a virtual destructor. An equivalent support for creation and copying of objects is missing. In C++, creation of object(s) always requires its type to be known at compile-time. The Virtual Constructor idiom allows polymorphic creation of and copying of objects in C++.

### Solution and Sample Code

The effect of a virtual constructor by a create member function for creation and a clone member function for copy construction as shown below.
The Manager class implements the two pure virtual functions and uses the type name (Manager) to create them. The function duplicate shows how virtual constructor idiom is used. It does not really know what it is duplicating. It only knows that it is cloning an Employee. The responsibility of creating the right instance is delegated to the derived classes. The duplicate function is therefore closed for modifications even though the class hierarchy rooted at Employee gets more sub-classes added in the future.
The return type of the clone and create member functions of the Manager class is not Employee but the class itself. C++ allows this flexibility in types where the return type of the over-ridden function can be a derived type of that of the function in the base class. This language feature is known as co-variant return types.
To handle resource ownership properly, the Resource Return idiom should be employed for the return types of clone and create functions as they are factory functions. If used, the return types (shared_ptr<Employee> and shared_ptr<Manager>) are no longer covariant return types and program should fail to compile. In such a case, the virtual constructor functions in the derived class should return the exact type as in the parent class.

### Known Uses

std::function

### Related Idioms

* Resource Return
* Polymorphic Exception

### References

* Virtual Constructor
# Virtual Friend Function
### Intent

Simulate a virtual friend function.

### Motivation

Friend functions are often needed in C++. A canonical example is that of types that can be printed to output streams (e.g., std::cout). An overloaded left-shift operator function, which is often a friend, is needed to achieve seamless streaming capabilities. Friend functions are really an extension of the class's interface. However, friend functions in C++ can not be declared virtual and therefore no dynamic binding of friend functions is possible. Applying a friend function to an entire hierarchy of classes becomes awkward if an overloaded friend function is needed for every class in the hierarchy. This lack of support for dynamic binding makes it hard to justify that friend functions are in fact an extension of the class's interface. Virtual friend function idiom addresses this concern elegantly.

### Solution and Sample Code

Virtual friend function idiom makes use of an extra indirection to achieve the desired effect of dynamic binding for friend functions. In this idiom, usually there is only one function that is a friend of the base class of the hierarchy and the friend function simply delegates the work to a helper member function that is virtual. The helper function is overridden in every derived class, which does the real job and the friend function just serves as a facade.

### References

* Virtual friend function idiom, Marshall Cline
# Traits
### Intent

To be able to use a common interface to get information about a type, even when the type cannot be changed to conform to any common interface.

### Motivation

A function template might need to behave differently for different types based on information about those types. If only user-defined types can have members and member types that encode information about the enclosing type, then there will need to be a lot of special cases for builtin types like integers and pointers. By using a separate traits class with a primary specialization for types that can be modified to include certain members and specializations for types that cannot, functions can still use a common interface by using the traits class.

### Solution and Sample Code

All traits classes have zero size and only include static members or subtypes. The primary specialization usually gets the values or types from members of the class whose traits are gotten. (In the below example, the member types come from base classes.) The specializations get the values or types from other means in such a way that the interface remains consistent. The cool thing about traits is that they are non-intrusive. This allows them to be applied to built-in types, like the specialization of container_traits for arrays below. This also allows retroactive modeling.

### Known Uses

* std::allocator_traits
* std::iterator_traits
* std::pointer_traits
* std::numeric_limits
* std::common_type
* std::basic_common_reference

### Related Idioms

* Type Generator

### References

* Traits
* Introduction to Traits
* GENERIC<PROGRAMMING> Traits: The else-if-then of Types
# Type Selection
### Intent

Select a type at compile-time based on a compile-time boolean value or a predicate.

### Motivation

Ability to take decisions based on the information known at compile-time is a powerful meta-programming tool. One of the possible decisions to be made at compile-time is deciding a type i.e., the choice of the type may vary depending upon the result of a predicate.
For example, consider a Queue abstract data-type (ADT) implemented as a class template that holds a static array of Ts and the maximum capacity of the Queue is passed as a template parameter. The Queue class also needs to store the number of elements present in it, starting from zero. A possible optimization for such a queue class could be to use different types to store the size. For instance, when Queue's maximum capacity is less than 256, unsigned char can be used and if the capacity is less than 65,536, unsigned short can be used to store the size. For larger queues, unsigned integer is used. Type selection idiom can be used to implement such compile-time decision making.

### Solution and Sample Code

A simple way of implementing the type selection idiom is the IF template. IF template takes three parameters. The first parameter is a compile-time boolean condition. If the boolean condition evaluates to true the 2nd type passed to the IF template is chosen otherwise third. Type selection idiom consists of a primary template and a partial specialization as shown below.
We now use the type selection idiom to implement the Queue size optimization mentioned above.
The Queue class template declares an array or Ts. The type of the size data member depends on the result of two comparisons performed using the IF template. Note that these comparisons are not performed at run-time but at compile-time.

### Known Uses

* Boost.MPL Library
* std::conditional

### Related Idioms

* Tag Dispatching
# More C++ Idioms/Web Analytics
### Page Views

Cumulative page views of all the idioms from mid Feb to mid May in year 2012.
Idioms by popularity

### Data Source

Wikipedia article traffic statistics
A python script to create a .csv file from the Wikipedia article traffic statistics.
# Lua Functional Programming

This book is about the Lua programming language, inspired by and based on Paul Graham's work On Lisp. You should be familiar with the Lua language. Familiarity with the Lisp language is recommended but not required (I'm not too familiar with it myself but I've read introductory tutorials before and On Lisp does a pretty good job of explaining in English what the code snippets do).
On Lisp is an advanced Lisp tutorial showing the reader Lisp programming best practices. Lisp is a language suited for functional programming.
The purpose of this book is to investigate whether Lua can be used for similar functional programming tasks as Lisp, and whether Lua might actually be a "better" Lisp. To do that I've attempted to duplicate (in Lua) all the code snippets featured in On Lisp, among other things.
The chapters here have a one-to-one correspondence with On Lisp, wherever possible.
On the side note, the Lua Programming language is used in the creations of add-ons for the ever popular MMORPG World of Warcraft.

## The Book

* Introduction
* Arithmetic
* Assignment
* Functions

## References

* Programming in Lua

## See also

* Images with Lua source code
# Lua Programming/A simple card game

A simple card Game.
When I was a lad, I'd copy acres of code from printed books to enter text games I could then play. The BASIC language was an OK start, but I'm struck at how messy it can get with all those GOTO statements. I re-wrote a simple game called ACEY DEUCY in lua trying to avoid the temptation to refactor too brutally.
There are lots of improvements you could make - why not have a try at making it better - or add graphics using Turtle or...
Any way - here 'tis:
# Lua Functional Programming/Functions

In Lua, as in Lisp, functions are a kind of data type; you can assign them to variables and pass them around in your code.

## Defining Functions

Functions can be defined in the "ordinary" way, and we can call them.
We can access the function object created simply by using its name without any parentheses. Thus we can pass the function as an argument, store it in a data structure, etc.
So-called lambda expressions or anonymous inline functions can also be created in Lua. They are similar to the "ordinary" functions described above in almost every way.
Note that functions and other variables share the same namespace in Lua (and in most other languages), unlike Lisp. In fact, in Lua, a function is just another kind of data you can store in a variable.

## Functional Arguments

Function objects can be passed to other functions as arguments. To invoke an argument as a function, just append the parenthesised list that you want to invoke it with. Using the double function defined earlier, we can do things like
The "canonical" example of a function that takes another function as a parameter is map. Unfortunately map does not come with Lua, so we'll have to code it ourselves.
This is a simple map implementation that only works with one array. But it works well:
A more complex map implementation that works with more than one array is possible:
And let's use it:
Sort is built-in, though, and we can pass a sorting function if we want.
On Lisp provides an example of a remove-if implementation in Lisp. Remove-if is not built-in into Lua, so we might as well code a Lua implementation which is equivalent to the Lisp code below.
Compare with the following Lisp code:
Both the Lua and Lisp code above are tail-recursive safe (see Tail Recursion below). (Most implementations for both languages support tail-recursion optimising.) Just for comparison, here's how I would code a "pure" Lua version:
In Lua, we have to define the helper functions cdr and cons which is built-in into Lisp, but using the remove_if is quite easy:
# Lua Programming/Features
## Features of Lua

The features of the lua programming language include:
* simple
* efficient
* portable
* extensible
* adaptable to a broad range of applications
* Lua is an extension programming language
* Suitable for use as an embedded language within a host application
* Cross Platform Support
* Implemented in ANSI C
* Lightweight core occupies just 60k and executable footprint of just 140k
* Easy to use conventional scripting language
* Dynamic datatypes
* Powerful builtin support for text processing
* Interpreted bytecode compilation for fast and efficient execution
* Stack based virtual machine model
* Support for procedural, object oriented, functional and datadriven programming
* Supports coercion
* freeform syntax
* lettercase sensitive
* keywords