text:
Italian/Grammar/Pronouns

General
Personal pronouns are short words that replace persons or things: he, she, they, it, me, her etc.

Personal pronouns can play various roles. For instance, in the sentence I eat cake, the word 'I' is a subject, but in the sentence That lion wants to eat me, the word 'me' is the object.

Other pronouns (not personal) also replace nouns, with a more specific usage. For instance, this can replace a noun, with a meaning similar to it (or he/she), e.g. in the sentence this is good for you.

More information about pronouns, subjects etc. in English can be found in a different place. Here it is assumed that sufficient knowledge is available.

Subject Personal Pronouns / Pronomi personali soggetto
List of Subject Personal Pronouns:

Singular: io  - I    - Note: no capital letter required tu  - you  - Note: used to address one person egli - he  - Note: not used in common talk lui - he   - Note: colloquial, normally it replaces egli ella - she - Note: not used in common talk lei - she  - Note: colloquial, normally it replaces ella esso - it  - Note: masculine, little used in common speech essa - it  - Note: feminine, little used in common speech lei - you  - Note: special use; sometimes with capital initial

Plural: noi - we voi - you  - Note: used to address two or more people Voi - you  - Note: same as 'voi' with lower case initial, but more formal (compare to 'Lei' in the singular) essi - they - Note: masculine esse - they - Note: feminine loro - they - Note: both masculine and feminine, colloquial, normally it replaces essi and esse Loro - you - Note: special use, very uncommon, capital initial

The pronouns for the 1st person (singular: io, plural: noi) do not need special explanations.

The pronouns for the 2nd person (in English you both singular and plural) have a usage far more varied than in English.

Tu is addressed to one person only (singular) and is related to the older English thou. It is felt to be informal. It is used with members of the same family (e.g. father, mother), with relatives (e.g. uncles), with children, with friends, and, in modern usage, with work colleagues. It is often used with boys and girls, and sometimes it is used with other persons in order to create a friendly atmosphere.

In the other cases (especially with grown-up people that are not friends or relatives) it is replaced by the pronoun lei (sometimes written with a capital letter). This pronoun literally means she and its usage is similar to English sentences including His/Her Majesty.

For the same purpose the pronoun Ella can also be used. This is felt today as obsolete and is used rarely only in writing.

When two or more people are addressed, voi is used both in formal and informal language - that is with relatives, friends and other people. The plural for Lei does exist, it is Loro (capital initial), but it is nowadays little used. Instead of Loro, Voi is used, which is the same as voi but with a capital letter.

The pronouns for the singular 3rd person (in English he/she/it) take into account the gender of the replaced noun, which in Italian can only be masculine or feminine.

When referring to a person, he is translated as egli (proper language, rarely used in speech) or lui (colloquial), she as ella (rare in speech) or lei (colloquial).

For animals or things, it is translated as esso when the noun is masculine (e.g. lago, lake) and as essa when it is feminine (e.g. barca, boat).

Plural also takes into account the gender, so they is translated as essi (masc.) or esse (fem.). In colloquial talk they is usually translated as loro.

It should also be remembered that pronouns are required less often than in English because verb forms change for every person. It's usually better to say Sono felice ([I] am happy) than Io sono felice (I am happy).

Missing subject pronouns
In many languages, including English, French and German, the subject of the verb must be expressed. Pronouns are widely used to avoid repeating nouns for this purpose.

In Italian the subject is often omitted, as the verb can give sufficient information. Personal subject pronouns are far less used than in English. They are used only when there is a need for clarity or a wish to emphasize the pronoun itself.

Examples of missing subjects: Piove. It is raining. No need to mention it. Vengo subito. I come soon. No need to mention I. Dove vai? Where are you going? No need to mention you. Dove andiamo? Where are we going? No need to mention we.

Example of special uses: Credo di sì. I think so. Io credo di sì. I do think so. The pronoun makes the assertion more emphatic.

Object Pronouns
1) In most cases the direct and indirect object pronouns are placed before the verb: Ti vedo. I see you. One exception: loro as an indirect object is placed after the verb. Additionally, a few forms of the verb always have pronouns after them, but then they are postfixed (ie. written onto it as one word). These forms are the infinitive (dropping the final 'e', eg. vederlo), the gerund and the past participle (but only when used alone, not as part of a perfect tense). For example 'I want to see him' is Voglio vederlo and not voglio lo vedere. Note that stress does not change when pronouns are appended, ie.  scri vere =>  scri verlo and not scri ver lo

2) Note that 'Lei' and 'Voi' when indicating formal 'you' are capitalised, regardless of inflection (eg. ''Perché non Le piace questo film?. ''Why don't you like this movie? ). This rule also applies to postfixed 'Lei' and 'Voi', but there they may also occur in lower case (eg. I can see you. ''Posso vederLa. or Posso vederla. '')

3) When two pronouns (or a pronoun and ci (there) or ne (form there/it)) are combined, the order is indirect + direct + ci/ne. You will never encounter all three together, but for example if you have an indirect and a direct object, then the indirect will precede the direct. Additionally the preceding form changes: For example, 'He gives it to us' is Ce lo dà. Glie is affixed to the next word, so 'I give it to him/them' becomes Glielo do.

Another example is the verb andarsene, which means to go away (andare-si-ne, lit. to go (oneself) from the place). It is conjugated me ne vado, te ne vai, se ne và, etc.

As you can see in andarsene the postfixed pronouns are all written as one word. This is the rule for all such combinations, ie. ''Voglio dartelo. ''I want to give it to you. (=dare-ti-lo)

4) The prepositional forms are obligatory after prepositions: Vado da lui stasera. I'm going to his place tonight.

They are also placed after the verb instead of the direct object to emphasize the pronoun (eg. Ho visto te. It is you I saw. - This is somewhat uncommon).

