text:
Proteomics/Proteomics and Drug Discovery/Docking and Scoring

Chapter Edited and Updated by: Vishal Thovarai & Kevin Smith E-mail: pac8612@rit.edu

This Section:

=Docking & Scoring=

Following protein studies and either virtual library creation or the decision to use a particular existing library, the next steps in this type of drug discovery are docking and scoring. In docking, various algorithms fit compounds from the virtual libraries into the specified target site or sites on a particular protein. The algorithms used in this stage often use either Monte Carlo methods, Genetic algorithms, or incremental construction, which are elaborated upon later in this section.

After compounds are docked, they are then scored. Scoring takes into account the chemical interactions between the ligand and target, in order to determine the energy state of the complex and to rank the efficacy of the compound being scored.

The top-scoring compounds are then visually inspected in the predicted docking orientation to verify the calculated stability, before actual laboratory experiments are performed to verify and determine both the efficacy and toxicity of the drug lead.

Principles of Molecular Docking
The aim of molecular docking is essentially to determine the binding interactions between two molecular species, in this context either protein to protein, or protein to ligand interactions. Of course, data representing the molecule and its respective properties must be already known on order to be able to simulate its behavior. For this reason, this type of behavioral deduction is known as retrospective virtual screening (Paetz). From a computational perspective, this is modernly accomplished through simulated molecular modeling software, or algorithms. The model then analyzes a gross amount of potential conformations which can be assumed, in order to assess those conformations which appear energetically favorable. The main algorithms used to do this use Monte Carlo methods, genetic algorithms, or incremental construction.

Monte Carlo method algorithms can be used to help predict the behavior of a physical system. The use pseudo-random number generation to power calculations result in many random conformations and configurations of the ligand in the binding site, in an attempt to “randomly” find a best-fit match. Given the complexity and sheer volume of the possible interactions, this type of algorithm is well suited for applications which are designed to emulate molecular interactions.

Genetic algorithms treat the different ligand states as members of a population. These members are mated and mutated, with the best-fit members of each generation carried on to additional generations. In working towards a best-fit case, evolution is modeled in order to produce better and better matches with each new generation. Mutations and deleterious events are used to avoid local maxima, which would give the illusion of working towards a “local” best-fit match, even though it might not be the absolute best-fit match.

Incremental construction treats the ligands as fragments that can be either rigid or flexible, depending on known stererochemical principles. The rigid sections are first put into ideal positions in the target site, followed by the flexible sections. The goal of adding the flexible portions second is to be able to connect all of the rigid fragments completely and appropriately. Versions of incremental construction are similar to the clique search. In this method, the rigid fragments are selected and positioned based on specific characteristics such as ability to function in a hydrogen bond, or electrostatic interactions between functional groups and side chains (Krovat).

A major factor to be decided upon is whether the ligand, the protein, or both are going to be treated as rigid or flexible. The computation time is already significant when the ligand is treated as flexible and the protein, rigid. The reason for this scenario, which is often typical in initial screenings, is that a.) flexibility in the ligand is easier to simulate, due to the small size of the compound and b.) flexibility in the ligand can lead to a broader range of compounds that fit a particular conformation; thus, there is a set of alternatives to choose from in terms of a chemical that is cheap and easy to synthesize or acquire. Many chemicals in virtual libraries do not actually exist, or are very difficult to acquire, so this element of choice among several good matches is critical in making VLS a much cheaper alternative to traditional laboratory screening.

Treating the protein as flexible greatly increases the computation time for docking due to the vast number of conformational changes that need to be considered; however, this allows more accurate docking when proteins are flexible in vivo, especially when induced-fit proteins are being targeted. Certain ligands that would not necessarily be top matches when the protein is considered rigid, may be ranked much higher when the protein is allowed to be flexible. There are alternatives for protein flexibility that keep computation time down. One such method is to use the X-ray crystallographic or NMR structure of a protein bound to a known ligand during docking. This allows the virtual library to be docked to the protein in its ligand-bound conformation. Another method is the use of several protein structures with slightly different conformations, which is usually achieved during NMR structure determination. This set of structures, or ensemble, is used in docking to find chemical matches that dock appropriately in several of the conformational models; the goal is to find a lead that could remain docked during a transition from the unbound protein conformation to the protein-ligand conformation.

Approaches and Algorithms
The two commonly used approaches are Surface Complementarity and Simulation based approaches. Surface complementarity approaches use techniques such as Fourier Transforms or Fast Fourier Transforms to convert the structural information of the receptors and ligands into mathematical grids and then check for complementarity between the structures. Simulation algorithms such as Simulated Annealing and Tabu Searching generally perform simulations using energy calculations as described later.

