OpenLLM-France/wikimedia huggingface dataset:
# XQuery/Timing Fibonacci algorithms
## Fibonacci algorithms

Fibonacci is the computer science 'hello world'. A recursive function which follows the definition of the Fibonacci series looks pretty much the same in every language. Here is the XQuery version:
The empty sequence is used here as a return when the function is undefined so the return type is an optional integer. Top-down, goal-oriented, close to the mathematical definition but requiring repeated re-evaluations of intermediate values. So how about bottom-up, starting with the known and working up to the goal?
with a 'front-door' function to get started:
Iterative solutions in which variables are updated look rather messy by comparison with this tail-recursive formulation, a style essential to many algorithms in XQuery.

## Timing

Just how much worse is the recursive formulation? We need to time the calls, and now we really could do with those higher order functions so we can pass either fib function to a timer function to execute. Step in eXists function modules. These raise XQuery from an XML query language to a viable web application platform. The util module provides two functions:
so we can create the recursive function template with:
The timer function takes a function, a sequence of the parameters to be passed to the function and a repetition number. The timing is based on system time and the time difference converted to seconds and then to milliseconds:
and call it as

## An intermediate data structure

Calling the timer with n ranging from 1 to max will generate the required data. Rather than simply outputting this data, we need an intermediate XML data structure containing the results. This can then be transformed into different representation or analysed later, to fit a curve to the data perhaps or export to a spreadsheet.

## Results as a table

This data structure can be transformed to a table, iterating over the tuples.
Here the XPath name function is used to convert from the tag names to strings. This reflection allows very generic functions to be written and is a key technique for making the transition from problem-specific structures to generic functions. Note that the dataset has not been typed. This is because the function is written with minimal requirements of the structure which would require a permissive schema language to express.

## Results as a graph

For graphing, this basic matrix could be imported directly into Excel, or, thanks to the wonderful GoogleCharts, to a simple line graph. Selected columns of the dataset are extracted and joined with commas, then all datasets joined with pipes.

## The final script

Finally, adding some intro, some page layout and CSS , the final script looks like:
# XQuery/Timing a Query
## Motivation

You want to time how long it takes for a query to run.

## Method

We will bookend the query with two instances of the util:system-time function.

## Example

Our sample query that we want to time is as follows:
To time this query, we will insert util:system-time on either end of the query:
The results of this query will be something like:
This value is expressed in seconds.

## Discussion & Other Approaches