They can replace the indirect object in a similar fashion, which is much more common, but these pronouns require the preposition a when indicating the indirect object (eg. Lo dirò a te prima che lo dica agli altri. I'll tell you before I tell any of the others. - As you can see in this sentence, nouns such as gli altri also need the preposition a)

Possessive Pronouns
Possessives, like articles, must agree with the gender and number of the noun they modify. Hence, mio zio, my uncle, but mia zia, my aunt. So depending on what is being modified, the possessive pronouns are:

 * Masc. sing.: mio, tuo, suo, nostro, vostro, loro
 * Fem. sing.: mia, tua, sua, nostra, vostra, loro
 * Masc. pl.: miei, tuoi, suoi, nostri, vostri, loro
 * Fem. pl.: mie, tue, sue, nostre, vostre, loro

In most cases the possessive adjective must be used with the definite article:

 * Ho perso la mia penna. (I've lost my pen.)
 * Mi piace il mio lavoro. (I like my job.)
 * Hanno rubato la mia automobile! (They've stolen my car!)

The only exception is when the possessive refers to a family member in the singular:

 * Sara è mia sorella (Sarah is my sister.)
 * Questa penna è di mia zia. (This pen is my aunt's.)

But in the plural:

 * Le mie zie sono vecchie (My aunts are old)

However, 'loro' always takes the definite article (also note that 'loro' does not change, for example the female form is 'loro', not 'lora' or something like that):

 * La loro sorella è malata (Their sister is ill)

Personal pronouns can also be used on their own:

 * Questa macchina è la mia. (This car is mine)

To say 'one of my', 'one of your' etc. you use a personal pronoun with the indefinite article:

 * Un mio figlio è malato (One of my sons is ill)

And finally, possessives may be placed behind the noun it refers to in poetical language and specific expressions. If the definite article is used at all, it remains before the noun.

 * (Gli) affari tuoi (Your (own) business)
 * Fatti gli affari tuoi! (Mind you own business!)

Relative Pronouns
Relative pronouns are just pronouns, like those before this section but they refer to something relative to the context of the sentence or the situation. the pronoun "I" will always refer to myself while the pronoun "she" will always refer to some "her". A Relative pronoun can refer to a person, a thing or a situation. In English these pronouns are who, which, that, whom, where.

 * Pronoun che: this pronoun is used when you use which, who, and that.

 * Pronouns il quale, la quale, i quali, le quali: this pronoun "quale" is like the previous one but it also indicates the gender and number:
 * il quale: masculine singular
 * la quale: feminine singular
 * i quali: masculine plural
 * le quali: feminine plural

 * Pronoun cui: this pronouns introduces indirect objects (this means all those objects that need a preposition before it): “Headphone is the instrument (with) which you can hear music with” this pronoun needs “with” to work.

 * Extra pronouns: chi, colui, colei, coloro, ciò, chiunque, quanto, etc... words that serve the purpose of a pronoun.

Demonstrative Pronouns
There are only two demonstrative pronouns: questo and quello. Pay attention to how these pronouns change in gender and number.

 * questo, questa, questi, queste=this, these
 * quello, quella, quelli, quelle=that, those

'Questo' and related forms always use their full form. 'Quello' uses the full form as described above when on their own (for example, Questo è rotto. This one is broken.), but has a shorter form when used with a noun (Quel problema non si può risolvere. That problem can't be solved.)

The form is dependent on the article you would use with the noun: For example, you would say gli uomini, so you say quegli uomini. These forms are also used when followed by a relative pronoun: Quel che voglio = What I want / The one that I want / That which I want.
 * il => quel
 * lo => quello
 * la => quella
 * l => quell
 * i => quei
 * le => quelle
 * gli => quegli

Italiano/Pronombres

title: Italian/Grammar/Pronouns


text:
Applicable Mathematics/Odds

"Odds" is a way of expressing the likelihood of an event.

The more usual way of expressing the likelihood of an event is its "probability" (the percentage of future trials which are expected to produce the event: so in tossing a coin believed to be fair, we would assign a probability of 50% (or one half, or 0.5) to the event "heads").

The ODDS of an event, however, is the ratio of the probability of the event happening to the probability of the even not happening (i.e. the ODDS of a fair coin landing heads is 50%:50% = 1:1 = 1). It is the ODDS we are using when we use a phrase like "it is 50/50 whether I get the job" or "The chances of our team winning are 2 to 1".

Or, For example, when rolling a fair die, there is one chance that you will roll a 1 and five chances that you will not. The odds of rolling a 1 are 1:5, or 1 to 5. This can also be expressed as $$1/5$$ or 0.2 or 20%, but these forms are likely to be misunderstood as normal probabilities rather than odds.

To convert odds to probability, you add the two parts, and this is the denominator of the fraction of your probability. The first part becomes the numerator. Thus, 1:5 becomes 1/(1+5) or 1/6.

To convert probability to odds, you use the numerator as the first number, then subtract the numerator from the denominator and use it as the second number. Thus, 1/6 becomes 1:(6-1) or 1:5.

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

title: Applicable Mathematics/Odds


text:
Conlang/Beginner/Writing

OK, you have your sounds and words, but you think that this alphabet we use is boring? Well, you're in luck! This page will give you a few hints and tips about creating your own writing system, commonly called a "conscript".

Types of script
To make an interesting writing system the last thing you want to do is copy the Roman script. So, before you actually start to create any glyphs (symbols), you will need to decide what kind of script you would like to make. Scripts are divided up by how many sounds are expressed per glyph.

 * One glyph for an entire syllable (like Cherokee, or Japanese kana).
 * Only glyphs for consonants (like Hebrew).
 * One consonant per glyph with little marks for vowels (like Sanskrit).
 * A separate glyph for each consonant and vowel (like English, or Hangul).
 * One glyph for each unit of meaning or concept (like Chinese).

Naturally, you are not limited to just these types. You can modify or combine them to fit your language and style.

Glyphs
Now that you have chosen the type of script you want, you get to design the glyphs themselves. Here are a few things to keep in mind:

 * Think about how many distinct glyphs you will need. How you determine this will depend on what type of script you have chosen.  In a script with very many glyphs, you will probably want most glyphs to have a fair amount of detail, so they can be readily told apart.
 * Many cultures began writing with basic pictures of objects, such as the ancient Maya or the Egyptians using hieroglyphs. These pictures were simplified and worn down over time into more abstract shapes.  For example, the letter A has its origins in a glyph representing the head of a bull.
 * If you prefer to use symbols you can either do them by hand or start with pictures and write them fast with a pen or brush to see how they morph.
 * If too many symbols are very similar or just turned versions of other symbols, they can be very confusing to read. Although, if you are making a secret language, this might be your goal.
 * Think about where your script is written. Carved or etched letters will tend to have hard lines, while letters written by brush will often be flowing. A script originating as knots tied in a string — a common ancient record-keeping technique — may have a connecting line written through the middle of every letter.
 * A cursive version of your script can be made by writing each of your letters as fast as you can. If you make sure they still look different from each other, but slur them enough for speed, they should come out with a viable cursive form.
 * Scalability. How small can your glyphs get before details are lost and it is too difficult to distinguish one from another?  If you plan on creating a font for your writing system this will be important.

Writing Direction
Okay, now you have your sounds and your symbols but you have one more thing to figure out: which way the words will be written.

 * Top to Bottom
 * Left to Right
 * Right to Left
 * Bottom to top
 * Boustrophedon — write one way until the end of the line and then write the opposite way from there for the next line:

You then need to find out which way the lines will go. For example, Japanese is sometimes written top to bottom with vertical lines going right to left. Arabic goes right to left but the lines go top to bottom horizontally. Chinese and Mongolian are both traditionally written top to bottom but with vertical lines going left to right and right to left respectively. Some writing systems like Ogham are sometimes even written in a circle.

Now you can write in your own script!

title: Conlang/Beginner/Writing


text:
Active Server Pages/Basic ASP Syntax

= Objectives =

In this section you will learn about the different parts of Active Server Pages scripting. We don't want to get too deep in discussion of how to write ASP scripts, but instead just want to introduce the different elements of ASP scripting.

= Content =

Active Server Pages or ASP is a scripted language which means that it doesn't have to be compiled in order to run. Instead, the program code is parsed, interpreted and evaluated in real-time. This means that you do not have to compile code in order to execute it.

Code is executed by placing it within a web page on a Web server. ASP was developed by Microsoft and because of this, is only completely reliable on Microsoft's IIS (Internet Information Server.) We encourage you to use Microsoft IIS to develop Active Server Page code.

Statements
A statement is like a sentence in English, it describes one task for the ASP interpreter to perform. A block of code is made up of multiple statements strung together on a web page.

There are various types of statements which we will talk about in the future including: "(flow) control, output, assignment, and HTTP processing.

In Active Server Pages, it is important to realize that each statement must appear on a line by itself. There is no special delimiter that indicates the end of an ASP statement. Unless you consider the carriage-return as the delimiter, which you really shouldn't.

You can use the colon character ":" within a program block to place multiple statements on the same line such as:

In practice, it is best to avoid such programming constructs since it will make your code harder to read and maintain.

Another way to include more than one statement on a line is by using multiple code blocks like in the following:

Here, you have two different statements (even though they look like one statement) broken into two different code blocks. Active Server Pages allows this construct on your web pages since it is sometimes necessary to write code like this to eliminate white space that appears on your web page.

Variables
One of the hallmarks of a good scripting language is that the variables in the language are loosely typed. This means that there is minimal type-checking done on the values of the variables your program code uses. Active Server Pages was built correctly as a scripting language to be loosely typed. This allows you, as the programmer, to worry less about what type a variable is which frees you from a lot of work converting values and testing for the correct type.

You are not required to declare your variables before you use them (or even at all if you so wish). The one exception to this rule is when the page directive "Option Explicit" is in effect. If you place the following at the top of your ASP page, you will be required to declare all variables:

If you don't want this requirement in all your scripts, you can leave it out. It is a useful tool to throw onto a page to check for mis-spelled or mis-used variable names. If you mis-spelled a variable, you will likely see "variable not defined".

Variables are declared with a Dim statement and can include a single variable at-a-time or a comma-delimited list of variable names like shown in the following example:

There is no such thing as a global variable in the ASP language. All variables are specific to the web page they are processed in. Once the page is done processing the values are lost. One exception to this is the Application object. It can hold a number of different values, each of which is associated with a string value. Another way is to pass variables in a web form or part of the URL in the Request object. More information on these topics will be covered later.

Comments
Comments are notations you can make on your web page within an ASP script block that will not be output on the web page. For all intents and purposes, they are hidden from your site visitors since they cannot view the ASP source code for your web pages. This allows you to make comments about what your code is doing.

Active Server Pages uses the quote character (') to define comments. This comment is a "line comment" meaning that it will comment out everything following it up until the end of the line. There is no multi line comment in ASP. In order to comment multiple lines, each line must be preceded by a quote (').

Server-Side Includes (SSI)
Server-Side Includes allow you to retrieve code from one web page and insert it into another page. This allows you to create common pieces of code and HTML which only need to be maintained in one place. Other web pages can include this content within their pages using this server directive.

If you are using server-side include directives, you cannot place ASP code within the directive. This is because the directive is evaluated before the ASP code is interpreted. So trying to do something like the following is illegal:

But this doesn't mean that you can't place ASP code inside an included file. So if you include a file called /lib/common.asp, you can place ASP code inside that file (just like you would a normal ASP page) and it will be evaluated by IIS and the results will be placed in the calling page.

An interesting note is that your main page can use a ".html" extension and include (via SSI) an ASP page and the included file will be interpreted and processed as ASP and included in the HTML page.

The two different types of Server-Side includes allow you to retrieve and include files based on the absolute path (based on the Web site root) or relative to the calling page as shown below;

There are benefits to using both. A good rule of thumb is this: if you expect you will be moving entire folders (or trees) of your web application then relative paths are more appropriate. If you expect things to stay pretty much where you created them then you should use absolute paths.

Please note: When using IIS6 (Windows 2003 Server), relative paths are not enabled by default, which will cause any Server-Side includes using relative paths to cease functioning.

= Review Questions =

 * What are the three different types of script delimiters?
 * What file extension must be used when writing an ASP web page?
 * Which web server must be used to interpret ASP web pages?
 * How do you declare a variable?
 * How do you enforce the rule that all variables must be declared?
 * What are the benefits of server-side includes?
 * When should you use absolute server-side includes (SSI)?
 * How do you terminate a statement in ASP?
 * What is an "interpreted" scripting language?
 * How do you write comments in Active Server Pages?
 * How do you make "block comments" in ASP?
 * Which database works best with ASP?

= Exercises =

Career Fair or Exhibition

= External Links =
 * ASP Tutorials

title: Active Server Pages/Basic ASP Syntax


text:
Talk:Conlang/Beginner/Writing

Shorten
Maybe this article should be shortened, and some of the material moved to an Intermediate Conscripting article. --Jim Henry 22:21, 10 August 2005 (UTC)

 * I tentativly agree. Any ideas on which topics to move? -- Ingolemo 19:08, 11 August 2005 (UTC)

 * Probably most of the material in the "Glyphs" section, and the bit about boustrophedon in the "Writing Direction" section. Also the "now you can write in your own script" bit. --Jim Henry 21:14, 11 August 2005 (UTC)

 * I should mention that I'm a little wary of editing this article myself due to an off-wiki incident that I don't want to get into. But, by all means, go ahead yourself. - Ingolemo 18:43, 17 August 2005 (UTC)

Recommendation
The Beginner section is supposed to avoid overwhelming the novice with details and technical terms. I'm not going to prune right now, because Intermediate/Writing is itself in trouble, and it seems prudent to wait to prune here until after one can compare this to a stable version of that. At a minimum, though, the terms for different types of scripts (abugidas, etc.) don't belong here, and the detailed identifications of different examples are a bit overwhelming too. If there are parentheticals under the script type bullets at all, they should probably be short and sweet, like they were a year or more ago. (The introduction of the distinction between Japanese kana and kanji, which looked like such a reasonable step at the time since one certainly doesn't want misinformation in the Beginner section, seems to have been where these parentheticals started down the slippery slope to where they are now.) Pi zero (talk) 13:00, 3 September 2008 (UTC)

 * Okay, I've done the "minimum", lopping off the technical terms and detailed examples from the types of scripts. Pi zero (talk) 00:26, 5 September 2008 (UTC)

Writing in Circles?
Near the end there is a reference to Ogham being written in a circle, yet I find no reference to that in the Wiki article. Can we get an editor to either fix the mention here or add the relevant info there?

Thanks, Westley Turner (discuss • contribs) 21:08, 6 November 2017 (UTC)

 * Searching the Internet, the Buckquoy spindle-whorl is an example. --Pi zero (discuss • contribs) 04:06, 7 November 2017 (UTC)

title: Talk:Conlang/Beginner/Writing


text:
Cookbook:Potato Pancakes

| Cuisine of Israel

Ingredients

 * 4 large potatoes
 * 1 medium onion
 * 1 egg, beaten
 * 2 tablespoons Matzo meal, corn meal, or flour
 * Salt to taste
 * 2 tablespoons vegetable oil
 * Applesauce and/or sour cream

Procedure

 * 1) Peel and grate potatoes and onion.
 * 2) Mix potato and onion with egg, matzo meal, and salt.
 * 3) Heat oil in a 10-inch pan over medium heat until it is quite hot. Drop 1–2 tablespoons of the potato mixture onto the pan per pancake. Turn once to allow both sides to fry.
 * 4) Serve with applesauce and/or sour cream as a topping.

title: Cookbook:Potato Pancakes


text:
Active Server Pages/Variable Types

= Objectives =

In this section you will learn about variables in Active Server Pages. This includes naming conventions, how they are declared, different primitive types and naming conventions. After studying this section, you should have a firm grasp of the types of variables available to you and how to work with different types in a web application.

= Content =

All variables in ASP are loosely typed. This means that you don't need to declare variables with a type. It also means that you can assign the value of any variable to any other variable. There are a few exceptions to this rule as we will see.

Basically, every variable in ASP has the major type of Variant. It is "variant" meaning that the type of value it holds can vary. Basically, the ASP interpreter will handle all conversion between types automatically when you group more than one variable or type together in a single expression.

Variable Scope
There are three different scopes for variables used in ASP. The first is page scope meaning that the variable is available for the entire duration. These are typically declared at the top of the page. The second type of variables are procedure scoped variables which are declared inside a procedure or function declaration. The third type of variables are scoped with a class definition which is used for object-oriented programming.

Page-scoped variables will be visible to all code included on your web page including procedures and functions. You can even access page-scoped variables within a class although good object-oriented design would strongly discourage this practice.

Procedure-scoped variables will only be visible within the procedure in which they are defined. It is perfectly acceptable to use the same variable name for a page-scoped variable and a procedure-scoped variable. Keep in mind, that when you do this, you will hide the page-scoped variable and will have no way to access it within the procedure.

Class-scoped variables can only be accessed through an instance of the class. There is no notion of static variables or static methods in the simplified ASP scripting language. You will need to use the ObjectName.VariableName syntax in order to access member variables directly. Only variable declared Public can be accessed in this way. Private class variables can only be accessed by code defined within the class. More information about using classes in Active Server Pages will be discussed later.

Valid Variable Names
To be valid, an ASP variable name must follow the following rules:

 * Must begin with an alphabetic character
 * All other characters must be alphanumeric or underscore ("_")
 * Name must not exceed 255 characters in length
 * Name must be unique within the scope it is defined
 * Name must not be the same as a reserved word of built in functions, procedures, and objects.

Variable names, just like statements are case-insensitive. This means that if you declare a variable with the name "myVar", you can access it using "MYVAR" or "myvar" or even "MyVaR".

One way to avoid using reserved words and make it easier to identify what type of variables you are using is to use a naming convention. Usually the first letter or few letters of the variable names what information it holds.

Examples:
 * nCount n for integer or number, holds a value that is used to count something, like for control loops.
 * sName s for string, holds a value that represents a name.
 * bIsActive b for boolean, holds true or false values, in this case true if something is active, false if it is not.

Following a naming convention can help avoid messy code, and leads to good programming habits. It also allows somebody else to work with your code and help debug it or modify it. Along with a naming convention, use comments as well to document what the variable is to be used for in the ASP page.

Examples:

You will learn more on naming conventions later on in this document.

Declaring Variables
To declare a variable, you use the Dim statement for page and procedure-scoped variables. After the Dim statement, you can put a comma-separated list of variable names. If you prefer, you can just put one variable on each line. This allows you to add comments about each variable you declare.

You should place your variables in a consistent location on the page or within your procedures. Typically, most people place the declarations at the very top (beginning) of the page or the top of the procedure. Others think it makes more sense to place the variable declarations right above the location where they are first used.

Primitive Types
When we talk about primitive types, we are talking about low-level variables types that cannot be broken down into smaller primitive types. Basically, these are the "built-in" variables that Active Server Pages understands.

These are sometimes referred to the "sub-type" of the variable since the major type of the variable is "variant". Each variable may have one of the sub-types shown in the following table. If you have used other programming languages, then these primitive types will be very familiar to you.

Special Values
In addition to the values shown above, the following special values may also be assigned to Active Server Page variables:

The empty value is the default value for newly declared variables (never assigned any value.) If tested in a boolean context, it is equivalent to "false" or tested in a string context it is equivalent to the empty string ("")

Conversion and Verification
You don't need to concern yourself much with setting the type of the variable. This is done pretty much automatically for you. In the event that you want to set the type that is assigned to a variable, you can use the ASP conversion function that corresponds to each type.

Also, there are verification functions available to make sure a variable is compatible with the specified type. This doesn't mean that the variable has that sub-type. Rather, it means that the variable can successfully be converted to the type.

Literal Values
Literal values are values you insert into your ASP code and use in expressions. By itself, a literal value has no use, but when used in a statement such as an assignment or output statement

You will notice that there is no way to specify a date literal in ASP. Therefore, you need to use a function call to build a date value using DateSerial or you can use Now to get the current date and time.

The value for a literal value is bound by the limits specified in the table for primitive types above. If you attempt to use a value that is outside the acceptable range for any of the types, you will receive an error message indicating this fact and your ASP page will terminate execution.

Constant Definitions
In some cases, you might want to create "named constants" instead of using literal values all of the time. This is particularly useful if you create a common include file that will be used in multiple scripts on your site. You define constants using the Const keyword like so:

It is common practice to use all uppercase variables for your constant definitions although this is not required. It simply makes your code easier to read and maintain.

Naming Conventions
A naming convention is a standard way of naming all of the variables used on your site. There are various different methods used for naming variables and a whole chapter could be devoted to this subject. One of the most popular is Hungarian notation where the first letter of the variable name indicates the dominant sub-type for the variable.

The Microsoft standard proposed for Visual Basic is to use a 3-letter naming convention for their variables. This is a little more clear for reading and maintaining code. Some would consider this overkill for a light-weight scripting language.

= Summary =

= Exercises =

title: Active Server Pages/Variable Types


text:
Linguistics/Phonology

The human brain is an amazing piece of work. Every time you utter a sound, or hear one, there are dozens of things that happen subconsciously and take the sound and reduce it to one of several distinct sounds that we use in our language. The problem is that these distinct sounds are different in different languages. When you come into a new language and you hear a sound you're not used to, you automatically try to fit it into one of your previous categories of sounds. This can cause interesting problems.

Let's illustrate this with a (slightly-hypothetical) analogy. There is one group of people from the Land of Men, and another from the Land of Women. In the Land of Men there are only a few colours: red, blue, brown, yellow, pink, green, and a few more. In the Land of Women, however, there are many more: chartreuse, magenta, terracotta, viridian, lavender rose, etc. Whole books could be written about the colours in the land of women, and indeed, some have.

When the men visit the Land of Women, they have no end of trouble. You see their road signs are colour-coded. The women have no problem with this. Their stop signs are rust-coloured and their yield signs are painted in auburn. Now the men, they look at both of these colours and see brown. So as far as they can tell, all stop signs are brown in the Land of Women; however, sometimes women will stop at the stop signs and sometimes they drive right through. Obviously the women must be terrible drivers. Likewise, the women notice the men have an annoying habit of always stopping at yield signs.

Similarly, speakers of different languages compartmentalize the sounds they hear in words into different categories. For instance, in English the words 'toe' and 'so' are distinguished by their initial consonants: 'toe' begins with the sound /t/ while 'so' begins with /s/. However, many speakers of the language Tok Pisin do not differentiate between these sounds, and they may be interchanged without changing the meaning of words (e.g. [tupu] or [supu] for the word tupu, meaning 'soup'). Thus knowing how languages classify sounds is at least as important as knowing what sounds they use in the first place.

We can speak of a language's phonology as being how it carves up the acoustic space into meaningful units. This is an area of study practiced by phonologists.

Phonemes
The basic unit of study of phonology is the phoneme, which may be defined as sets of phones which function as one unit in a language, and provide contrast between different words. In other words, a phoneme is a category that speakers of a language put certain sounds into. For instance, returning to the Tok Pisin example above, the sounds [s] and [t] would both belong to the phoneme /t/. (In the IPA, phonemes are conventionally enclosed in forward slashes //.)

As another example, try pronouncing the English words keys and schools carefully, paying close attention to the variety of [k] in each. You should find that in the first there is a noticeable puff of air (aspiration), while in the second it is absent. These words may be written more precisely phonetically as [kʰiz] and [skulz]. However, since aspiration never changes the meaning of a word, both of these sounds belong to the phoneme /k/, and so the phonetic representations of these words are /kiz/ and /skulz/.

It should be evident why it is appropriate to refer to the phoneme as a level of abstraction away from the phone. We have removed a layer of information which, while interesting in itself, does not interact in many aspects of a language.

The phonemic inventory of a language is the collection of phonemes in a language. We looked at English's in the last chapter.

Allophony
Two phones are called allophones if they belong to the same phoneme. For instance, in Tok Pisin [t] and [s] are allophones of /t/, and in English [k] and [kʰ] are allophones of /k/.

Allophones are often conditioned by their environment, meaning that one can figure out which allophone is used based on context. For example, in most varieties of American English, the English phoneme /t/ is realized as a tap [ɾ] between vowels in normal speech when not preceding a stressed vowel, for example in the word "butter". In a case like this we can say that the plosive [t] and tap [ɾ] allophones of the phoneme /t/ are in complementary distribution, as every environment selects for either one or the other, and the allophones themselves may be referred to as complementary allophones. Similarly [k] and [kʰ] are in complementary distribution, as [k] mainly occurs in the sequence /sk/, while [kʰ] occurs elsewhere.

By contrast, allophones may sometimes co-occur in the same environment, in which case they are in free variation. For example, the English word cat's word-final /t/ phoneme may be realized either with an audible release, or as the tongue held in the gesture without being released. These phones, notated as [t] and [t̚] in the IPA, are free variants, as either is allowed to occur in the same position. Similarly [s] and [t] are free variants for some speakers of Tok Pisin.

Minimal pairs
An important question which may have occurred to you already is: how can we tell what is a phoneme? One of the most robust tools for examining phonemes is the minimal pair. A minimal pair is a pair of words which differ only in one segment. For example, the English words do /du/, too /tu/, you /ju/, moo /mu/ all form minimal pairs with each other. In a minimal pair one can be sure that the difference between the words is phonemic in nature, because the segments in question are surrounded by the same environment and thus cannot be allophones of each other. In other words, they are in contrastive distribution.

This is not a foolproof tool. In some cases it may by chance be impossible to find a minimal pair for two phonemes even though they clearly contrast. In many cases it is possible to find near-minimal pairs, where the words are so similar that it is unlikely that any environment is conditioning an allophone.

Finally this also requires some common sense, since phonemes may be in complementary distribution without being likely allophones. For instance, the English phonemes /h/ and /ŋ/ (both occurring in the word hung /hʌŋ/) can never occur in the same environment, as /h/ is always syllable-initial and /ŋ/ always syllable-final. However few would suggest that these phonemes are allophones. Since English speakers never confuse them, they are auditorily quite different, and substituting one for another in a word would render it unintelligible. Unfortunately there is no hard-and-fast consensus on precisely how to be sure sounds are allophones or not, and in many languages there is vigorous debate.

Phonotactics
Phonotactics are the rules that govern how phonemes can be arranged. Look at the following lists of made-up words:

 * Pfilg
 * Dchbin
 * Riaubg
 * Streelling
 * Mard
 * Droib

The first three are 'unpronounceable' because they violate English's phonotatic constraints: 'pf' and 'dchb' aren't allowed at the start of a syllable, while 'bg' isn't allowed at the end. The next three are nonsensical words, but they do not violate phonotactics, so they have an 'English-like' feel. Lewis Carroll was particularly skilled in the art of creating such words. Some of his creations were immortalised in his poem Jabberwocky. Here are a couple of stanzas from his famed work:

Note that different languages have different phonotactics. The Czech Republic has cities like Brno and Plzeň, while the Mandarin for Amsterdam is Amusitedan. Czech phonotactics allow for really complicated consonant clusters, while Mandarin allows for none.

Morphophonology
Morphophonology (or morphophonemics) looks at how morphology (the structure of words) interacts with phonology. In morphophonology one may talk about underlying or morpho-phonemic representations of words, which is a level of abstraction beneath the phonemic level. To see how this follows from the definition of morphophonology, it is necessary to look at an example. Compare the Biloxi words:

 * de 'he goes' - da 'don't go'
 * ande 'he is' - anda 'be!'
 * ide 'it falls' - ide 'fall!'
 * da 'he gathers' - da 'gather!'

Some also use this approach to deal with cases of neutralization and underspecification. Compare the Turkish words: Similar patterns in other words in Turkish show that while final stops are always devoiced, some will always voice when followed by a vowel added by suffixing, while the others always stay voiceless. Phonemically both ets must be represented as /et/, because phonemes are defined as the smallest units that may make words contrast (be distinguishable), so if we said the word for 'to do' was phonemically /ed/ then the two words would have to contrast! Still, we would like to say that on a more abstract level the word for 'to do' ends in a different segment, which doesn't surface (be realized) in some positions. The level of abstraction above the phoneme is known as an underlying or morpho-phonemic representation, and as is conventional we will indicate it here with pipes ||. Underlyingly, these Turkish words may be represented as |et|, |eti|, |ed|, and |edi|, and in the same way other Turkish words with this type of voicing alternation underlyingly end in a voiced stop, which surfaces as a voiceless phoneme when word-final.
 * et 'meat'
 * eti 'his meat'
 * et 'to do'
 * edi 'he does'

The parallelism between the morpho-phonemic layer and the phonemic layer should be clear. Just like how phonemes surface as phones conditioned by their environment, underlying segments surface as phonemes. The important difference is that the surfacing of morpho-phonemic segments as phonemes occurs after morphological processes (e.g. adding endings on to words) take place. In a sense, morphophonology is morphologically informed, while plain phonology isn't.

Issues
In some theoretical frameworks of speech (such as phonetics and phonology for applied linguistics and language teaching or speech therapy), it is convenient to break up a language's sounds into categorical sounds—that is, sound types called 'phonemes'. The construct of the phoneme, however, is largely a phonological concern in that it is supposed to model and refer to a transcendental entity that superstructurally and/or psychologically sits over the phonetic realizations and common variations of a sound in a language.

For example, if the English phoneme /l/ is posited to subsist, it might be said to do so because the /l/ of 'light' creates a clear contrast with a phonetically similar sounding word, such as 'right' or 'write' (both of which have a distinct /r/ at the beginning instead of a distinct /l/). Thus, 'light' and 'write' are a 'minimal pair' illustrating that, in English at least, phonemic /l/ and phonemic /r/ are distinct sound categories, and that such a distinction holds for realized speech.

Such a model has the profound weakness of circular logic: phonemes are used to delimit the semantic realm of language (lexical or higher level meaning), but semantic means (minimal pairs of words, such as 'light' vs. 'right' or 'pay' vs. 'bay') are then used to define the phonological realm. Moreover, if phonemes and minimal pairs were such a precise tool, why would they result in such large variations of the sound inventories of languages (such as anywhere from 38–50 phonemes for counts of English)? Also, it is the case that most words (regardless of homophones like 'right' and 'write', or minimal pairs like 'right' and 'light') differentiate meaning on much more information than a contrast between two sounds.

The phoneme is really a structuralist and/or psycholinguistic category belonging to phonology that is supposed to subsist ideally over common variations (called 'allophones') but be realized in such ways as the so-called 'clear' [l] at the beginning of a word like 'like' but also as the so-called 'dark' [l] at the end of a word like 'feel'.

Such concerns are really largely outside of the realm of phonetics because structuralist and/or psycholinguistic categories are really about cognitive and mentalist aspects of language processing and acquisition. In other words, the phoneme may (or may not) be a reality of phonology; it is in no way an actual physical part of realized speech in the vocal tract. Realized speech is highly co-articulated, displays movement and spreads aspects of sounds over entire syllables and words. It is convenient to think of speech as a succession of segments (which may or may not coincide closely with phonemes, ideal segments) in order to capture it for discussion in written discourse, but actual phonetic analysis of speech confounds such a model. It should be pointed out, however, that if we wish to set down a representation of dynamic, complex speech into static writing, constructs like phonemes are very convenient fictions to indicate what we are trying to set down (alternative units in order to capture language in written form, though, include the syllable and the word).

Exercise 1: Kalaallisut
Kalaallisut, or Greenlandic, is an Eskimo-Aleut language spoken by most of the population of Greenland, and has more speakers than all other Eskimo-Aleut languages combined. While Kalaallisut is currently written using five vowel letters, it is analyzed as having only three underlying vowel phonemes. From the following words, deduce Kalaallisut's phonemic vowel inventory and what conditions the allophonic vowels:

 * assaat - forearm
 * assoqquppaa - goes windward of it
 * assoruuppoq - pulls himself together
 * ilisimannippoq - has knowledge of something
 * isuma - mind
 * kikkut - which, whom, whose (pl.)
 * mulequt - leaf
 * nukarlersaat - the youngest of them
 * nuliariipput - they are married
 * orsuut - blubber
 * paamaarpoq - is slow
 * paaq - soot
 * qinnilinnik piiaat - screwdriver
 * sakiak - rib
 * terlippoq - is safe
 * uagut - we
 * utoqqaq - old
 * uffarvik - bathtub
 * ullortuvoq - the day is long
 * versi - verse

(Words taken from this Greenlandic English Dictionary.)

title: Linguistics/Phonology


text:
User:Sma

...

title: User:Sma


text:
PHP Programming/Functions

Introduction
Functions (or methods in the context of a class/object) are a way to group common tasks or calculations to be re-used simply.

Functions in computer programming are much like mathematical functions: You can give the function values to work with and get a result without having to do any calculations yourself.

You can also find a huge list of predefined functions built into PHP in the PHP Manual's function reference.

How to call a function
Note that echo is not a function. "Calling a function" means causing a particular function to run at a particular point in the script. The basic ways to call a function include:
 * calling the function to write on a new line (such as after a ";" or "}")
 * calling the function to write on a new line inside a control
 * assigning the returned value of a function to a variable "$var = function"
 * calling a function inside the argument parentheses (expression) of a control

In our earlier examples we have called several functions. Most commonly we have called the function print to print text to the output. The parameter for echo has been the string we wanted printed (for example print("Hello World!") prints "Hello World!" to the output).

If the function returns some information, we assign it to a variable with a simple assignment operator "=":

Parameters
Parameters are variables that exist only within that function. They are provided by the programmer when the function is called and the function can read and change them locally (except for reference type variables that are changed globally, which is a more advanced topic).

When declaring or calling a function that has more than one parameter, you need to separate between different parameters with a comma ','.

A function declaration can look like this:

To call this function, you must give the parameters a value. It doesn't matter what the value is, as long as there is one:

Output:

Hello World

When declaring a function, you sometimes want to have the freedom not to use all the parameters. Therefore, PHP allows you to give them default values when declaring the function:

These values will only be used, if the function call does not include enough parameters. If there is only one parameter provided, then $var2 = "I'm Learning PHP":

Output:

Hello I'm Learning PHP

Another way to have a dynamic number of parameters is to use PHP's built-in func_num_args, <tt>func_get_args</tt>, and <tt>func_get_arg</tt> functions.

or

The above functions would calculate the arithmetic mean of all of the values passed to them and output it. The difference is that the first function uses <tt>func_num_args</tt> and <tt>func_get_arg</tt>, while the second uses <tt>func_get_args</tt> to load the parameters into an array. The output for both of them would be the same. For example:

Output:

Mean: 27

Returning a value
This function is all well and good, but usually you will want your function to return some information. Generally there are two reasons why a programmer would want information from a function:
 * 1) The function does tasks such as calculations, and we need the result.
 * 2) A function can return a value to indicate, if the function encountered any errors.

To return a value from a function use the <tt>return</tt> statement in the function.

Example PHP script:

Result:

The result of 1 + 6 + 9 is 16

Notice that a <tt>return</tt> statement ends the function's course. If anything appears in a function declaration after the <tt>return</tt> statement is executed, it is parsed but not executed. This can come in handy in some cases. For example: Notice that there is no <tt>else</tt> after the <tt>if</tt>. This is due to the fact that, if <tt>$divider</tt> does equal <tt>0</tt>, the <tt>return</tt> statement is executed and the function stops.

If you want to return multiple variables, you need to return an array rather than a single variable. For example:

When calling this from your script, you need to call it into an array. For example:

In this case <tt>$return['tot']</tt> will be the total (e.g. 15), while <tt>$return['diff']</tt> will be the difference (5).

Runtime function usage
A developer can create functions inside a PHP script without having to use the <tt>function name($param...) {}</tt> syntax. This can be done by way of programming that can let you run functions dynamically.

Executing a function that is based on a variable's name
There are two ways to do it: either using the direct call, or the <tt>call_user_func</tt> or the <tt>call_user_func_array</tt>:

Using <tt>call_user_func*</tt> functions to call functions
<tt>call_user_func</tt> and <tt>call_user_func_array</tt> only differ in that the <tt>call_user_func_array</tt> allows you to use the second parameter as array to pass the data very easily, and <tt>call_user_func</tt> has an infinite number of parameters that is not very useful in a professional way. In these examples, a class will be used for a wider range of using the example:

Using <tt>call_user_func</tt>:

Using <tt>call_user_func_array</tt>:

Note how <tt>call_user_func</tt> and <tt>call_user_func_array</tt> are used in both of the examples. <tt>call_user_func_array</tt> allows the script to execute the function more dynamically.

As there was no example of using both of these functions for a non-class function, here they are:

Using <tt>call_user_func</tt>:

Using <tt>call_user_func_array</tt>:

Creating runtime functions
Creating runtime functions is a very good way of making the script more dynamic:

<tt>create_function</tt> creates a function with parameters <tt>$one</tt> and <tt>$two</tt>, with a code to evaluate return… When <tt>create_function</tt> is executed, it stores the function's info in the memory and returns the function's name. This means that you cannot customise the name of the function although that would be preferred by most developers.

title: PHP Programming/Functions


text:
Talk:European History/Renaissance Europe

I added some info on donatello, added his works

Error
This isn't correct: Thus, Italian scholars called for a 'renascence' (most likely from which "Renaissance" is derived, meaning 'rebirth') in European education and culture. The term renaissance means "rebirth in French"

Fixed the error; sorry about any confusion it might have caused. --Ccny930 00:07, 29 June 2007 (UTC)

Use of the term Dark Ages
The term "the mega faggot" has been proven to be more the invention of earlier historians who tended to view the middle ages as a period where knowledge was lost in a mist of ignorance and superstition. Its also referred to as "the dark ages" because there were gaps in our knowledge of this period. The loss of knowledge has been proven not to be the case and we're filling in the historical gaps. Admittedley the main thrust of modern thinking came from the Renaissance but to imagine that the Acropolis (such a visible remnant of Classical Greece) or the works of Herodotus or Virgil were not studied is wrong. The Renaissance may actual be an "information" revolution (just as we're now experiencing with the internet) and that knowledge was not lost but simply was not widely available to study. Its not so much that the West was devoid of knowledge and enquiry - more probable that the invention of the printing press allowed for the greater availability of books and this is turn led to more studies of the classics by more people. There are countless other Renaissance inventions like the telescope, modern banking, clocks, new sea routes and much more that made the Renaissance "information highway" a borderless conduit for knowledge.