Simulated Annealing
Simulated Annealing is a probalistic meta-algorithm that has many applications, one of which is molecular docking. This algorithm will create a good approximation when optimizing functions. This does this by taking the point s in the function E(s) and minimizing the energy, which in molecular docking will result in the optimization of protein interaction. It does this by running a series of calculations moving from the original state of s, to a state of s’ which is an arbitrary number. This is called a transition. Transitions are shown through an acceptance probability function n P(e,e',T), which depends on the energy and temperature of the two states. In the function P e is the energy, e’ is the energy state the algorithm is moving to, and T is the temperature. The acceptance probability function is beneficial because with very small temperature values the computation will move to values of lower energy levels. A requirement of the probability function is that each move must be nonzero. 1 Another aspect of simulated annealing is the annealing schedule. This is where the temperature is slowly reduced as the simulation progresses. The parameters used in simulated annealing are the state space,  the energy function, the candidate generator procedure neighbor, the acceptance probability function, and the annealing schedule. 1 Flowchart of Simulated Annealing Process

Tabu search
Tabu search is another type of algorithm. The difference here is that it has a memory structure and will not attempt to calculate a possibility more than twice. It can be used for combinatorial optimization problems, where the goal is to find the best possible solution. It uses at local search procedure to move from one solution to the next. The N*(x) function in the tabu search algorithm is set to memorize the last number (n) of possibilities it has tried so there are no repeat calculations.2 This makes it more efficient than other algorithms (Hou).

Docking Implementations
Due to the enormous computational demand of docking and scoring algorithms, many such applications are developed with parallel programming pragmatics, so that they can be run on clusters of multiple CPUs and be greatly sped up. Grid Computing, a rapidly growing area of parallel computing, is currently being investigated as an alternative to devoted computer clusters. Grid computing, which models the electrical utility grid, would allow all of the idle computers at a pharmaceutical company to be used in a distributed computational grid. Especially at night, hundreds or even thousands of idle workstations could rival dedicated clusters, at a fraction of the cost. The tradeoff, however, is grid computing’s lack of guaranteed availability-on-demand.

Scoring Methods
Scoring, which evaluates the binding strength and energy state of the ligand-protein complex, follows docking during virtual drug discovery. Scoring can be done with several degrees of stringency. The most basic scoring functions consider hydrogen bond formation, van der Waal interactions, and other electrostatic forces. More advanced scoring functions consider, in addition to the above forces, the dielectric constant of the solution, in addition to various chemical energy models (Anderson). More basic scoring is often done in initial screenings, with increasing levels of scoring complexity used iteratively to narrow the field of high-scoring drug leads.

Another approach aimed at “scoring” non-metallic protein to ligand interactions is based on the comprehensive analysis of specific atomic characteristics of the molecule(s) in question. While considering some of the more basic criteria listed above, such as van der Waals and electostatic interactions, an empirical score is also designated with respect to hydrophobicity, and free energy changes in the bound state (Jain). This protocol has thus far shown much promise in terms of rapid computation and accuracy, and is available on the internet under the name Binding Affinity Prediction of Protein- Ligand server, or BAPPL.

A second phase of scoring involves evaluating the highest-scored matches visually to verify the predicted binding potential. Conformation, alignment of bonds, and the shapes of the interacting surfaces are considered in this final review step. Furthermore, size and availability/producability of the leads are included in the evaluation step. A compound that is easily synthesized but slightly less effective may be cheaper and better to investigate further than a higher-scoring ligand that does not exist outside of the virtual library.

Issues of Concern in Docking and Scoring
One of the first issues to be concerned with in docking is the resolution of a protein’s structure, along with the temperature of the atoms that comprise the protein. Temperature refers to the degree of uncertainty in the three-dimensional coordinates of an atom, due to resonance and vibration during the structure determination phase. This vibration is present in all atoms; however, greater vibration leads to greater temperature, and thus an atom’s determined coordinates become less reliable and accurate (Krovat).

A further concern in docking is the physiological pH of the protein versus the pH of the protein during crystallization. This a major factor in locating potential hydrogen bonding sites. The protonation and deprotonation of many amino acid side chains as pH changes could mean the difference between a tightly binding ligand and one that does not bind well at all, even though the former may be a false positive and the latter, a false negative. The context of hydrogen bonds must be considered as well, because they can occupy a range of binding strengths. This factor affects scoring too.

Additional concerns include binding in broad and shallow sites, as surface geometry plays less of a role due to the absence of specific shapes that might otherwise interact. Also, unusual binding modes that might exist in vitro might not be detected during in silico docking (Krovat).

Due the difficulty in resolving membrane-bound proteins, homology modeling, or the elucidation of molecular structure inferred from the primary sequence, is used in docking in these cases; this is in addition to the homology modeling used in determining the structure of membrane proteins.

References:
BAPPL LINK:

Bleicher, H. Konrad, et al. Hit and Lead Generation: Beyond High-Throughput Screening. Nature Reviews, Drug Discovery. 2003 May:(2), 369-378.

Hou, T., Wang, J., XU, X., “A Compatison of Three Heuristic Algorythms for Molecular Docking”. Chinese Chemical Letters 10 (1999): 615-618

Jain, Tarum, Jayaram, B. An all atom energy based computational protocol for predicting binding affinity of protein-ligand complexes. FEBS Letters. 2005:(579), 6659-6666.

Kapetanovic, M. I. Computer-aided drug discovery and development (CADDD): In-silico-chemico-biological approach. Chemico-Biology Int. 2007.

Lengauer, Thomas, et al. Novel technologies virtual screening. Drug Discovery Today. 2004 Jan:(9)1, 27-34.

Meek, J. Peter, et al. Shape Signatures; speeding up computer aided drug discovery. Drug Discovery Today. 2006 Oct:(11)19-20, 895-904.

Paetz, Jurgen, Schneider, Gisbert. A neuro-fuzzy approach to virtual screening in molecular bioinformatics. Fuzzy Sets and Systems. 2005:(152), 67-82.

Krovat, m. Eva, Langer, Thierry. Impact of Scoring Functions on Enrichment in Docking-Based Virtual Screening: An Application Study on Renin Inhibitors. J. Chem. Info. Comput. Sci. 2004 Apr:(3)44, 1123-1129.

Next: Software Tools


text:
Modern History/Space Exploration

Heliocentric Model
The Roman Catholic Church was very much in control of early astronomy.

USSR Space Attempts and Success
Sputnik, a small metal ball with instruments attached to it, was the first man-made object to leave earth and orbit it. It was really technologically, simple, and would set the tone for much of the Soviet Union's space exploration program.

US Space Attempts and Success
The first satellites were launched by the Soviet Union at the end of the 1950's. If they can put a satellite into space, they can launch a warhead at the United States. This was what spurred the United States to start their own space program to challenge the perceived "Soviet Superiority", and start academically challenging students to be successful in Math and the Sciences.

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

title: Modern History/Space Exploration


text:
Modern History/Franco-Prussian War

The Franco-Prussian War (July 19, 1870 – May 10, 1871) was fought between France and Prussia (backed by the North German Confederation and the southern German states of Baden, Bavaria and Württemberg). The conflict marked the culmination of rising tensions between the two powers following Prussia's increasing dominance in Germany, then still a loose federation of quasi-independent territories.

Origins
The long term causes of the war can be traced back decades. France was understandably anxious about the increasing economic and political power of Prussia to its east, and at the same time eager to pursue it's old diplomatic aims of the expansion of its territories eastwards. Internally, the Bonapartist regime that ruled France faced increasing dissent, and some believed that a successful war against Prussia would not only provide economic and territorial gains but also prevent revolution. Prussia, on the other hand, believed that a war with France would help strengthen Germany as a whole by ending French influence, and that a victorious Prussia could achieve the ultimate goal of the unification of Germany. These tensions increased due to a number of diplomatic crises between the two nations in the 1860s, particularly over the Austro-Prussian War and France's attempt to purchase Luxembourg.

The war was finally triggered by a dispute over the possible ascension of the German Prince Leopold of Hohenzollern-Sigmaringen (a member of Prussia's Hohenzollern royal family) to the Spanish throne, following the abdication of Isabella II in 1868. The French government feared that this expansion of Prussian influence would weaken France's position in Europe, not least because it made it probable that any war with Prussia would lead to war with Spain, forcing France to fight on two fronts. The French Emperor Napoleon III issued an ultimatum to the Prussian King Wilhelm I demanding that Leopold be withdrawn from candidacy for the Spanish throne, and he complied. Eager to press their perceived advantage, the French demanded a guarantee that no other Hohenzollern candidates would be put forwards, but the Prussian government refused. French public opinion was inflamed, and France declared war.

The War
There were many European nations which had motives to go to war against Prussia alongside France, but Napoleon III's mismanagement of France's foreign policy had led to the diplomatic isolation of France, and at the outbreak of war France was unable to find any allies. In contrast, Prussia had signed treaties with the southern German states of Baden, Bavaria and Württemberg which guaranteed their support if war was declared against Prussia.

France was able straight away to field an army of about 400,000 highly trained soldiers, compared to roughly 1.2 million Prussian and southern German troops. However, the German soldiers were not regulars and would take some time to train, so the French army had an initial advantage. This was exploited by pushing forwards up to the German border, and on August 2 the French seized the city of Saarbrücken. The Prussian army moved swiftly against them, and less than a week after Saarbrücken fell, the German forces inflicted a series of heavy defeats upon the French. The Prussian army steamrollered it's way into France, capturing Metz in October after a bloody siege. Although Napoleon III himself surrendered and was taken prisoner following the Battle of Sedan in early September, the war continued to be fought by a French republican government for several months.

title: Modern History/Franco-Prussian War


text:
Template:SideBox

The following parameters accept the same values as the HTML "style" attribute properties with the same names.
 * e.g to change:  define ' '.

Parameters:
 * clear: left, right, both
 * font-size: http://www.w3.org/TR/CSS21/fonts.html#font-size-props
 * text-align: http://www.w3.org/TR/CSS21/text.html#alignment-prop (default: center)
 * bgcolor: (background-color) http://www.w3.org/TR/CSS21/colors.html#background
 * width: http://www.w3.org/TR/CSS21/visudet.html#the-width-property (default: 250px)
 * min-width: http://www.w3.org/TR/CSS21/visudet.html#min-max-widths (default: 200px, only meaningful if width is specified in %)
 * float: right or left (default: right)

The "style" parameter allows any other CSS attributes to be set. One of the previous parameters is preferable to using "style", as it makes the template syntax easier to read. The "higher" parameter positions the box by the given units higher than without the parameter (e.g. higher=1em).

de:Vorlage:SeitlicherKasten

title: Template:SideBox


text:
US History/Keywords1

Jeffersonian and Jacksonian Democracy (1800-1840)
strict v. broad interpretation (of Constitution) Revolution of 1800 Alexis de Tocqueville Monroe Doctrine Marbury v Madison Clay's American System Whig Party Louisiana Purchase Lewis and Clark Haitian Rebellion Embargo Act impressments War of 1812 War Hawks Hartford Convention Era of Good Feelings cotton gin (Eli Whitney) Erie Canal Lowell factory system Transcendentalists Emerson Thoreau Hawthorne Seneca Falls Republican motherhood Horace Mann Dorothea Dix William Lloyd Garrison Monroe Doctrine

Jackson
Jackson's Indian policy Indian Removal Act Supreme Court and the Cherokees Chief Justice John Marshall Trail of Tears Tariff of Abominations Nullification crisis in South Carolina (1832) Webster-Hayne Debates Force Bill (1833) Second Bank of the US

Manifest Destiny and Sectionalism (1820-1860)
Republican Party Free-Soil Party "Bleeding Kansas"

Treks
Gold Rush 49er Donner Party Joseph Smith Book of Mormon

title: US History/Keywords1


text:
Haskell/Continuation passing style

Continuation Passing Style (CPS for short) is a style of programming in which functions do not return values; rather, they pass control onto a continuation, which specifies what happens next. In this chapter, we are going to consider how that plays out in Haskell and, in particular, how CPS can be expressed with a monad.

What are continuations?
To dispel puzzlement, we will have a second look at an example from way back in the book, when we introduced the  operator:

> map ($ 2) [(2*), (4*), (8*)] [4,8,16]

There is nothing out of ordinary about the expression above, except that it is a little quaint to write that instead of. The  section makes the code appear backwards, as if we are applying a value to the functions rather than the other way around. And now, the catch: such an innocent-looking reversal is at heart of continuation passing style!

From a CPS perspective,  is a suspended computation: a function with general type  which, given another function as argument, produces a final result. The argument is the continuation; it specifies how the computation will be brought to a conclusion. In the example, the functions in the list are supplied as continuations via, producing three distinct results. Note that suspended computations are largely interchangeable with plain values: converts any value into a suspended computation, and passing   as its continuation gives back the original value.

What are they good for?
There is more to continuations than just a parlour trick to impress Haskell newbies. They make it possible to explicitly manipulate, and dramatically alter, the control flow of a program. For instance, returning early from a procedure can be implemented with continuations. Exceptions and failure can also be handled with continuations - pass in a continuation for success, another continuation for fail, and invoke the appropriate continuation. Other possibilities include "suspending" a computation and returning to it at another time, and implementing simple forms of concurrency (notably, one Haskell implementation, Hugs, uses continuations to implement cooperative concurrency).

In Haskell, continuations can be used in a similar fashion, for implementing interesting control flow in monads. Note that there usually are alternative techniques for such use cases, especially in tandem with laziness. In some circumstances, CPS can be used to improve performance by eliminating certain construction-pattern matching sequences (i.e. a function returns a complex structure which the caller will at some point deconstruct), though a sufficiently smart compiler should be able to do the elimination.

Passing continuations
An elementary way to take advantage of continuations is to modify our functions so that they return suspended computations rather than ordinary values. We will illustrate how that is done with two simple examples.

Modified to return a suspended computation,  looks like this:

How the  example works:

 * 1) square x and throw the result into the (\x_squared -> ...) continuation
 * 2) square y and throw the result into the (\y_squared -> ...) continuation
 * 3) add x_squared and y_squared and throw the result into the top level/program continuation.