Another approach to timing queries, using higher order functions, is discussed in the article on Timing Fibonacci algorithms.
Also, eXist supports an XQuery pragma for timing queries, which logs the time required to complete a query.
(Explain why util:system-time is necessary and fn:current-time won't work in this example.)
# XQuery/Transformation Styles
## Motivation

You have documents that you want to transform from one format to another. You would like to know what approach works best for your situation.

## Methods

There are several different methods or styles of transformation that you can use to convert documents from one format to another. Each method has its strengths or weakness based on the type of data that you are going to transform.
* Template Method
* Filters Method
* Typeswitch Method
* XSLT Method
* Combination of Methods

### Template Method

This method is similar to the "split" functions we used to split a large file into multiple smaller files. The general idea is to create a new in-line template and fill in the values from the old document by specifying path references to the old document values.
For example:

### Filters Method

This method uses a series of "node filters" that use recursion on each node of a document. The node filter approach is ideal if you are only making a few changes, such as renaming a few elements, adding a few elements or inserting a few new attributes.
The following article covers node filters: XQuery/Filtering_Nodes

### Typeswitch Method

This method is ideal if you have a set of rules for transforming each element to one or more other elements. It is a bit more complex since each element can have its own transformation rule. For large documents that have a consistent but nested structure it is the most general purpose and the most similar to anyone that has use template matching rules in XSLT transforms.

### XSLT Method

If you have an existing XSLT transform you can also use this in your transformation system. The problem with XSLT is that it does not use the eXist indexing system and transforms on large documents can be very slow. XSLT programs also must be carefully set up to include the correct import statements which can get very complex within an XML database. There are also few open source XSLT 2.0 software systems that support extensions such as math functions.

### Combination Method

If you have many transforms you can use combinations of methods. Large systems frequently use a base typeswitch library and then add customization using filters.
# XQuery/Tree View
## Motivation

You want a general purpose function that creates a tabular view of hierarchical data.

## Method

We will write a recursive function to display each node and then to display each child in an HTML table.
Some systems call this a "Grid View" of XML data.

## element-to-nested-table function

The following function generates an HTML table with nested subtables for the child nodes.
Note that the rows displaying different kinds of items (text, attribute,element) are classed so that they may be styled.

## Document display

This function can be used in a script to provide a viewer for any XML document.
e.g.
* UWE's news feed
* Whisky data
* Employee data
* Met Office shipping Forecast mal-formed XML
# XQuery/URL Driven Authorization
## Motivation

You want to check to see if a user is logged in before a page is rendered.

## Method

This example will use a custom controller.xql file to do this.
Sample controller.xql file:
# X Window Programming/Resources
## Resources

* Xorg Foundation Official Website (http://www.x.org)
* X Window FAQs (http://www.faqs.org/faqs/x-faq/)
* X Window Wikipedia entry (http://en.wikipedia.org/wiki/X_Window_System)
* XLib Programming Manual, Published by O'Reilly & Associates, Inc. (http://www.sbin.org/doc/Xlib/)
* XLib Functions Manual (http://tronche.com/gui/x/xlib/function-index.html)
* GTK+ References (http://www.gtk.org/api/)
* GTK+ Tutorial (http://www.gtk.org/tutorial/)
* XCB wiki (http://xcb.freedesktop.org/)
* XCB API reference (http://xcb.freedesktop.org/XcbApi)
* XCB Further publications (http://xcb.freedesktop.org/Publications)
* SDL website (http://www.libsdl.org)
* SDL.NET homepage (http://cs-sdl.sourceforge.net)
* The Game Programming Wiki's SDL Tutorials (http://gpwiki.org/index.php/SDL_tutorials)
* SDL Documentation (http://www.libsdl.org/cgi/docwiki.cgi/FrontPage)
* Site dedicated to SDL. SDL forum (http://gamescreators.sourceforge.net/)
* Official OpenGL Website (http://www.opengl.org)
* SGI's OpenGL website (http://www.sgi.com/products/software/opengl/)
* OpenGL at Curlie

### Further reading

* Richard S. Wright Jr. and Benjamin Lipchak: OpenGL Superbible, Third Edition, Sams Publishing, 2005, ISBN 0-672-32601-9
* Astle, Dave and Hawkins, Kevin: Beginning OpenGL Game Programming, Course Technology PTR, ISBN 1-59200-369-9
* Fosner, Ron: OpenGL Programming for Windows 95 and Windows NT, Addison Wesley, ISBN 0-201-40709-4
* Kilgard, Mark: OpenGL for the X Window System, Addison-Wesley, ISBN 0-201-48359-9
* Lengyel, Eric: The OpenGL Extensions Guide, Charles River Media, ISBN 1-58450-294-0
* OpenGL Architecture Review Board, et al: OpenGL Reference Manual: The Official Reference Document to OpenGL, Version 1.4, Addison-Wesley, ISBN 0-321-17383-X
* OpenGL Architecture Review Board, et al: OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 2, Fifth Edition, Addison-Wesley, ISBN 0-321-33573-2
* Rost, Randi J.: OpenGL Shading Language, Addison-Wesley, ISBN 0-321-19789-5
# X Window Programming/XCB
## Introduction

XCB (X C Binding) is a C language binding for the X Window System. It aims to replace XLib. The project was started in 2001 by Bart Massey.
Xlib/XCB provides application binary interface compatibility with both Xlib and XCB, providing an incremental porting path.

### Aims of XCB

The main aims of XCB are:
* reduction in library size and complexity;
* direct access to the X11 protocol.
Secondary aims include making the C interface asynchronous, facilitating better multithreading and making extensions easier to implement (via XML protocol descriptions).
The core and extension protocol descriptions are in XML, with the C bindings created via XSLT. A tertiary aim is to repurpose these protocol descriptions for the creation of protocol documentation, further language bindings, and server-side stubs.
Massey has worked to prove XCB formally correct, using Z notation. (Xlib has long been known to contain errors.)

### Example
## Old Example

XCB has a comparable, but slightly lower-level API than XLib, as can be seen with these examples.

### References

* XCB: An X Protocol C Binding (Bart Massey and Jamey Sharp, 19 September 2001, presented at XFree86 Technical Conference 2001)
* XCL: An Xlib Compatibility Layer For XCB (Jamey Sharp and Bart Massey, 15 April 2002, presented at USENIX 2002)
* X Meets Z: Verifying Correctness In The Presence Of POSIX Threads (Bart Massey and Robert Bauer, 15 April 2002, presented at USENIX 2002)
# X Window Programming/XLib/Library Conventions
### Library Conventions

Xlib follows a number of conventions to make it easier to use and remember.
The major conventions are:
* To differentiate the X symbols from the other symbols, the library uses mixed case for external symbol names. It leaves lowercase for variables and all uppercase for user macros, as per existing convention.
* All Xlib functions, user-visible data structures, and anything that a user might dereference begins with a capital X.
* Macros and other symbols do not begin with a capital X. To distinguish them from all user symbols, each word in the macro is capitalized.
* The beginnings of all function names and symbols are capitalized.
* All elements of a data structure are in lowercase. Compound words, where needed, are constructed with underscores (_).
* The display argument, where used, is always first in the argument list.
* All resource objects, where used, occur at the beginning of the argument list immediately after the display argument.
* When a graphics context is present together with another type of resource (most commonly, a drawable), the graphics context occurs in the argument list after the other resource. Drawables outrank all other resources.
* Source arguments always precede the destination arguments in the argument list.
* The x argument always precedes the y argument in the argument list, and the width argument always precedes the height argument in the argument list.
* Where the x, y, width, and height arguments are used together, the x and y arguments always precede the width and height arguments.
* Where a mask is accompanied with a structure, the mask always precedes the pointer to the structure in the argument list.
# X Window Programming/SDL
## Introduction

Simple DirectMedia Layer (SDL) is a cross-platform multimedia library written in C that creates an abstraction over various platforms' graphics, sound, and input APIs, allowing a developer to write a computer game or other multimedia application once and run it on many operating systems including GNU/Linux, Microsoft Windows and MacOS X. It manages video, events, digital audio, CD-ROM, sound, threads, shared object loading, networking and timers.

### History

Sam Lantinga created the library, first releasing it in early 1998, while working for Loki Software. He got the idea while porting a Windows application to Macintosh. He then used SDL to port Doom to BeOS. Several other free libraries appeared to work with SDL, such as SMPEG and OpenAL.
The SDL library has bindings with almost every programming language there is, from the popular (C++, Perl, Python (through pygame), Pascal etc.) to the less known (such as Euphoria or Pliant). This and the fact that it is open-source and licensed under the LGPL make SDL a common choice for a lot of multimedia applications.
SDL itself is very simple; it merely acts as a thin, cross-platform wrapper, providing support for 2D pixel operations, sound, file access, event handling, timing, threading, and more. OpenGL is often used with SDL to provide fast 3D rendering. It is often thought of as a cross-platform DirectX, although it lacks some of its more advanced functionality. SDL instead has a huge number of third party extensions that make it easy to do more advanced functions.
The library is divided into several subsystems, namely the Video (handles both surface functions and OpenGL), Audio, CD-ROM, Joystick and Timer subsystems. Besides this basic, low-level support, there also are a few SDL-dependent libraries that provide some additional functionality. These include SDL_image (provides an easy way to load today's most common image formats), SDL_mixer (complex audio functions, mainly for sound mixing), SDL_net (networking support), SDL_ttf (TrueType Font rendering support), SDL_gfx (some additional graphical functions, such as image resizing and rotating) and SDL_rtf (simple Rich Text Format rendering).

### Example C Code

A very basic SDL program. It loads SDL subsystems, pauses for 2 seconds, closes SDL, then exits the program.
Here is more advanced example :
That is easily compiled and ran under Linux with "gcc `sdl-config --cflags --libs` -O3 mandelbrot.c && ./a.out", on Windows it's the same, but you have to use MinGW to compile it.

### Extensions

* SMPEG - SDL MPEG Player Library
* Guichan and ParaGUI - Widget Sets
* GGI - a free cross-platform graphics interface
# X Window Programming/XLib/Basics
## Display

Display is the input/output hardware set connected to the X Server.
# X Window Programming/Introduction

This book is designed for people interested in learning how to program the X Window System and assumes some basic knowledge on how to use a computer, how to setup and use The X Window System, how to use a compiler, and how to write a program in the C programming language. This book is open work, so if you find any problems with terms or concepts, you can contribute an explanation to it. Feel free to participate; you are welcome to do so.
The X Window System (or X and X11 for short) is a server application that provides basic functions for displaying graphics and gathering user input transparently, either locally or over a network. X distributes user input to and accepts output requests from applications through the X Window System protocol.
X does not mandate the visual appearance and interface of applications, choosing instead to allow applications to use whatever visual style and interface is desired. As a result, different applications may present radically different interfaces.
# 9-1 Series

The 9-1 Series of wikibook textbooks are unofficial textbooks for various subjects following the British GCSE 9-1 National Curriculum.
The following is a list of all of the 9-1 Series textbooks as well as the specification that they follow.
If you are interested in contributing to this project please message NeutrinoPenguin or add a comment in the discussion section of this page.

## Math Courses

9-1 Mathematics
9-1 Additional Mathematics

## Science Courses

9-1 Physics | 9-1 Computer Science
9-1 Chemistry
9-1 Biology

## English Courses

9-1 English Literature
9-1 English Language

## Humanities Courses

9-1 Geography
9-1 History
# 99 Elm Problems/Learning Track
## Problem presentation

Each step of the Learning Track will have links to problems in order from simple to complex. This will often not be in numerical order. A link is provided to each problem page which has:
* The problem statement: Describes problem, and ask you to implement a solution.
* An example: Presents a example of the function with input and the correct result.
* A unit test: A complete program that executes multiple tests of problem solution. You can use this program on the Elm online editor, http://elm-lang.org/try. The stubbed-out function you need to implement will be at the top, just below the imports.
* Hints: Suggests one or more ways to implement a solution.
* Solutions: Links to a page with one or more solutions.

## Learning from the problems

Copy the unit test into the Elm online editor, http:/elm-lang.org/try, or in the debugger-enabled http://debug.elm-lang.org/try. Find the stubbed-out functions with comment -- your implementation goes here. Attempt to implement the function. You may want or to write helper functions to complete your solutions.
Click “Compile” to test your code. If your solution is correct you will be rewarded with the message “Your implementation passed all tests”. If tests fail, examine which tests failed and try again.
We learn best by doing, so before checking the hints or the solutions page, attempt to solve the problem yourself. Apply what you learned from the previous problems to solve the later problems. Then check the hints and see if that doesn’t inspire other solutions or improvements to your own. Finally, check the solutions page to learn from those examples.
* Step 1: Simple list functions
* Step 2: Passing functions as arguments
* Maybe Just Nothing
* Recursion
* Recursion on Lists
* Recursion on Binary Trees
* Map
* Fold
# 99 Elm Problems/Lists/Problem 1/Find the last element of a list

Find the last element of a list.
Example in Elm:
Result:
Solutions
# 9-1 Physics/Momentum

Momentum is defined by the following equation:
$p=mv$
$p$ momentum (kilograms meters per second, ${\text{kg m/s}}$)
$m$ mass (${\text{kg}}$)
$v$ velocity (${\text{m/s}}$)

## Conservation of momentum

In a closed system, the total momentum before an event is equal to the total momentum after the event. This is known as the conservation of momentum.
Imagine two balls, a red ball and a white ball. The red ball is stationary, so $p=0$. However the white ball is moving. The white ball hits the red ball, causing it to move. The red ball now has momentum and the white ball has less momentum. The combined momentum of both of these objects will be equal to the initial momentum of the white ball.

## Changes in momentum

When a force acts on an object that is moving, or able to move, a change in momentum occurs. The following equations (which you should already be familiar with):
$F=ma$, $a={\dfrac {v-u}{t}}$ can be substituted into each other to give us the formula:
$F={\dfrac {m(v-u)}{t}}$which can be simplified to $F={\dfrac {m\Delta v}{t}}$ where $m\Delta v$ is equal to the change of momentum and the force is equal to the rate of change of momentum.
# 9-1 Science/Scientific thinking
## The Scientific Method

Scientists come up with hypotheses (potential ideas for how something works and why it works). These are then tested and results are collected.

## Scientific investigations

* The variable you change is called the independent variable.
* The variable you measure is called the dependent variable.
* The variables that are kept constant are called control variables.
# A-level Physics/Nuclear and Particle Physics/The Nucleus
## Nucleons

Protons and neutrons are the constituents of atomic nuclei. A proton is a positively charged particle which has the same charge as an electron, but positive. A neutron, on the other hand, is a neutral particle with zero charge. Protons have a mass of 1.6552e-27 kg and a charge of +1.66e-19 Coulombs, while neutrons have a mass of 1.6725e-27 kg. Protons and neutrons collectively are called NUCLEONS. The number of protons in the nucleus give the atomic number, while the sum of the total mass of protons and neutrons gives 99.9% of the mass of the atom, the rest is due to electrons. On the periodic table, you can see the number of nucleon written as the mass number.

## What force holds the atomic nuclei together?

For many years people had wondered what held an atom in place and why it doesn't just split apart due to repulsive electric forces. At first they thought that it was gravity which held the atoms, protons and neutrons in place. This was disproved after they found out gravity was very very weak at nuclear levels. In fact it's a million million million million million million times too small. (10^36) We now know the interaction responsible for binding quarks, anti-quarks, and gluons to make hadrons is called strong nuclear force (SNF) or The Strong Interaction. Residual strong force interactions provide the nuclear binding force. Simply put, strong force is the force that holds atomic nuclei together against the Coulomb (electrostatic repulsion) force of repulsion between protons. The strong force acts on any pair of hadrons. It has an extremely short range of only a few femtometers. Even so, at a very short range indeed, the SNF becomes repulsive, otherwise the neutrons and protons would be attracted together to the point where they would become a singularity.

## The radii of atomic nuclei

The following gives the formula to work out the radii of atomic nuclei. $r=r_{0}A^{\frac {1}{3}}$ Where:
* r is the radii
* A is the number of nucleons
* r0 is a constant having value 1.2 fermi to 1.5fermi.

## Density of nuclear matter

$density={\frac {mass}{volume}}$
$\rho ={\frac {m}{{\frac {4}{3}}(\pi r^{3})}}$ (since ${\frac {4}{3}}(\pi r^{3})$ is the volume of nucleus which is considered as sphere of radius r).NUCLEAR DENSITY is constant throughout the nuclear dimensions.

## Calculating electrostatic force

$F={\frac {1}{4\pi \epsilon _{0}}}{\frac {Q_{1}Q_{2}}{r^{2}}}$ Where:
* F is the force
* $\epsilon _{0}$ is the permittivity of free space with the value 8.8541878176$^{e-12}$ F/m c(farad per metre per coulomb)
above expression is known as a coulomb law of electrostatics.

## Calculating gravitional force

$F=G{\frac {m_{1}m_{2}}{r^{2}}}$
Where:
* F is the force
* m1 and m2 are product of the two masses;
* and r being the distance between them.
* G is the value of the gravitational constant, which is
    $G=6.67\times 10^{-11}\ {\mbox{N}}\ {\mbox{m}}^{2}\ {\mbox{kg}}^{-2}\,$
# A-level Physics/Health Physics/The Eye and Sight

The eye is a complex and remarkable organ responsible for vision in humans and many other animals. Sight, or vision, is the process of perceiving and interpreting light that enters the eye, allowing us to understand the world around us.
Anatomy of the Eye:
The human eye is a globe-like structure with several key components that work together to gather, focus, and process light:
Process of Vision:
Color Vision:
Cones are responsible for color vision and are sensitive to different wavelengths of light. Humans have three types of cones, each sensitive to a different range of wavelengths corresponding to blue, green, and red light. The brain processes the signals from these cones to create the perception of a wide range of colors.
Depth Perception:
The brain uses the slight differences in the images received from both eyes (binocular vision) to perceive depth and distance. This is known as stereopsis.
Overall, the eye and the process of sight are remarkable examples of biological and neural complexity, allowing us to experience the visual world in intricate detail.

## External Resources

* Sensory Systems