I'll remove the term when I come across it though if anyone disagrees please feel free to revert my edits.

Sluffs (discuss • contribs) 00:16, 19 September 2012 (UTC)


text:
Active Server Pages/Conditionals and Looping

= Objectives =

In this section we will introduce the basic program flow-control statements available to you in Active Server Pages. This includes conditional statement and looping constructs. After studying this section, you should have a good understanding of how to use Active Server Pages to make decisions based on expressions. You should also understand how to repeat a block of program code based on conditions you define.

= Content =

Conditional statements are used by your program to make decisions and decide what the program should do next. An example of this would be deciding whether a user has entered the correct password for your site by comparing the password entered with the correct password. If the user passes the test, they are sent to their account management Web page. If they fail, they are sent back to the login screen with an error indicating the "password is invalid".

This kind of decision making is common in all programming languages. You need to master this aspect of Active Server Pages in order to write dynamic web applications.

Another important concept is looping. Looping simply means that you repeat the same block of code multiple times. Since you are going through the code once, going back to the beginning and repeating it again, the direction of program execution looks like a loop (or a circle) which is why we call it looping. We will introduce you to all of the looping methods available to you in this chapter.

Program Flow
In general, program flow starts at the very top of the page and continues all the way down the page in the same way that you read a book. All pages are executed this way in ASP and it makes the code very easy to follow until you get to conditional statements and looping constructs.