We can try it out in GHCi by passing  as the program continuation: 25
 * Main> pythagoras_cps 3 4 print

If we look at the type of  without the optional parentheses around  and compare it with the original type of , we note that the continuation was in effect added as an extra argument, thus justifying the "continuation passing style" moniker.

"bar"
 * Main> thrice tail "foobar"

A higher order function such as, when converted to CPS, takes as arguments functions in CPS form as well. Therefore,  will become , and the final type will be. The rest of the definition follows quite naturally from the types - we replace  by the CPS version, passing along the continuation at hand.

The monad
Having continuation-passing functions, the next step is providing a neat way of composing them, preferably one which does not require the long chains of nested lambdas we have seen just above. A good start would be a combinator for applying a CPS function to a suspended computation. A possible type for it would be:

(You may want to try implementing it before reading on. Hint: start by stating that the result is a function which takes a continuation; then, let the types guide you.)

And here is the implementation:

We supply the original suspended computation  with a continuation which makes a new suspended computation (produced by  ) and passes the final continuation   to it. Unsurprisingly, it mirrors closely the nested lambda pattern of the previous examples.

Doesn't the type of  look familiar? If we replace with  and  with  we get the   signature. Furthermore, our old friend plays a  -like role, in that it makes a suspended computation out of a value in a trivial way. Lo and behold, we have a monad! All we need now is a type to wrap suspended computations, with the usual wrapper and unwrapper functions.

The monad instance for  follows directly from our presentation, the only difference being the wrapping and unwrapping cruft:

The end result is that the monad instance makes the continuation passing (and thus the lambda chains) implicit. The monadic bind applies a CPS function to a suspended computation, and  is used to provide the final continuation. For a simple example, the Pythagoras example becomes:

While it is always pleasant to see a monad coming forth naturally, a hint of disappointment might linger at this point. One of the promises of CPS was precise control flow manipulation through continuations. And yet, after converting our functions to CPS we promptly hid the continuations behind a monad. To rectify that, we shall introduce, a function which gives us back explicit control of continuations - but only where we want it.

is a very peculiar function; one that is best introduced with examples. Let us start with a trivial one:

The argument passed to  is a function, whose result is a suspended computation (general type ) which we will refer to as "the   computation". In principle, the  computation is what the whole   expression evaluates to. The caveat, and what makes  so special, is due to , the argument to the argument. It is a function which acts as an eject button: calling it anywhere will lead to the value passed to it being made into a suspended computation, which then is inserted into control flow at the point of the  invocation. That happens unconditionally; in particular, whatever follows a  invocation in the   computation is summarily discarded. From another perspective,  captures the rest of the computation following the  ; calling it throws a value into the continuation at that particular point ("callCC" stands for "call with current continuation"). While in this simple example the effect is merely that of a plain,   opens up a number of possibilities, which we are now going to explore.

Deciding when to use
gives us extra power over what is thrown into a continuation, and when that is done. The following example begins to show how we can use this extra power.

is a slightly pathological function that computes the square of its input and adds three; if the result of this computation is greater than 20, then we return from the  computation (and, in this case, from the whole function) immediately, throwing the string   into the continuation that will be passed to. If not, then we subtract four from our previous computation,  it, and throw it into the continuation. Remarkably,  here is used just like the 'return' statement from an imperative language, that immediately exits the function. And yet, this being Haskell,  is just an ordinary first-class function, so you can pass it to other functions like , store it in a  , etc.

Naturally, you can embed calls to  within do-blocks:

When you call  with a value, the entire   call takes that value. In effect, that makes  a lot like an 'goto' statement in other languages: when we call   in our example, it pops the execution out to where you first called , the   line. No more of the argument to  (the inner do-block) is executed. Hence the following example contains a useless line:

will return, and not  , because we pop out of   before getting to the   line.

Behind the scenes
We have deliberately broken a trend here: normally when we introduce a function we give its type straight away, but in this case we chose not to. The reason is simple: the type is pretty complex, and it does not immediately give insight into what the function does, or how it works. After the initial presentation of, however, we are in a better position to tackle it. Take a deep breath...

We can make sense of that based on what we already know about. The overall result type and the result type of the argument have to be the same (i.e. ), as in the absence of an invocation of  the corresponding result values are one and the same. Now, what about the type of ? As mentioned above, 's argument is made into a suspended computation inserted at the point of the   invocation; therefore, if the latter has type   's argument must have type. As for 's result type, interestingly enough it doesn't matter as long as it is wrapped in the same  monad; in other words, the   stands for an arbitrary type. That happens because the suspended computation made out of the  argument will receive whatever continuation follows the , and so the continuation taken by  's result is irrelevant.

To conclude this section, here is the implementation of. Can you identify  in it?

Though the code is far from obvious, an amazing fact is that the implementations of,   and   for   can be produced automatically from their type signatures - Lennart Augustsson's Djinn  is a program that will do this for you. See Phil Gossett's Google tech talk: for background on the theory behind Djinn; and Dan Piponi's article:  which uses Djinn in deriving continuation passing style.

Example: a complicated control structure
We will now look at some more realistic examples of control flow manipulation. The first one, presented below, was originally taken from "The Continuation monad" section of the All about monads tutorial, used with permission.

is a function that takes an integer. The implementation uses  and   to set up a control structure using   and   that does different things based on the range that   falls in, as stated by the comment at the top. Let us dissect it:

 * 1) Firstly, the   at the top just means that we run the   block that follows with a final continuation of   (or, in other words, we extract the value from the suspended computation unchanged). That is necessary as the result type of   doesn't mention.
 * 2) We bind   to the result of the following   do-block:
 * 3) If   is less than 10, we exit straight away, just showing.
 * 4) If not, we proceed. We construct a list, , of digits of.
 * 5)   (an  ) gets bound to the result of the following inner   do-block.
 * 6) If , i.e., if   has less than 3 digits, we pop out of this inner do-block with the number of digits as the result.
 * 7) If   has less than 5 digits, we pop out of the inner do-block returning the original.
 * 8) If   has less than 7 digits, we pop out of both the inner and outer do-blocks, with the result of the digits of   in reverse order (a  ).
 * 9) Otherwise, we end the inner do-block, returning the sum of the digits of.
 * 10) We end this do-block, returning the String , where X is  , the digits of  , and Y is the result from the inner do-block,.
 * 11) Finally, we return out of the entire function, with our result being the string "Answer: Z", where Z is the string we got from the   do-block.

Example: exceptions
One use of continuations is to model exceptions. To do this, we hold on to two continuations: one that takes us out to the handler in case of an exception, and one that takes us to the post-handler code in case of a success. Here's a simple function that takes two numbers and does integer division on them, failing when the denominator is zero.

How does it work? We use two nested calls to. The first labels a continuation that will be used when there's no problem. The second labels a continuation that will be used when we wish to throw an exception. If the denominator isn't 0,  is thrown into the   continuation, so the execution pops right back out to the top level of. If, however, we were passed a zero denominator, we throw an error message into the  continuation, which pops us out to the inner do-block, and that string gets assigned to   and given to.

A more general approach to handling exceptions can be seen with the following function. Pass a computation as the first parameter (more precisely, a function which takes an error-throwing function and results in the computation) and an error handler as the second parameter. This example takes advantage of the generic  class which covers both   and the corresponding   transformer by default, as well as any other continuation monad which instantiates it.

And here is our  in action:

In this example, error throwing means escaping from an enclosing. The  in   jumps out of  's inner.

Example: coroutines
In this section we make a CoroutineT monad that provides a monad with, which enqueues a new suspended coroutine, and  , that suspends the current thread.

Some example usage: Outputting: 3 4 3 2 4 3 2 4 4

Example: Implementing pattern matching
An interesting usage of CPS functions is to implement our own pattern matching. We will illustrate how this can be done by some examples.

Now we have learnt CPS, we can refactor the code like this.

"It's True" "It's False"
 * Main> check true
 * Main> check false

What happens here is that, instead of plain values, we represent  and   by functions that would choose either the first or second argument they are passed. Since  and   behave differently, we can achieve the same effect as pattern matching. Furthermore,,   and  ,   can be converted back and forth by   and.

We should see how this is related to CPS in this more complicated example.

0 4 9 0 4 9
 * Main> fun Zero
 * Main> fun $ One 3
 * Main> fun $ Two 3 4
 * Main> funCPS zero
 * Main> funCPS $ one 3
 * Main> funCPS $ two 3 4

Similar to former example, we represent values by functions. These function-values pick the corresponding (i.e. match) continuations they are passed to and pass to the latter the values stored in the former. An interesting thing is that this process involves in no comparison. As we know, pattern matching can work on types that are not instances of : the function-values "know" what their patterns are and would automatically pick the right continuations. If this is done from outside, say, by an  function, it would have to inspect and compare the patterns and the values to see if they match -- and thus would need   instances.

title: Haskell/Continuation passing style


text:
Introduction to Psychology/Memory

Introduction: Memory at Wikipedia

 * Long-term memory and short-term memory.
 * Working memory
 * 1) Storing Knowledge
 * 2) Retrival
 * Amnesia
 * Repression
 * 1) Memory in Childhood
 * Eyewitness Testimony
 * 1) /Flashbulb Memories/

Back to Table of Contents << Previous chapter||Next chapter >>

title: Introduction to Psychology/Memory


text:
Category:Chinese templates

This category contains templates used in the Chinese (Mandarin) book.

|Templates

title: Category:Chinese templates


text:
Wikijunior:Kings and Queens of England/The Stuarts

James I (1603-1625)
James I was born at Edinburgh Castle on 19 June 1566. James was the only child of Mary, Queen of Scots and her second husband, Lord Darnley. James was a direct descendant of Henry VII through his great-grandmother Margaret Tudor, sister of Henry VIII. He ruled in Scotland as James VI from 24 July 1567 until his death on 27 March 1625. He was also King of England and King of Ireland as James I from 24 March 1603 until his death. He was the first monarch of England from the House of Stuart.

James was a successful monarch in Scotland, but he was an unsuccessful monarch in England. He was unable to deal with a hostile Parliament, and the refusal by the House of Commons to levy sufficiently high taxes crippled the royal finances. However, James is considered to have been one of the most intellectual British monarchs. Under him, much of the cultural flourishing of Elizabethan England continued; science, literature and art, contributed by men such as Sir Francis Bacon and William Shakespeare grew by leaps.

Before becoming King of England
In June 1567, Protestant rebels arrested James's mother, Mary, Queen of Scots, and imprisoned her. Mary was forced to abdicate the throne on 24 July, giving it to James, then only thirteen months old. He was brought up as a member of the Protestant Church of Scotland. During James VI's early reign, power was held by a series of regents, with James taking power himself in 1581, though he did not rule by himself, relying instead on the advice of his closest courtiers. He carried on ruling as King of Scotland, and then, on the death of Queen Elizabeth of England in 1603, an English Accession Council met and proclaimed James King of England. However, Scotland and England remained separate states - it was not until 1707 that the Acts of Union merged the two nations to create a new state, the Kingdom of Great Britain.

Early reign in England
James is noted for creating many new lords. In total, sixty-two people were raised to the English Peerage by James. Elizabeth had only created eight new peers during her 45-year reign. Upon his arrival in London, James was almost immediately faced by religious conflicts in England. He was presented with a petition from Puritans requesting further Anglican Church reform. He accepted the invitation to a conference in Hampton Court, which was subsequently delayed due to the Plague. In 1604, at the Hampton Court Conference, James was unwilling to agree to most of their demands. He did, however, agree to fulfill one request by authorizing an official translation of the Bible, which came to be known as the King James Version.

In 1605, a group of Catholic extremists led by Robert Catesby developed a plan, known as the Gunpowder Plot, to cause an explosion in the chamber of the House of Lords, where the King and members of both Houses of Parliament would be gathered for the State Opening of Parliament. The conspirators sought to replace James with his daughter, Elizabeth, who, they hoped, could be forced to convert to Catholicism. One of the conspirators, however, leaked information regarding the plot, which was then foiled. Terrified, James refused to leave his residence for many days. Guy Fawkes, who was to be the one lighting the gunpowder, was tortured on the rack until he revealed the identities of the other conspirators, all of whom were executed or killed during capture. Dolls of Guy Fawkes are still burned each 5 November, which is known as Guy Fawkes, or bonfire, Night, to commemorate the plot.

Conflict with Parliament and death
Following the dissolution of the Addled Parliament, James ruled without a Parliament for seven years. Faced with financial difficulties due to the failure of Parliament to approve new taxes, James sought to enter into a profitable alliance with Spain by marrying his eldest surviving son, Charles, to the daughter of the King of Spain. The proposed alliance with a Roman Catholic kingdom was not well received in Protestant England. James's unpopularity was increased by the execution of Sir Walter Raleigh.

James lapsed into senility during the last year of his reign. Real power passed to his son, Charles, and to the Duke of Buckingham, although James kept enough power to ensure that a new war with Spain did not occur while he was King. James died at Theobalds House in 1625 of 'tertian ague' (fever one day in every three), probably brought upon by kidney failure and stroke. He was buried in the Henry VII Lady Chapel in Westminster Abbey. Charles succeeded him as Charles I.

Issue
James's children included Henry Frederick, Prince of Wales (who died aged 18 in 1612), Elizabeth, Margaret Stuart (who died in infancy), Charles, Mary and two more children who died in infancy (Robert and Sophia).

Charles I (1625-1649)
Charles I was born at Dunfermline Palace on 19 November 1600. He was the second son of James I and Anne of Denmark. He was King of England, Scotland and Ireland from 27 March 1625 until his execution in 1649. He famously engaged in a struggle for power with the Parliament of England. He was a supporter of the Divine Right of Kings, and many in England feared that he was attempting to gain absolute power. There was widespread opposition to many of his actions, especially the levying of taxes without Parliament's consent. Religious conflicts continued throughout Charles's reign. He selected his Catholic wife, Henrietta Maria, over the objections of Parliament and public opinion.

The last years of Charles' reign were marked by the English Civil War, in which he was opposed by the forces of Parliament, who challenged his attempts to increase his own power, and by Puritans, who were hostile to his religious policies. The war ended in defeat for Charles, who was subsequently tried, convicted and executed for high treason. The monarchy was overthrown, and a commonwealth was established.

Early life and reign
Charles was not as well-regarded as his elder brother, Henry. However, when his elder brother died of typhoid in 1612, Charles became heir to the throne and was later made Prince of Wales. Charles ascended the throne in March 1625 and on 1 May of that year married to Henrietta Maria, who was nine years his junior. She was a sister of King Louis XIII of France. His first Parliament, which he opened in May, was opposed to his marriage to Henrietta Maria, a Roman Catholic, because it feared that Charles would lift restrictions on Roman Catholics and undermine the official establishment of Protestantism. Although he agreed with Parliament that he would not relax restrictions relating to recusants, he promised to do exactly that in a secret marriage treaty with Louis XIII. Charles and his wife had nine children, with three sons and three daughters surviving infancy.

Personal Rule
In January 1629, Charles opened the second session of the Parliament which had been prorogued in June 1628. He hoped that, with the Duke of Buckingham gone, Parliament, which had been refusing to let him raise taxes, would finally cooperate with him and grant him further subsidies. Instead, members of the House of Commons began to voice their opposition to the levying of tonnage and poundage without parliamentary consent. When he requested a parliamentary adjournment in March, members held the Speaker down in his chair whilst three resolutions against Charles were read aloud. The last of these resolutions declared that anyone who paid tonnage or poundage not authorized by Parliament would "be reputed a betrayer of the liberties of England, and an enemy to the same". Though the resolution was not formally passed, many members declared their approval. Afterward, when the Commons passed further measures, Charles commanded the dissolution of Parliament.

Charles decided that he could not rely on Parliament for further monetary aid. Immediately, he made peace with France and Spain. The following eleven years, during which Charles ruled without a Parliament, have been known as the Eleven Years Tyranny.

In the meantime Charles still had to get funds to maintain his treasury. Relying on an all but forgotten feudal statute passed in 1278, requiring anyone who earned £40 or more each year to present himself at the King's coronation so that he may join the royal army as a knight, Charles fined everyone who failed to attend his coronation in 1626. He reintroduced the feudal tax known as ship money, which was even more unpopular. A writ issued in 1634 ordered the collection of ship money in peacetime, although laws passed when Edward I and Edward III were on the throne said it should not be collected in peacetime. This action of demanding ship money in peacetime led to a rebellion which forced him to call parliament into session by 1640.

Short and Long Parliaments
A dispute with the Churches in Scotland meant that Charles needed more money. He therefore had to end his personal rule and recall Parliament in April 1640. Although Charles offered to repeal ship money, the House of Commons demanded the discussion of various abuses of power during the period of Charles's personal rule. Parliament refused to help Charles and it was dissolved in May 1640, less than a month after it assembled. It became known as the Short Parliament. Charles still tried to defeat the Scots, but failed. The peace treaty he agreed required the King to pay the expenses of the Scottish army he had just fought. Charles took the unusual step of summoning the magnum concilium, the ancient council of all the Peers of the Realm, who were considered the King's hereditary counsellors. The magnum concilium had not been summoned in centuries, and it has not been summoned since Charles's reign. On the advice of the peers, Charles summoned another Parliament, which became known as the Long Parliament.