Because of the logical flow of the program, it is easy to trace through your program code and output debugging information to see what your script is doing as it gets processed by the ASP interpreter. Through use of the Response.End statement, you can place breakpoints in your script to stop execution at specific points. More about this will be discussed later.

One topic that will not be covered in this section is procedure and object method calls. We will talk about these in later sections.

Conditionals
A conditional statement is one where an expression is evaluated and based on the result one or more actions may be taken. This allows you to check for a certain condition and take a specific action that is required when the condition is or is not met.

If-Then Statement
The "If-Then" statement is the most basic conditional statement. When put on a single line, this statement says "If the condition is met, then do this." For example, we could test to see if someone is old enough to vote with:

You may optionally, create an If-Then statement that encloses a block of statements. A block of statements means more than one statement grouped together. In this case, the entire block of statements will be executed only when the condition is met. We use indenting in this case to help us read the code and determine where the block starts and ends.

As you can see in this program block, the If Then statement defines the start of the program block while the End If statement defines the end of the program block. The program block is indented to make it easier to match the start and end of the block. All of the statements in this program block will only be executed if the conditional statement is met (nAge > 18). When it is not, nothing will be done.

If-Then-Else
The If Then statement is great, but what if you want to perform two different actions. One action to be taken when the condition is met and one action to be taken when the condition is not met. That is what the If Then Else statement was create to handle. It basically says: "If the condition is met, then do this, otherwise do this".