The Long Parliament assembled in November 1640 and proved just as difficult to negotiate with as the Short Parliament. To prevent the King from dissolving it at will, Parliament passed the Triennial Act, which required that Parliament was to be summoned at least once every three years. In May 1641, he assented to an even more far-reaching Act, which provided that Parliament could not be dissolved without its own consent. Charles was forced into one concession after another. Ship money, fines in destraint of knighthood and forced loans were declared unlawful, and the hated Courts of Star Chamber and High Commission were abolished. Although he made several important concessions, Charles improved his own military position by securing the favour of the Scots. He finally agreed to the official establishment of Presbyterianism, and in return got considerable anti-parliamentary support.

The House of Commons then threatened to impeach Charles' Catholic Queen, Henrietta Maria, finally leading the King to take desperate action. His wife persuaded him to arrest the five members of the House of Commons who led the anti-Stuart faction on charges of high treason, but, when the King had made his decision, she made the mistake of telling a friend who, in turn, told Parliament. Charles entered the House of Commons with an armed force on 4 January 1642, but found that his opponents had already escaped. Many in Parliament thought Charles's actions outrageous, but others had similar sentiments about the actions of Parliament itself. Several members of the House of Commons left to join the royalist party, leaving the King's opponents with a majority. It was no longer safe for Charles to be in London, and he went north to raise an army against Parliament. The Queen, at the same time, went abroad to raise money to pay for it.

Civil war
The English Civil War had not yet started, but both sides began to arm. Charles raised the royal standard in Nottingham on 22 August 1642. He then set up his court at Oxford, from where he controlled roughly the north and west of England, Parliament remaining in control of London and the south and east. The Civil War started on 25 October 1642 with the inconclusive Battle of Edgehill and continued indecisively through 1643 and 1644, until the Battle of Naseby tipped the military balance decisively in favour of Parliament. There followed a great number of defeats for the Royalists, and then the Siege of Oxford, from which Charles escaped in April 1646. He put himself into the hands of the Scottish Presbyterian army at Newark, and was taken to nearby Southwell while his "hosts" decided what to do with him. The Presbyterians finally arrived at an agreement with Parliament and delivered Charles to them in 1647. He was imprisoned at Holdenby House in Northamptonshire, but was soon transferred to a number of different locations.

Trial and execution
Charles was finally moved to Windsor Castle and then St James's Palace. In January 1649, the House of Commons without the assent of either the Sovereign or the House of Lords—passed an Act of Parliament creating a court for Charles's trial. The High Court of Justice established by the Act consisted of 135 Commissioners (all firm Parliamentarians). The King's trial (on charges of high treason and "other high crimes") began on 2 January, but Charles refused to enter a plea, claiming that no court had jurisdiction over a monarch. It was then normal practice to take a refusal to plead as an admission of guilt, which meant that the prosecution could not call witnesses to its case. Fifty-nine of the Commissioners signed Charles's death warrant on 29 January, 1649. After the ruling, he was led from St. James's Palace, where he was confined, to the Palace of Whitehall, where an execution scaffold had been erected in front of the Banqueting House.

Charles was beheaded on 30 January, 1649. One of the revolutionary leaders, Oliver Cromwell, allowed the King's head to be sewn back on his body so the family could pay its respects. Charles was buried in private and at night on 7 February 1649, in the Henry VIII vault inside St George's Chapel in Windsor Castle. Charles was father to a total of nine legitimate children, two of whom would eventually succeed him as king. Several other children died in childhood.

Interregnum (1649-1660)
The English Interregnum was the period of parliamentary and military rule after the English Civil War, between the execution of Charles I in 1649 and the restoration of Charles II in 1660.

This era in English history can be divided into four periods:
 * 1) The first period of the Commonwealth of England from 1649 until 1653
 * 2) The Protectorate under Oliver Cromwell from 1653 to 1659
 * 3) The Protectorate under Richard Cromwell in 1659
 * 4) The second period of the Commonwealth of England from 1659 until 1660

Life during the Interregnum
Four years after Charles I's execution, Oliver Cromwell was offered the Crown. But he refused and chose instead to rule as Lord Protector. Oliver Cromwell was a Puritan and during the Interregnum, he imposed a very strict form of Christianity upon the country. Cromwell granted religious freedom otherwise previously unknown in England, but other forms of expression were suddenly limited (for instance, theatre, which had thrived under the Stuart kings and Elizabeth I, was banned). Cromwell also imposed his own personal vision of Christianity on the masses, with feasts on days of fast disallowed and work on Sundays subject to fine. Richard Cromwell was the successor to his father. But he gave up his position as Lord Protector with little hesitation, resigning or "abdicating" after a demand by the Rump Parliament. This was the beginning of a short period of restoration of the Commonwealth of England, and Charles I's son, also called Charles, was soon invited back as king.

Charles II (1660-1685)
Charles II was born in St James's Palace on 29 May 1630. Charles was the eldest surviving son of Charles I and Henrietta Maria of France. He was the King of Scots from 30 January 1649 and King of England and Ireland from 29 May 1660 until his death on 6 February 1685. Unlike his father Charles I, Charles II was skilled at managing the Parliament of England, so much so that Charles is still considered one of England's greatest kings. It was during his reign that the Whig and Tory political parties developed. He famously fathered numerous illegitimate children, of whom he acknowledged fourteen. Known as the "Merry Monarch", Charles was a patron of the arts.

Restoration
After the death of Oliver Cromwell in 1658, Charles's chances of regaining the Crown seemed slim. Oliver Cromwell was succeeded as Lord Protector by his son, Richard Cromwell. However, the new Lord Protector abdicated in 1659. The Protectorate of England was abolished, and the Commonwealth of England established. During the civil and military unrest which followed, George Monck, the Governor of Scotland, was concerned that the nation would descend into anarchy and sought to restore the monarchy. Monck and his army marched into the City of London and forced the Long Parliament to dissolve itself. For the first time in almost twenty years, the members of Parliament faced a general election. A Royalist House of Commons was elected. The Convention Parliament, soon after it assembled on 25 April 1660, heard about the Declaration of Breda, in which Charles agreed, amongst other things, to pardon many of his father's enemies. It subsequently declared that Charles II had been the lawful Sovereign since Charles I's execution in 1649.

Charles set out for England, arriving in Dover on 23 May 1660 and reaching London on 29 May. Although Charles granted amnesty to Cromwell's supporters in the Act of Indemnity and Oblivion, he went back on his pardon of the commissioners and officials involved in his father's trial and execution. Many among those who signed Charles I's death warrant were executed in 1660 in the most gruesome fashion: they were hanged, drawn and quartered. Others were given life imprisonment. The body of Oliver Cromwell was also "executed".

The Convention Parliament was dissolved in December 1660. Shortly after Charles's coronation at Westminster Abbey on 23 April 1661, the second Parliament of the reign, the Cavalier Parliament, met. As the Cavalier Parliament was overwhelmingly Royalist, Charles saw no reason to dissolve it and force another general election for seventeen years.

Foreign policy
In 1662 Charles married a Portuguese princess, Catherine of Braganza, who brought him the territories of Bombay and Tangier as dowry. During the same year, however, he sold Dunkirk, a much more valuable strategic outpost to his cousin King Louis XIV of France of France for £40,000. In 1668, England allied itself with Sweden, and with its former enemy the Netherlands, in order to oppose Louis XIV in the War of Devolution. Louis was forced to make peace with the Triple Alliance, but he continued to maintain his aggressive intentions. In 1670, Charles, seeking to solve his financial troubles, agreed to the Treaty of Dover, under which Louis XIV would pay him £200,000 each year. Meanwhile, around 1670, Charles granted the British East India Company the rights to autonomous territorial acquisitions, to mint money, to command fortresses and troops, to form alliances, to make war and peace, and to exercise both civil and criminal jurisdiction over the acquired areas in India. Earlier in 1668 he leased the islands of Bombay for a paltry sum of ten pounds sterling paid in gold.

Great Plague and Fire
In 1665, Charles II was faced with a great health crisis: an outbreak of Bubonic Plague in London commonly referred to as the Great Plague of London. The death toll at one point reached 7000 per week. Charles, his family and court fled from London in July 1665 to Oxford. Various attempts at containing the disease by London public health officials all fell in vain and the disease continued to spread rapidly. On 2 September 1666 came the Great Fire of London. Although it ended the Great Plague by burning of plague-carrying rats and fleas, the fire consumed about 13,200 houses and 87 churches, including the original St. Paul's Cathedral.

Conflict with Parliament
Charles's wife Queen Catherine was unable to produce an heir. Charles's heir was therefore his unpopular Roman Catholic brother, James. In 1678, Titus Oates, a former Anglican cleric, falsely warned of a "Popish Plot" to kill the king and replace him with James. Charles did not believe the story, but ordered his chief minister to investigate. He, however, was an anti-Catholic, and encouraged Oates to make his accusations public. The people were seized with an anti-Catholic hysteria; judges and juries across the land condemned the supposed conspirators; numerous innocent individuals were executed. Later in 1678, however, the chief minister was impeached by the House of Commons on the charge of high treason. To save Lord Danby from the impeachment trial in the House of Lords, Charles dissolved the Cavalier Parliament in January 1679. A new Parliament, which met in March of the same year, was quite hostile to the king, and this led to the chief minister being forced to resign and being held prisoner in the Tower of London.

Later years
The Parliament of 1679 was elected at a time when there were strong anti-Catholic sentiments. It was opposed to the prospect of a Catholic monarch. An Exclusion Bill, which sought to exclude James from the line of succession, was introduced. The "Abhorrers", those who opposed the Exclusion Bill, would develop into the Tory Party, whilst the "Petitioners", those who supported the Exclusion Bill, became the Whig Party. Fearing that the Exclusion Bill would be passed, Charles dissolved Parliament in December 1679. Two further Parliaments were called in Charles's reign (one in 1680, the other in 1681), but both were dissolved because they sought to pass the Exclusion Bill. During the 1680s, however, popular support for the Exclusion Bill began to dissolve, and Charles experienced a nationwide surge of loyalty. For the remainder of his reign, Charles ruled as an absolute monarch, without a Parliament.

In 1685 Charles died suddenly. When he knew he was dying and in great secrecy, a priest was summoned to his bedside. Charles was admitted into the Catholic Church and received the last rites. He was buried in Westminster Abbey. He was succeeded by his brother, who became James II in England and Ireland, and James VII in Scotland.

James II (1685-1688)
James II of England and VII of Scotland was born at St James's Palace on 14 October 1633. He was the second surviving son of Charles I and Henrietta Maria of France. He became King of England, King of Scots and King of Ireland on 6 February 1685. He was the last Roman Catholic monarch to reign over England, Scotland and Ireland. Some of his subjects distrusted his religious policies and alleged despotism, leading a group of them to depose him in the Glorious Revolution. He was replaced not by his Roman Catholic son, James Francis Edward, but by his Protestant daughter and son-in-law, Mary II and William III, who became joint rulers in 1689. The belief that James remained the legitimate ruler became known as Jacobitism (from Jacobus, the Latin for James). However, James did not try to return to the throne, instead living the rest of his life under the protection of King Louis XIV of France. His son James Francis Edward Stuart and his grandson Charles Edward Stuart (Bonnie Prince Charlie) attempted to restore the Jacobite line after James's death on 16 September 1701, but failed.

Early life
Like his brother, James sought refuge in France during the Interregnum, and he served in the French army. In 1656, when his brother, Charles, entered into an alliance with Spain, an enemy of France, he joined the Spanish army. Both armies praised James's abilities. In 1660, Charles II was restored to the English Throne, and James returned to England with him. Though he was the heir, it seemed unlikely then that he would inherit the Crown, as it was thought that Charles would have legitimate children. In September 1660, James married Lady Anne Hyde, the daughter of Charles's then chief minister, Edward Hyde, 1st Earl of Clarendon.

Religion
James was admitted to the Roman Catholic Church in 1668 or 1669. His Protestant enemies in the Parliament of England then passed the Test Act, which made all civil and military officials swear an oath against certain practices of the Roman Catholic Church and receive communion in the Church of England. James refused to do this and gave up his post of Lord High Admiral as a result. Charles II opposed James's conversion, and ordered James's children be raised as Protestants, but in 1673, he allowed James (whose first wife had died in 1671) to marry the Catholic Mary of Modena.

In 1677, James allowed his daughter, Mary, to marry the Protestant Prince of Orange, William III, who was also his nephew. However, fears of a Catholic monarch remained, and got greater as Charles II's wife continued to fail to provide an heir.

Reign and the Glorious Revolution
Charles died without legitimate offspring in 1685, and James became king. At first, there was little opposition to him and many Anglicans supported him as the legitimate monarch. The new Parliament which assembled in May 1685 seemed favourable to James, agreeing to grant him a large income. James, however, faced the Monmouth Rebellion, which was led by Charles II's illegitimate son, the Duke of Monmouth. James Scott, 1st Duke of Monmouth declared himself King on 20 June 1685, but was defeated at the Battle of Sedgemoor. Monmouth was executed at the Tower of London soon after. Despite the lack of popular support for Monmouth, James began to distrust his subjects. His judges, most notably Judge Jeffreys (the "Hanging Judge"), punished the rebels brutally. Judge Jeffreys' Bloody Assizes led the people to see their King as a cruel and barbarous ruler. To protect himself from further rebellions, James sought to establish a large standing army. By putting Roman Catholics in charge of several regiments, the King was drawn into a conflict with Parliament. Parliament was prorogued in November 1685, never to meet again during James's reign.

Religious tension intensified in 1686. In the Declaration of Indulgence in 1687, he suspended laws punishing Roman Catholics and other religious dissenters. In April 1688, James re-issued the Declaration of Indulgence, and ordered Anglican clergymen to read it in their churches. When the Archbishop of Canterbury and six other bishops petitioned for a change in the King's religious policies, they were arrested and tried for seditious libel, but were acquitted. Public alarm increased with the birth of a Catholic son and heir, James Francis Edward, to Queen Mary in June, 1688. Several leading Protestants then entered into negotiations with William, Prince of Orange, who was James's son-in-law, for him to invade and become king. By September, it had become clear that William was looking to invade. James believed his army could fight them off, but when William landed on 5 November 1688, all of the King's Protestant officers went over to William's side. On 11 December, James attempted to flee to France. He was caught in Kent, but allowed to escape to France on 23 December.

When James left, no Parliament was in session, so William convened a Convention Parliament. The Convention declared on 12 February 1689 that James's attempt to flee on 11 December meant that he had abdicated and that the throne had then become vacant (instead of passing to James II's son, James Francis Edward). James's daughter Mary was declared Queen. She was to rule jointly with her husband William III. The Scottish Estates followed suit on 11 April.

William and Mary then granted their assent to the Bill of Rights. This confirmed that William III and Mary II were to be King and Queen. It also charged James II with abusing his power by suspending the Test Acts, the prosecuting of the Seven Bishops for petitioning the Crown, establishing a standing army and imposing cruel punishments. The Act also set out who would be heirs to the Crown. First were any children of William and Mary, to be followed by the Princess Anne and her children, and finally by the children of William by any subsequent marriage.

Later years and legacy
With a French army on his side, James landed in Ireland in March 1689. The Irish Parliament did not follow the example of the English Parliament and instead declared that James remained King. He was, however, defeated at the Battle of the Boyne on 1 July 1690. He fled back to France after the defeat departing. In France, James was allowed to live in a royal castle. An attempt was made to restore him to the throne by killing William III in 1696, but the plot failed. Louis XIV's offer to have James elected King of Poland was rejected, after which Louis no longer helped James. He died in 1701 at Saint-Germain-en-Laye, where he was buried.

The son of James II, James Francis Edward Stuart (known to his supporters as "James III and VIII" and to his opponents as the "Old Pretender"), took up the Jacobite cause. He led a rising in Scotland in 1715 shortly after George I became king, but was defeated. Further risings were also defeated. After the rising of 1745 led by Charles Edward Stuart, no serious attempt to restore the Stuart heir has been made.

James Francis Edward died in 1766, when he was succeeded by his eldest son, Charles Edward Stuart (known to his supporters as "Charles III" and to his opponents as the "Young Pretender"). Charles in turn was succeeded by his younger brother Henry Benedict Stuart, a cardinal of the Catholic Church. Henry was the last of James II's legitimate descendants.

Children
James had eight children by Anne Hyde, of whom only two, Mary and Anne, survived infancy. They became the next two Queens. By Mary of Modena he had six children, two of whom survived infancy. The most famous of his children by Mary of Modena was James Franci Edward Stuart. He also had a number of illegitimate children.

William III (1689-1702) and Mary II (1689-1694)
After the Glorious Revolution, William III and his wife, Mary II, became joint rulers.

William
William was born in The Hague in the Netherlands on 14 November 1650. He was the son of William II, Prince of Orange, and Mary Stuart. He was Dutch aristocrat and a Protestant Prince of Orange from his birth. He was King William III of England and of Ireland from 13 February 1689, and William II, King of Scots from 11 April 1689 in each case until his death on 8 March 1702.

Eight days before he was born, his father died from battle wounds, and so William became the Sovereign Prince of Orange at the moment of his birth. On 23 December 1660, when William was just ten years old, his mother died of smallpox while visiting her brother, King Charles II in England. In her will, Mary made Charles William's legal guardian. Charles passed on this responsibility to William's paternal grandmother, the Princess Dowager Amalia, with the understanding that Charles's advice would be sought whenever it was needed. In 1666, when William was sixteen, the States General of the United Provinces of the Netherlands officially made him a ward of the government, or as William himself called it, a "Child of State". This was one in order to prepare William for a role in the nation's government. When his time as the government's ward ended three years later, William returned to private life.