As you can see from the example above, you can put the entire If Then Else statement in one line. In many cases, you will want to avoid this since it tends to make the length of the line very long. Instead, you will probably want to use the program block form like so:

In this case, only one of the two program blocks will be executed. The first will be executed when the condition is met. The second will be executed when the condition is not met. So you can think of the If Then Else statement as saying "one or the other but not both".

Although we are using more than one statement in the program blocks shown above, you could also put a single statement within each program block. For debugging purposes, you can even have no statements at all within a program block. This allows you to comment out all the statements in a program block and your script will still run no problem.

You will notice that in the conditional expression for the If Then statement, we did not have to enclose the condition with parentheses "(" and ")". You can always use parentheses for grouping expressions together but they are not required to enclose conditional statements.

Select Case
The If Then statements are great if you are just evaluating a "true" or "false" condition. But if you want to evaluate an expression other than a boolean and take some action based on the result, you will need another mechanism. This is why the ASP language includes the Select Case statement. This allows you to basically "select" from a list of many cases, the action to perform.

The cases for a Select Case are all literal primitive values. You must have an "exact match" in order to match a "case". You may include more than one value to match, but you may not define ranges of values to match, nor may you define a pattern to match.

This select statement is a little deceiving, because it will only tell you that you can vote if the age is 18 and only 18. If the age is greater than 18, then none of the specific cases will be matched. Instead, the optional catch-all case (Case Default) will be executed when the age is greater than 18.