Mary
Mary II was born in London on 30 April 1662. She was the eldest daughter of James II and his first wife, Lady Anne Hyde. She reigned as Queen of England and Ireland from 13 February 1689 until her death on 28 December 1694, and as Queen of Scotland from 11 April 1689 until her death. Mary came to the throne after the Glorious Revolution. Mary reigned jointly with her husband and first cousin, William III, who became the sole ruler upon her death. Mary, although a sovereign in her own right, did not wield power during most of her reign. She did, however, govern the realm when her husband was abroad fighting wars.

James II converted to Roman Catholicism in 1668 or 1669, but Mary and Anne were order by Charles II to have a Protestant upbringing, pursuant to the command of Charles II. At the age of fifteen, Princess Mary became engaged to the Protestant Stadtholder and Prince of Orange, William. William was the son of her aunt and Prince William II of Nassau. They married in London on 4 November 1677. Mary went to the Netherlands, where she lived with her husband. She did not enjoy a happy marriage, with her three pregnancies ended in miscarriage or stillbirth. She became popular with the Dutch people, but her husband neglected or even mistreated her and had an affair with one of Mary's ladies-in-waiting.

Reign
Although most in England accepted William as Sovereign, he faced considerable opposition in Scotland and Ireland. The Scottish Jacobites, who believed that James II remained the legitimate monarch, won a stunning victory on 27 July 1689 at the Battle of Killiecrankie, but were later beaten within a month. William's reputation suffered after the Massacre of Glencoe in 1692, when almost one hundred Scots were murdered for not properly pledging their allegiance to the new King and Queen. Accepting public opinion, William sacked those responsible for the massacre, though they still remained in his favour.

In Ireland, where the French aided the rebels, fighting continued for much longer, although James II fled the island after the Battle of the Boyne in 1690. This Battle is still commemorated each year by the Protestants in Northern Ireland. After the Anglo-Dutch Navy defeated a French fleet at in 1692, the naval supremacy of the English became apparent, and Ireland was conquered shortly after.

From 1690 onwards, William often remained absent from England. Whilst her husband was away, Mary ruled. She was a firm ruler, and even ordered the arrest of her own uncle for plotting to restore James II to the throne. In 1692, she dismissed and imprisoned the influential John Churchill, 1st Earl of Marlborough on similar charges. In this case the dismissal reduced her popularity and harmed her relationship with her sister Anne. When William was in England, Mary stepped aside from politics. She did, however, get involved in the affairs of the Church, in particular with Church appointments. Mary died of smallpox in 1694. After Mary II's death, William III continued to rule as king. Although he had previously mistreated his wife and kept mistresses, William deeply mourned his wife's death. Although he was brought up as a Calvinist, he converted to Anglicanism, but his popularity fell greatly during his reign as a sole Sovereign.

William as sole ruler
William, like many other European rulers, became concerned about who would succeed to the throne of Spain, which brought with it vast territories in Italy, the Low Countries and the New World. The question became important as The King of Spain, Charles II, was an invalid with no prospect of having children, and had amongst his closest relatives Louis XIV, the King of France, and Leopold I, the Holy Roman Emperor. William wanted to stop either of these inheriting all Spanish lands. William and Louis XIV agreed to the First Partition Treaty, which provided for the division of the Spanish Empire: Duke Joseph Ferdinand of Bavaria (whom William himself chose) would obtain Spain, while France and the Holy Roman Emperor would divide the remaining territories between them. The Spaniards, however, wanted to keep the Spanish territories united.

After Joseph Ferdinand died of smallpox, William and Louis In 1700, the two rulers agreed to the Second Partition Treaty in 1700, under which the territories in Italy would pass to a son of the King of France, and the other Spanish territories would be inherited by a son of the Holy Roman Emperor. This infuriated both the Spanish, who wanted the empire intact, and the Holy Roman Emperor, who wanted the Italian territories. Unexpectedly, King Charles II of Spain changed his will as he lay dying in late 1700. He left all Spanish territories to Philip, a grandson of Louis. The French ignored the Second Partition Treaty and claimed the entire Spanish inheritance. Louis also angered William by recognising James Francis Edward Stuart, the son of the former King James II, who had died in 1701, as King of England. The subsequent conflict, known as the War of the Spanish Succession, continued until 1713.

Princess Anne's last surviving child, William, Duke of Gloucester, died in July 1700, and, as it was clear that William III would have no more children, Parliament passed the Act of Settlement in 1701, which provided that the Crown would go to the nearest Protestant relative, Sophia, Electress of Hanover and her Protestant heirs when William III died.

William's death
In 1702, William died of pneumonia, a complication from a broken collarbone, resulting from a fall off his horse. It was believed by some that his horse had stumbled into a mole's burrow, and as a result many Jacobites toasted "the little gentleman in the black velvet waistcoat". William was buried in Westminster Abbey alongside his wife. He was succeeded by Queen Anne.

Anne (1702-1714)
Anne was born in St James's Palace on 6 February 1665. She was the second daughter of James, who went on to become James II, and his first wife, Lady Anne Hyde. She was Queen of England, Scotland and Ireland from 8 March 1702 until her death on 1 August 1714. Anne was the last monarch of the House of Stuart. She was succeeded by a distant cousin, George I. Anne's reign saw the two party political system develop.

Early life
On 28 July 1683, Anne married the Protestant Prince George of Denmark, brother of the Danish King Christian V. The union was unpopular because Denmark was pro-France union, but it was a happy one for Anne and George. Sarah Churchill became Anne's lady of the bedchamber, and, by the latter's desire to mark their mutual intimacy and affection, all deference due to her rank was abandoned and the two ladies called each other Mrs Morley and Mrs Freeman. Sarah remained Anne's closest friend, and later married John Churchill, the 1st Duke of Marlborough. However, they had a falling out and Sarah was banned from court during the War of the Spanish Succession, when her husband was leading the English armies in the War.

By 1700, Anne had been pregnant at least eighteen times. Thirteen times, she miscarried or gave birth to stillborn children. Of the remaining five children, four died before reaching the age of two years. Her only son to survive infancy, William, Duke of Gloucester, died at the age of eleven on 29 July 1700. William and Mary did not have any children, and therefore Anne was the only individual remaining in the line of succession established by the Bill of Rights. If the line ended, then the deposed King James may have reclaimed the Throne. To stop a Roman Catholic from becoming king, Parliament enacted the Act of Settlement 1701, which provided that the Crown would go to Sophia, Electress of Hanover, and her descendants, who descended from James I of England through Elizabeth of Bohemia.

Early reign
William III died on 8 March 1702, leaving the Crown to Anne. At about the same time, the War of the Spanish Succession began. It would continue until the last years of Anne's reign, and would dominate both foreign and domestic policy. Soon after becoming Queen, Anne made her husband Lord High Admiral in control of the Royal Navy. Control of the army went to Lord Marlborough. The Duchess of Marlborough was appointed to the post of Mistress of the Robes, the highest office a lady could attain.

Anne's first government was mostly Tory. The Whigs, who were, unlike the Tories, big supporters of the Warm became more influential after the Duke of Marlborough won a great victory at the Battle of Blenheim in 1704. The Whigs quickly rose to power, and almost all the Tories were removed from the ministry. The Act of Union between England and Scotland was then passed. Under the Act, England and Scotland became one realm called Great Britain on 1 May 1707.

The Duchess of Marlborough's relationship with Anne worsened during 1707. Anne's husband, Prince George of Denmark, then died in October 1708, after which Anne grew even more distant from the Duchess of Marlborough. The Queen ended their friendship in 1709.

The fall of the Whigs came about quickly as the expensive War of the Spanish Succession grew unpopular in England. In the general election of 1710, the electorate returned a large Tory majority. The new Tory government began to seek peace in the War of the Spanish Succession. The Tories were ready to compromise by giving Spain to the grandson of the French King, but the Whigs could not bear to see a Bourbon on the Spanish Throne. The dispute was resolved by outside events, when the elder brother of Archduke Charles (whom the Whigs supported) conveniently died in 1711 and Archduke Charles then inherited Austria, Hungary and the throne of the Holy Roman Empire. To also give him the Spanish throne was no longer in Great Britain's interests, as he would become too powerful. The Treaty of Utrecht in 1713 provided that peace, although it only got ratified by Great Britain when Anne created twelve new peers in one day to make sure it had enough support in the House of Lords.

Under the terms of the ratified treaty, Philip, grandson of the French King Louis XIV, was allowed to remain on the Throne of Spain, and kept Spain's New World colonies. The rest of the Spanish territories, however, wer spliy amongst various European princes. Great Britain kept of Gibraltar and Minorca, and got some French colonies in North America.

Death and legacy
Anne died of an abscess and fever arising from gout, at approximately on 1 August 1714. Her body was so swollen that it had to be buried in Westminster Abbey in a vast almost-square coffin. She died shortly after the Electress Sophia (8 June 1714) and so the Electress's son, George, became king of Great Britain.