Of course, you don't need to include the Case Default if you don't need it. By leaving it off, you are basically saying "do nothing if an exact match for a case is not found".

You can use any expression for the Select Case as long as it evaluates to a primitive type. You can not use an object expression because there is no such thing as an object literal to compare it to. However, you can call an object method that returns a primitive type and use this as the expression.

In the example shown above, you can see that we are using the carriage return to separate the Case from the block to be executed. There is no need to terminate this type of program block. It is terminated by the instance of the next case or the End Select. You may also put the case and the action to perform on the same line by using the colon as a statement separator:

Looping Constructs
Looping constructs are used for repeating the same step over-and-over again. There may be many reasons to use a loop. In database-driven web applications, you will often use a loop to iterate over each record returned from a recordset.

For Next Loop
The "for next" loop allows you to repeat a block of code using an incremental counter. The counter is initialized at the start of the loop and then incremented at the end of the loop. At the start of each repetition, the counter is checked to see if it has exceeded the ending value. This is best explained by using an example:

In this example, we have created a loop that is repeated 10 times. We know it executes exactly ten times because you can read the statement as "for every whole integer from 1 to 10, do this".

The variable "I" is initialized with a value of 1 and the first repetition of the program block (indented) is executed. The output will be "I = 1". Don't worry about the "<br>" part, this is just HTML code to create a line break on the web page.

The second time through the loop, the counter (I) is incremented and takes on a value of 2. So the second line output by this block is "I = 2". This process repeats as I is incremented one at a time until the counter exceeds the end value. So in this case, the last line printed will be "I = 10".

In a more advanced case, we can change the way in which the index is incremented. If we wanted the counter to increment by 2, we would write the For Next loop as follows:

The output of this code will be:

I = 1 I = 3 I = 5 I = 7 I = 9

This time we only get five values output by the loop. This is because we are incrementing the counter by 2 instead of by 1 (the default.) Notice that we do not have to finish on the ending value (10). After incrementing the counter from 9 to 11, the loop checks to see if we have exceeded the ending value (10) and exits the loop.

You can also count backwards like this:

And of course, you can substitute expressions and variables for the starting and ending values and even the amount to "step through" the loop:

Do While
Another looping construct is the Do While loop which will repeat a block of program code as long as the condition is met. This is kind of like the If Then conditional statement in that it expects a boolean expression. Here is what it looks like:

What we have here is a loop that does exactly the same thing as the For Next example shown in the previous section. Why would you want to use this construct instead of a "for next"? The problem becomes obvious when it is not easy to determine how many repetitions of the loop you need to do.

In this case, we do not know how many times we will have to divide the value of X by two until we end up with a value less than or equal to 1. So we just use the Do While loop to handle the logic for us.

Do Until
Almost identical to the Do While looping construct is the Do Until. It works exactly the same way except that it repeats the program block until the condition evaluates to "true". You could basically do the same thing with "Do While" by enclosing your expression with Not (expr), but the creators of ASP realized that the code would be cleaner using this more logical statement.

Here, we have created a loop that does exactly the same thing as our "do while". We just reversed the logic of the conditional statement and changed the keywords to Do Until. In this case, it doesn't make the code that much cleaner to read. But as we will see later, there are definite cases where you will want to use Do Until.

While
The While loop works exactly the same as the Do While except that it has a little shorter construct. Please read the section on "Do While" to understand how this looping construct works.

Unlike the "Do" loops, the While loop program block is terminated by the Wend statement. = Summary =

Active Server Pages has many different control flow statements to handle the execution of your ASP page. The conditional statements are: If Then, If Then Else and Select Case. The looping constructs are For Next, Do While, Do Until and While. Conditional expressions in ASP do not need to be enclosed in parentheses ("(" and ")").

For Next loops manipulate a counter and repeat the program block until the counter exceeds the ending value. Do While, Do Until and While loops repeat based on the evaluation of a boolean expression (meaning an expression resulting in the value of "true" or "false").

= Review Questions =

 * What types of conditional statements are available in ASP?
 * What types of looping constructs are available in ASP?
 * What are the three parameters for a For Next loop.
 * How do you count backwards using a For Next loop.
 * What loop would you use to repeat until a condition is satisfied?
 * What loop would you use to repeat while a condition is satisfied?
 * How do you terminate a program block for a Do While loop?
 * How do you terminate a program block for a While loop?

= Exercises =

 * Create a For Next loop that outputs integers from 10 to 100 that are evenly divisible by 10


text:
68000 Assembly

Contents

 * /Who used the 68k series?/
 * /Registers/
 * /Addressing Modes/
 * /Conditional Tests/
 * /Labels/
 * /Instruction Set/
 * /Further reading/

title: 68000 Assembly


text:
Algorithms/Introduction

This book covers techniques for the design and analysis of algorithms. The algorithmic techniques covered include: divide and conquer, backtracking, dynamic programming, greedy algorithms, and hill-climbing.

Any solvable problem generally has at least one algorithm of each of the following types:

 * 1) the obvious way;
 * 2) the methodical way;
 * 3) the clever way; and
 * 4) the miraculous way.

On the first and most basic level, the "obvious" solution might try to exhaustively search for the answer. Intuitively, the obvious solution is the one that comes easily if you're familiar with a programming language and the basic problem solving techniques.

The second level is the methodical level and is the heart of this book: after understanding the material presented here you should be able to methodically turn most obvious algorithms into better performing algorithms.

The third level, the clever level, requires more understanding of the elements involved in the problem and their properties or even a reformulation of the algorithm (e.g., numerical algorithms exploit mathematical properties that are not obvious). A clever algorithm may be hard to understand by being non-obvious that it is correct, or it may be hard to understand that it actually runs faster than what it would seem to require.

The fourth and final level of an algorithmic solution is the miraculous level: this is reserved for the rare cases where a breakthrough results in a highly non-intuitive solution.

Naturally, all of these four levels are relative, and some clever algorithms are covered in this book as well, in addition to the methodical techniques. Let's begin.

Prerequisites
To understand the material presented in this book you need to know a programming language well enough to translate the pseudocode in this book into a working solution. You also need to know the basics about the following data structures: arrays, stacks, queues, linked-lists, trees, heaps (also called priority queues), disjoint sets, and graphs.

Additionally, you should know some basic algorithms like binary search, a sorting algorithm (merge sort, heap sort, insertion sort, or others), and breadth-first or depth-first search.

If you are unfamiliar with any of these prerequisites you should review the material in the Data Structures book first.

When is Efficiency Important?
Not every problem requires the most efficient solution available. For our purposes, the term efficient is concerned with the time and/or space needed to perform the task. When either time or space is abundant and cheap, it may not be worth it to pay a programmer to spend a day or so working to make a program faster.

However, here are some cases where efficiency matters:

 * When resources are limited, a change in algorithms could create great savings and allow limited machines (like cell phones, embedded systems, and sensor networks) to be stretched to the frontier of possibility.

 * When the data is large a more efficient solution can mean the difference between a task finishing in two days versus two weeks. Examples include physics, genetics, web searches, massive online stores, and network traffic analysis.

 * Real time applications: the term "real time applications" actually refers to computations that give time guarantees, versus meaning "fast." However, the quality can be increased further by choosing the appropriate algorithm.

 * Computationally expensive jobs, like fluid dynamics, partial differential equations, VLSI design, and cryptanalysis can sometimes only be considered when the solution is found efficiently enough.

 * When a subroutine is common and frequently used, time spent on a more efficient implementation can result in benefits for every application that uses the subroutine. Examples include sorting, searching, pseudorandom number generation, kernel operations (not to be confused with the operating system kernel), database queries, and graphics.

In short, it's important to save time when you do not have any time to spare.

When is efficiency unimportant? Examples of these cases include prototypes that are used only a few times, cases where the input is small, when simplicity and ease of maintenance is more important, when the area concerned is not the bottle neck, or when there's another process or area in the code that would benefit far more from efficient design and attention to the algorithm(s).

Inventing an Algorithm
Because we assume you have some knowledge of a programming language, let's start with how we translate an idea into an algorithm. Suppose you want to write a function that will take a string as input and output the string in lowercase:

// tolower -- translates all alphabetic, uppercase characters in str to lowercase function tolower(string str): string

What first comes to your mind when you think about solving this problem? Perhaps these two considerations crossed your mind: The first point is "obvious" because a character that needs to be converted might appear anywhere in the string. The second point follows from the first because, once we consider each character, we need to do something with it. There are many ways of writing the tolower function for characters:
 * 1) Every character in str needs to be looked at
 * 2) A routine for converting a single character to lower case is required

function tolower(character c): character

There are several ways to implement this function, including:

 * look c up in a table—a character indexed array of characters that holds the lowercase version of each character.

 * check if c is in the range 'A' ≤ c ≤ 'Z', and then add a numerical offset to it.

These techniques depend upon the character encoding. (As an issue of separation of concerns, perhaps the table solution is stronger because it's clearer you only need to change one part of the code.)

However such a subroutine is implemented, once we have it, the implementation of our original problem comes immediately:

// tolower -- translates all alphabetic, uppercase characters in str to lowercase function tolower(string str): string let result := "" for-each c in str: result.append(tolower(c)) repeat return result end

The loop is the result of our ability to translate "every character needs to be looked at" into our native programming language. It became obvious that the tolower subroutine call should be in the loop's body. The final step required to bring the high-level task into an implementation was deciding how to build the resulting string. Here, we chose to start with the empty string and append characters to the end of it.

Now suppose you want to write a function for comparing two strings that tests if they are equal, ignoring case:

// equal-ignore-case -- returns true if s and t are equal, ignoring case function equal-ignore-case(string s, string t): boolean

These ideas might come to mind:
 * 1) Every character in strings s and t will have to be looked at
 * 2) A single loop iterating through both might accomplish this
 * 3) But such a loop should be careful that the strings are of equal length first
 * 4) If the strings aren't the same length, then they cannot be equal because the consideration of ignoring case doesn't affect how long the string is
 * 5) A tolower subroutine for characters can be used again, and only the lowercase versions will be compared

These ideas come from familiarity both with strings and with the looping and conditional constructs in your language. The function you thought of may have looked something like this:

// equal-ignore-case -- returns true if s or t are equal, ignoring case function equal-ignore-case(string s[1..n], string t[1..m]): boolean if n != m: return false              \if they aren't the same length, they aren't equal\ fi  for i := 1 to n: if tolower(s[i]) != tolower(t[i]): return false fi  repeat return true end

Or, if you thought of the problem in terms of functional decomposition instead of iterations, you might have thought of a function more like this:

// equal-ignore-case -- returns true if s or t are equal, ignoring case function equal-ignore-case(string s, string t): boolean return tolower(s).equals(tolower(t)) end

Alternatively, you may feel neither of these solutions is efficient enough, and you would prefer an algorithm that only ever made one pass of s or t. The above two implementations each require two-passes: the first version computes the lengths and then compares each character, while the second version computes the lowercase versions of the string and then compares the results to each other. (Note that for a pair of strings, it is also possible to have the length precomputed to avoid the second pass, but that can have its own drawbacks at times.) You could imagine how similar routines can be written to test string equality that not only ignore case, but also ignore accents.

Already you might be getting the spirit of the pseudocode in this book. The pseudocode language is not meant to be a real programming language: it abstracts away details that you would have to contend with in any language. For example, the language doesn't assume generic types or dynamic versus static types: the idea is that it should be clear what is intended and it should not be too hard to convert it to your native language. (However, in doing so, you might have to make some design decisions that limit the implementation to one particular type or form of data.)

There was nothing special about the techniques we used so far to solve these simple string problems: such techniques are perhaps already in your toolbox, and you may have found better or more elegant ways of expressing the solutions in your programming language of choice. In this book, we explore general algorithmic techniques to expand your toolbox even further. Taking a naive algorithm and making it more efficient might not come so immediately, but after understanding the material in this book you should be able to methodically apply different solutions, and, most importantly, you will be able to ask yourself more questions about your programs. Asking questions can be just as important as answering questions, because asking the right question can help you reformulate the problem and think outside of the box.

Understanding an Algorithm
Computer programmers need an excellent ability to reason with multiple-layered abstractions. For example, consider the following code:

function foo(integer a): if (a / 2) * 2 == a: print "The value " a " is even." fi end

To understand this example, you need to know that integer division uses truncation and therefore when the if-condition is true then the least-significant bit in a is zero (which means that a must be even). Additionally, the code uses a string printing API and is itself the definition of a function to be used by different modules. Depending on the programming task, you may think on the layer of hardware, on down to the level of processor branch-prediction or the cache.

Often an understanding of binary is crucial, but many modern languages have abstractions far enough away "from the hardware" that these lower-levels are not necessary. Somewhere the abstraction stops: most programmers don't need to think about logic gates, nor is the physics of electronics necessary. Nevertheless, an essential part of programming is multiple-layer thinking.

But stepping away from computer programs toward algorithms requires another layer: mathematics. A program may exploit properties of binary representations. An algorithm can exploit properties of set theory or other mathematical constructs. Just as binary itself is not explicit in a program, the mathematical properties used in an algorithm are not explicit.