Anne's reign saw greater influence in government by ministers and a decrease in the influence of the Crown. In 1708, Anne became the last British Sovereign to withhold the Royal Assent from a bill. The shift of power from the Crown to the ministry became even more apparent during the reign of George I, whose chief advisor, Sir Robert Walpole, is often described as the first Prime Minister. The age of Anne was also one of artistic, literary and scientific advancement. In architecture, Sir John Vanbrugh constructed elegant buildings such as Blenheim Palace (the home of the Marlboroughs) and Castle Howard. Writers such as Daniel Defoe, Alexander Pope and Jonathan Swift flourished during Anne's reign. Sir Isaac Newton also lived during Anne's reign, although he had reached his most important discoveries under William and Mary.


text:
Latin/Lesson 1-Revision

 * 1st declension: genitive ends in -ae, nominative usually ends in -a
 * 2nd declension: genitive ends in -i, nominative usually ends in -us for masculine and -um for neut.
 * 3rd declension: genitive ends in -is, nominative varies
 * 4th declension: genitive ends in -us, nominative usually ends in -us for m/f and -u for neut.
 * 5th declension: genitive ends in -ei, nominative usually ends in -es

Notice that almost all 1st declension nouns are feminine. A mnemonic device for the common masculine ones is PAIN -- poeta (poet), agricola (farmer), incola (inhabitant), and nauta (sailor). Almost all 2nd declension nouns are either masculine or neuter.

Notice that in all cases, the accusative of neuter nouns is the same as the nominative.

1st Declension

2nd

masculine

-us  -i -i   -orum -o   -is -um  -os -o   -is

neuter

-um  -a -i   -orum -o   -is -um  -a -o   -is

3rd

m/f

-?   -es -is  -um -i   -ibus -em  -es -e   -ibus

neut.

-?   -a -is  -um -i   -ibus -?   -a -e   -ibus

4th

m/f

-us -us -us -uum -ui -ibus -um -us -u  -ibus

neut. -u  -ua -us -uum -u  -ibus -u  -ua -u  -ibus

5th -es -es -ei -erum -ei -ebus -em -es -e  -ebus

A mnemonic device for the common irregular imperatives is the rhyme: dic, duc, fac, fer: there ought to be an "e", but it isn't there. dicite, ducite, facite, ferte.

1st conjugation: amo, amare, amavi, amatus

2nd conjugation: moneo, monere, monui, monitus

3rd conjugation: ago, agere, egi, actus

3rd -io       : capio, capere, cepi, captus

4th conjugation: sentio, sentire, sensi, sensus

Indicative Active Present

title: Latin/Lesson 1-Revision


text: File:Screenshot.jpg

title: File:Screenshot.jpg


text:
Latin/Lesson 5-Exercises

Translate:

 * 1) Multa de monte visa sunt.
 * 2) Hic opus factus est ab me.
 * 3) Multa magna agentur ab hoc puero.
 * 4) Deus laudabatur a multis.

title: Latin/Lesson 5-Exercises


text:
Wikijunior talk:Big Book of Fun Science Experiments/Red cabbage indicator

I don't understand
It is currently quite... weird and confusing. Although good images, text will help me understand. N1person 01:59, 2 May 2006 (UTC)


text:
TI-Basic Z80 Programming/List of Commands/GetKey

Intro and Syntax
Getkey is an important feature of user interaction in TI-Basic. getkey could be found in PGRM...Right...7... and it will display the following:
 * getkey

Yes, and it will get the number of the key when that code block is executed. However, that getkey is very short and therefore, it is hard to get an accurate key number. Because if you don't press anything during its being executed, it will result in 0.

Keep in mind that with out doing some sort of,

 * getkey->X

the getkey will store its result in the Ans variable.

Getkey with While and Goto Loops
How do you get an accurate recording?

well, there is a simple while loop that you could do. It's fairly easy so I'll explain it right here...

Things to do
 * While 1
 * getkey
 * If ans
 * End
 * End

That works because first, you set up a loop. And if there is nothing pressed, it will skip the if condition, then it will execute anything else below it in order. See, if getkey returned a 0, then the calculator skips the if condition, goes right back to the top which now again, checks for a getkey. so this continues on till you press a key!

Notifying a pressed button
This example will display "BUTTON PRESSED" when a button is pressed.

 * 0→K
 * While K=0
 * getKey→K
 * End
 * Disp "BUTTON PRESSED"

Now, I'll explain Line by Line...

 * Lbl K

that Lbl K is used so that could always loop back when you need to get the number of key being pressed. It will make possible for a loop.

 * getkey→K

This, is the most important part. You need the getkey to get the key number! the '→K' will store the returned value of getkey to the variable 'K'.

 * While K>0

this while loop is also essential because you want certain things to happen ONLY when a key is pressed. Thus, the key value is in K, it will check if K is actually greater than 0. If it is, it will execute the code block 'Disp "BUTTON PRESSED"'.

 * Disp "BUTTON PRESSED"

You also need this in order to actually see that the button is being pressed. When ever the While loop is executed, the Disp command will be executed, displaying a notice...

 * End

Possible mistake
This is the most important part of this code block. If there isn't an End, this is the result...

 * Lbl K
 * getkey->K
 * While K>0
 * Disp "BUTTON PRESSED"
 * Goto K
 * Goto K

Now do you notice any flaw? YES!

Do you think that this code will repeat itself? NO!

Do you know why it won't repeat it self? It won't repeat it self BECAUSE the 'End' isn't there! Even though it has a 'Goto K' statement, its still in the While loop, thus, if there is not keypress, that 'Goto K' won't be executed, resulting in quitting the program. It's essential that you include the 'End' whenever you need to exit from a while loop.

Displaying the corresponding key number with the pressed key
For example, this will display the key number being pressed... You could use this as a little tool in your calculators. Just press the button you want, and it'll display its corresponding key number. Here is goes;

 * Lbl 1
 * getKey
 * If Ans > 0
 * Disp Ans
 * Goto 1

Corresponding to specific keys
Now, if you want to respond to specific keys, such as the 2nd or Enter, you change '>0' to '=N' where N is the key number. the chart is shown here:

Do you notice anything weird? Yes! The On is not "registered". Instead of returning an integer for this key, this key will return an interrupt, meaning that it will interrupt the program. There are ASM utilities to block this On key. They are widely available at TI-Calc.Org. Anyway, look at other keys. Do you see how they are organized?

Key organization and numbering
Yes, each row starts with 11...21...31...41...51...61...71...81...91...101... and that's because then, it's easy to remember.

Here, let's use some example...

 * Lbl 1
 * getkey
 * If Ans = 11
 * Disp "Y= was PRESSED"
 * If Ans = 21
 * Disp "2ND WAS PRESSED"
 * Goto 1

the code should be self-explanatory. It checks for keys 11 or 21 being pressed and displays a corresponding message.

Moving Pixels with Up/Down/Left/Right Arrows
Is the Disp thingy boring for you? Well, let's move on and move things!

For now, we'll just move a pixel, but as you go on, practice and get complicated!

Example:

 * ClrDraw
 * 47→X:31→Y
 * Lbl 1
 * getKey→K
 * If K=25
 * ClrDraw
 * Y-1→Y
 * Pxl-On(Y,X)
 * End
 * If K=34
 * ClrDraw
 * Y+1→Y
 * Pxl-On(Y,X)
 * End
 * If K=24
 * X-1→X
 * Pxl-On (Y,X)
 * End
 * If K=26
 * X+1→X
 * Pxl-On (Y,X)
 * End
 * Goto 1

Now, the preceding code just moved a single pixel on the screen.

ERR-MEMORY
If you just pressed the buttons like crazy, and you got a error message saying: ERR-MEMORY then you're out of luck. The (dreaded) memory error is the worst feature about BASIC compared to Asm, because any BASIC program will eventually slow down and stop with a memory error if run for long enough. Main cause of memory errors: INEFFICIENT CODE and long program running time. Note that with efficient code, the running time will be much longer... here is an example of inefficient code:
 * 0->A
 * While A<10
 * A+1->A
 * If A=5:Goto X
 * End
 * Lbl X

Why? The Goto label quits the While loop, but it sits in memory because it never reached the 'End' command (simply placing 'End' after Lbl X in the code above does NOT work! So mainly, to optimize your code get rid of Goto's and Lbl's they are bad for you and your program! instead replace them with more efficient Repeat, While, and For loops. hey sorry but i made an equation set that does the samething but is faster and ahorter 1->B 1->C Lbl0 Output(B,C,"A getkey->A B-(A=25)+(B=34->B C-(A=24)=(A=26->C Goto0 storing values in B and C Label 0 Outputs A in the coordinates getkeys and stores in A the equations are self explanatory if you know the key codes and finally goto label0 hope that helps!


text:
User:Naconkantari/monobook.js

// User:Lupin/popups.js

mw.loader.load(            'https://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js'             + '&action=raw&ctype=text/javascript&dontcountme=s'); popupAdminLinks=true;

title: User:Naconkantari/monobook.js