Typically, when an algorithm is introduced, a discussion (separate from the code) is needed to explain the mathematics used by the algorithm. For example, to really understand a greedy algorithm (such as Dijkstra's algorithm) you should understand the mathematical properties that show how the greedy strategy is valid for all cases. In a way, you can think of the mathematics as its own kind of subroutine that the algorithm invokes. But this "subroutine" is not present in the code because there's nothing to call. As you read this book try to think about mathematics as an implicit subroutine.

Overview of the Techniques
The techniques this book covers are highlighted in the following overview.

 * Divide and Conquer: Many problems, particularly when the input is given in an array, can be solved by cutting the problem into smaller pieces (divide), solving the smaller parts recursively (conquer), and then combining the solutions into a single result. Examples include the merge sort and quicksort algorithms.

 * Randomization: Increasingly, randomization techniques are important for many applications. This chapter presents some classical algorithms that make use of random numbers.

 * Backtracking: Almost any problem can be cast in some form as a backtracking algorithm. In backtracking, you consider all possible choices to solve a problem and recursively solve subproblems under the assumption that the choice is taken. The set of recursive calls generates a tree in which each set of choices in the tree is considered consecutively.  Consequently, if a solution exists, it will eventually be found.

Backtracking is generally an inefficient, brute-force technique, but there are optimizations that can be performed to reduce both the depth of the tree and the number of branches. The technique is called backtracking because after one leaf of the tree is visited, the algorithm will go back up the call stack (undoing choices that didn't lead to success), and then proceed down some other branch. To be solved with backtracking techniques, a problem needs to have some form of "self-similarity," that is, smaller instances of the problem (after a choice has been made) must resemble the original problem. Usually, problems can be generalized to become self-similar.

 * Dynamic Programming: Dynamic programming is an optimization technique for backtracking algorithms. When subproblems need to be solved repeatedly (i.e., when there are many duplicate branches in the backtracking algorithm) time can be saved by solving all of the subproblems first (bottom-up, from smallest to largest) and storing the solution to each subproblem in a table. Thus, each subproblem is only visited and solved once instead of repeatedly. The "programming" in this technique's name comes from programming in the sense of writing things down in a table; for example, television programming is making a table of what shows will be broadcast when.

 * Greedy Algorithms: A greedy algorithm can be useful when enough information is known about possible choices that "the best" choice can be determined without considering all possible choices. Typically, greedy algorithms are not challenging to write, but they are difficult to prove correct.

 * Hill Climbing: The final technique we explore is hill climbing. The basic idea is to start with a poor solution to a problem, and then repeatedly apply optimizations to that solution until it becomes optimal or meets some other requirement. An important case of hill climbing is network flow. Despite the name, network flow is useful for many problems that describe relationships, so it's not just for computer networks. Many matching problems can be solved using network flow.

Level 1 (easiest)
1. Find maximum With algorithm and several different programming languages

2. Find minimum With algorithm and several different programming languages

3. Find average  With algorithm and several different programming languages

4. Find mode  With algorithm and several different programming languages

5. Find total  With algorithm and several different programming languages

6. Counting  With algorithm and several different programming languages

7. Find mean With algorithm and several different programming languages

Level 2
1. Talking to computer Lv 1  With algorithm and several different programming languages

2. Sorting-bubble sort  With algorithm and several different programming languages

Level 3
1. Talking to computer Lv 2  With algorithm and several different programming languages

Level 4
1. Talking to computer Lv 3  With algorithm and several different programming languages

2. Find approximate maximum  With algorithm and several different programming languages

Level 5
1. Quicksort

title: Algorithms/Introduction


text:
Algorithms/Mathematical Background

Before we begin learning algorithmic techniques, we take a detour to give ourselves some necessary mathematical tools. First, we cover mathematical definitions of terms that are used later on in the book. By expanding your mathematical vocabulary you can be more precise and you can state or formulate problems more simply. Following that, we cover techniques for analysing the running time of an algorithm. After each major algorithm covered in this book we give an analysis of its running time as well as a proof of its correctness

Asymptotic Notation
In addition to correctness another important characteristic of a useful algorithm is its time and memory consumption. Time and memory are both valuable resources and there are important differences (even when both are abundant) in how we can use them.

How can you measure resource consumption? One way is to create a function that describes the usage in terms of some characteristic of the input. One commonly used characteristic of an input dataset is its size. For example, suppose an algorithm takes an input as an array of $$n$$ integers. We can describe the time this algorithm takes as a function $$f$$ written in terms of $$n$$. For example, we might write:

 * $$f(n) = n^2 + 3n + 14$$

where the value of $$f(n)$$ is some unit of time (in this discussion the main focus will be on time, but we could do the same for memory consumption). Rarely are the units of time actually in seconds, because that would depend on the machine itself, the system it's running, and its load. Instead, the units of time typically used are in terms of the number of some fundamental operation performed. For example, some fundamental operations we might care about are: the number of additions or multiplications needed; the number of element comparisons; the number of memory-location swaps performed; or the raw number of machine instructions executed. In general we might just refer to these fundamental operations performed as steps taken.

Is this a good approach to determine an algorithm's resource consumption? Yes and no. When two different algorithms are similar in time consumption a precise function might help to determine which algorithm is faster under given conditions. But in many cases it is either difficult or impossible to calculate an analytical description of the exact number of operations needed, especially when the algorithm performs operations conditionally on the values of its input. Instead, what really is important is not the precise time required to complete the function, but rather the degree that resource consumption changes depending on its inputs. Concretely, consider these two functions, representing the computation time required for each size of input dataset:

 * $$f(n) = n^3-12n^2+20n+110$$
 * $$g(n) = n^3+n^2+5n+5$$

They look quite different, but how do they behave? Let's look at a few plots of the function ($$f(n)$$ is in red, $$g(n)$$ in blue):

In the first, very-limited plot the curves appear somewhat different. In the second plot they start going in sort of the same way, in the third there is only a very small difference, and at last they are virtually identical. In fact, they approach $$n^3$$, the dominant term. As n gets larger, the other terms become much less significant in comparison to n3.

As you can see, modifying a polynomial-time algorithm's low-order coefficients doesn't help much. What really matters is the highest-order coefficient. This is why we've adopted a notation for this kind of analysis. We say that:

 * $$f(n) = n^3-12n^2+20n+110 = O(n^3)$$

We ignore the low-order terms. We can say that:

 * $$O(\log {n}) \le O(\sqrt{n}) \le O(n) \le O(n \log {n}) \le O(n^2) \le O(n^3) \le O(2^n)$$

This gives us a way to more easily compare algorithms with each other. Running an insertion sort on $$n$$ elements takes steps on the order of $$O(n^2)$$. Merge sort sorts in $$O(n \log {n})$$ steps. Therefore, once the input dataset is large enough, merge sort is faster than insertion sort.

In general, we write

 * $$f(n) = O(g(n))$$

when

 * $$\exists c>0, \exists n_0> 0, \forall n\ge n_{0}: 0\le f(n)\le c\cdot g(n).$$

That is, $$f(n) = O(g(n))$$ holds if and only if there exists some constants $$c$$ and $$n_0$$ such that for all $$n>n_0$$ $$f(n)$$ is positive and less than or equal to $$c g(n)$$.

Note that the equal sign used in this notation describes a relationship between $$f(n)$$ and $$g(n)$$ instead of reflecting a true equality. In light of this, some define Big-O in terms of a set, stating that:

 * $$f(n)\in O(g(n))$$

when

 * $$f(n)\in \{f(n) : \exists c>0, \exists n_0> 0, \forall n\ge n_0: 0\le f(n)\le c\cdot g(n)\}.$$

Big-O notation is only an upper bound; these two are both true:

 * $$n^3 = O(n^4)$$
 * $$n^4 = O(n^4)$$

If we use the equal sign as an equality we can get very strange results, such as:

 * $$n^3 = n^4$$

which is obviously nonsense. This is why the set-definition is handy. You can avoid these things by thinking of the equal sign as a one-way equality, i.e.:

 * $$n^3 = O(n^4)$$

does not imply

 * $$O(n^4) = n^3$$

Always keep the O on the right hand side.

Big Omega
Sometimes, we want more than an upper bound on the behavior of a certain function. Big Omega provides a lower bound. In general, we say that

 * $$f(n) = \Omega(g(n))$$

when

 * $$\exists c>0, \exists n_0> 0, \forall n\ge n_{0}: 0\le c\cdot g(n)\le f(n).$$

i.e. $$f(n) = \Omega(g(n))$$ if and only if there exist constants c and n0 such that for all n>n0 f(n) is positive and greater than or equal to cg(n).

So, for example, we can say that

 * $$n^2-2n = \Omega(n^2)$$, (c=1/2, n0=4) or
 * $$n^2-2n = \Omega(n)$$, (c=1, n0=3),

but it is false to claim that

 * $$n^2-2n = \Omega(n^3).$$

Big Theta
When a given function is both O(g(n)) and Ω(g(n)), we say it is Θ(g(n)), and we have a tight bound on the function. A function f(n) is Θ(g(n)) when

 * $$\exists c_1>0, \exists c_2>0, \exists n_0> 0, \forall n\ge n_0 : 0\le c_1\cdot g(n)\le f(n)\le c_2\cdot g(n),$$

but most of the time, when we're trying to prove that a given $$f(n) = \Theta(g(n))$$, instead of using this definition, we just show that it is both O(g(n)) and Ω(g(n)).

Little-O and Omega
When the asymptotic bound is not tight, we can express this by saying that $$f(n) = o(g(n))$$ or $$f(n) = \omega(g(n)).$$ The definitions are:

 * f(n) is o(g(n)) iff $$\forall c>0, \exists n_0> 0, \forall n\ge n_0: 0\le f(n) < c\cdot g(n)$$ and
 * f(n) is ω(g(n)) iff $$\forall c>0, \exists n_0> 0, \forall n\ge n_0: 0\le c\cdot g(n) < f(n).$$

Note that a function f is in o(g(n)) when for any coefficient of g, g eventually gets larger than f, while for O(g(n)), there only has to exist a single coefficient for which g eventually gets at least as big as f.

Big-O with multiple variables
Given a functions with two parameters $$f(n,m)$$ and $$g(n,m)$$,

$$f(n,m)=O(g(n,m))$$ if and only if $$\exists c > 0, \exists n_0 > 0, \exists m_0 > 0, \forall n \geq n_0, \forall m \geq m_0 : 0 \leq f(n,m) \leq c \cdot g(n,m)$$.

For example, $$5n + 3m = O(n+m)$$, and $$n + 10m + 3nm = O(nm)$$.

Algorithm Analysis: Solving Recurrence Equations
Merge sort of n elements: $$T(n) = 2*T(n/2) + c(n)$$ This describes one iteration of the merge sort: the problem space $$n$$ is reduced to two halves ($$2*T(n/2)$$), and then merged back together at the end of all the recursive calls ($$c(n)$$). This notation system is the bread and butter of algorithm analysis, so get used to it.

There are some theorems you can use to estimate the big Oh time for a function if its recurrence equation fits a certain pattern.

Substitution method
Formulate a guess about the big Oh time of your equation. Then use proof by induction to prove the guess is correct.

Draw the Tree and Table
This is really just a way of getting an intelligent guess. You still have to go back to the substitution method in order to prove the big Oh time.

The Master Theorem
Consider a recurrence equation that fits the following formula:

 * $$T(n) = a T\left({\frac{n}{b}}\right) + O(n^k)$$

for a ≥ 1, b > 1 and k ≥ 0. Here, a is the number of recursive calls made per call to the function, n is the input size, b is how much smaller the input gets, and k is the polynomial order of an operation that occurs each time the function is called (except for the base cases). For example, in the merge sort algorithm covered later, we have

 * $$T(n) = 2 T\left({\frac{n}{2}}\right) + O(n)$$

because two subproblems are called for each non-base case iteration, and the size of the array is divided in half each time. The $$O(n)$$ at the end is the "conquer" part of this divide and conquer algorithm: it takes linear time to merge the results from the two recursive calls into the final result.

Thinking of the recursive calls of T as forming a tree, there are three possible cases to determine where most of the algorithm is spending its time ("most" in this sense is concerned with its asymptotic behaviour):

 * 1) the tree can be top heavy, and most time is spent during the initial calls near the root;
 * 2) the tree can have a steady state, where time is spread evenly; or
 * 3) the tree can be bottom heavy, and most time is spent in the calls near the leaves

Depending upon which of these three states the tree is in T will have different complexities:

The Master Theorem Given $$T(n) = a T\left({\frac{n}{b}}\right) + O(n^k)$$ for a ≥ 1, b > 1 and k ≥ 0:
 * If $$a < b^k$$, then $$T(n) = O(n^k)\ $$ (top heavy)
 * If $$a = b^k$$, then $$T(n) = O(n^k\cdot \log n)$$ (steady state)
 * If $$a > b^k$$, then $$T(n) = O(n^{\log_b a})$$ (bottom heavy)

For the merge sort example above, where

 * $$T(n) = 2 T\left({\frac{n}{2}}\right) + O(n)$$

we have

 * $$a=2, b=2, k=1\implies b^k = 2$$

thus, $$a = b^k$$ and so this is also in the "steady state": By the master theorem, the complexity of merge sort is thus

 * $$T(n) = O(n^1\log n) = O(n \log n)$$.

Amortized Analysis
[Start with an adjacency list representation of a graph and show two nested for loops: one for each node n, and nested inside that one loop for each edge e. If there are n nodes and m edges, this could lead you to say the loop takes O(nm) time. However, only once could the innerloop take that long, and a tighter bound is O(n+m).]

title: Algorithms/Mathematical Background