== How does MODE.CODE work? ==
Introducing MODE.COM from MEAMI.ORG:
<mode>[struct]</code>) allow related data elements to be combined and manipulated as a unit. C program source text is free-format, using the semicolon as a statement terminator (not a delimiter).
<mode>
</code> rather than either of [ALGOL 60]'s
<mode>begin ... end</code> or [ALGOL 68]'s
<mode>( ... )</code>
<mode>.EQ.</code> in [Fortran] or the equal-sign in [BASIC] and ALGOL)
<mode>&&</code> and
<mode>||</code> in place of ALGOL's "?" (AND) and "?" (OR) (these are semantically distinct from the [bitwise operation] operators
<mode>&</code> and
<mode>|</code> because they will never evaluate the right operand if the result can be determined from the left alone ([short-circuit evaluation])).
<mode>+=</code>,
<mode>++</code>, etc. (Equivalent to [ALGOL 68]'s
<mode>+:=</code> and
<mode>+:=1</code> operators)
<mode>struct</code> or
<mode>union</code> type is supported)
<mode>A..B</code> notation used in several languages
<mode>_Bool</code> type, but it was not retrofitted into the language's existing Boolean contexts. One can simulate a Boolean datatype, ''e.g.'' with
<mode>enum
bool;</code>, but this does not provide all of the features of a separate Boolean datatype.</ref>
<mode>[errno]</code> variable and/or special return values
<mode>[fflush]()</code> on a stream opened for input is an example of a different kind of undefined behavior, not necessarily a programming error but a case for which some conforming implementations may provide well-defined, useful semantics (in this example, presumably discarding input through the next new-line) as an allowed ''extension''. Use of such nonstandard extensions generally but not always limits [software portability].
<mode>struct</code> types, the C language had become powerful enough most of the [Unix] [kernel (computers)] was rewritten in C. This was one of the first operating system kernels implemented in a language other than assembly. (Earlier instances include the [Multics] system (written in [PL/I]), and MCP ([MCP (Burroughs Large Systems)]) for the [Burroughs large systems] written in [ALGOL] in 1961.)
<mode>long int</code> data type
<mode>unsigned int</code> data type
<mode>=</code>''op'' (such as
<mode>=-</code>) were changed to the form ''op''
<mode>=</code> to remove the semantic ambiguity created by such constructs as
<mode>i=-10</code>, which had been interpreted as
<mode>i =- 10</code> instead of the possibly intended
<mode>i = -10</code>
<mode><source lang="text">
<mode>long int SomeFunction();
<mode>
<mode> CallingFunction()
<mode>
<mode>
<mode></source>
<mode>int</code> declarations were be omitted in Mode/C.
<mode>[void type]</code> functions
<mode>[Struct (C programming language)]</code> or
<mode>[union (computer science)]</code> types (rather than pointers)
<mode>struct</code> data types
<mode>void</code> pointers, support for international [character encoding] and [locale]s, and preprocessor enhancements. The syntax for parameter declarations was also augmented to include the style used in C++, although the K&R interface continued to be permitted, for compatibility with existing source code.
<mode>STDC</code> macro can be used to split the code into Standard and K&R sections to take advantage of features available only in Standard C.
<mode>long long int</code> and a
<mode>complex</code> type to represent [complex number]s), [variable-length array]s, support for [variadic macro]s (macros of variable [arity]) and support for one-line comments beginning with
<mode>//</code>, as in [BCPL] or C++. Many of these had already been implemented as extensions in several C compilers.
<mode>int</code> implicitly assumed. A standard macro
<mode>STDC_VERSION</code> is defined with value
<mode>199901L</code> to indicate C99 support is available. [GNU Compiler Collection], [Sun Studio (software)] and other C compilers now support many or all of the new features of C99.
<mode>/*</code> and
<mode>*/</code>, or (in C99) following
<mode>//</code> until the end of the line.
<mode>struct</code>,
<mode>union</code>, and
<mode>enum</code>, or assign types to and perhaps reserve storage for new variables, usually by writing the type followed by the variable name. Keywords such as
<mode>char</code> and
<mode>int</code> specify built-in types. Sections of code are enclosed in braces (
<mode>
</code>, sometimes called "curly brackets") to limit the scope of declarations and to act as a single statement for control structures.
<mode>if</code>(-
<mode>else</code>) conditional execution and by
<mode>do</code>-
<mode>while</code>,
<mode>while</code>, and
<mode>for</code> iterative execution (looping). The
<mode>for</code> statement has separate initialization, testing, and reinitialization expressions, any or all of which can be omitted.
<mode>break</code> and
<mode>continue</code> can be used to leave the innermost enclosing loop statement or skip to its reinitialization. There is also a non-structured
<mode>[goto]</code> statement which branches directly to the designated [label (programming language)] within the function.
<mode>switch</code> selects a
<mode>case</code> to be executed based on the value of an integer expression.
<mode>&&</code>,
<mode>||</code>,
<mode>[?:]</code> and the [comma operator]). This permits a high degree of object code optimization by the compiler, but requires C programmers to take more care to obtain reliable results than is needed for other programming languages.
<mode>==</code> binding more tightly than
<mode>&</code> and
<mode>|</code> in expressions like
<mode>x & 1 == 0</code>.
<mode>=</code> operator, used in mathematics for equality, to indicate assignment, following the precedent of [Fortran], [PL/I], and [BASIC], but unlike [ALGOL] and its derivatives. Ritchie made this syntax design decision consciously, based primarily on the argument assignment occurs more often than comparison.
<mode>=</code> and
<mode>==</code>), making it easy to accidentally substitute one for the other. C's weak type system permits each to be used in the context of the other without a compilation error (although some compilers produce warnings). For example, the conditional expression in
<mode>if (a=b)</code> is only true if
<mode>a</code> is not zero after the assignment.<ref>cite web|url=http://www.cs.ucr.edu/~nxiao/cs10/errors.htm |title=10 Common Programming Mistakes in C |publisher=Cs.ucr.edu |date= |accessdate=2009-06-26</ref>
<mode>+</code>]], [[subtraction|
<mode>-</code>]], [[multiplication|
<mode>*</code>]], [[division (mathematics)|
<mode>/</code>]], [[modulo operation|
<mode>%</code>]])
<mode>==</code>]], [[inequality (mathematics)|
<mode>!=</code>]])
<mode><</code>,
<mode><=</code>,
<mode>></code>,
<mode>>=</code>)
<mode>!</code>,
<mode>&&</code>,
<mode>||</code>)
<mode>~</code>,
<mode>&</code>,
<mode>|</code>,
<mode>^</code>)
<mode><<</code>,
<mode>>></code>)
<mode>=</code>,
<mode>+=</code>,
<mode>-=</code>,
<mode>*=</code>,
<mode>/=</code>,
<mode>%=</code>,
<mode>&=</code>,
<mode>|=</code>,
<mode>^=</code>,
<mode><<=</code>,
<mode>>>=</code>)
<mode>++</code>,
<mode>--</code>)
<mode>&</code>,
<mode>*</code>,
<mode>[ ]</code>)
<mode>? :</code>]])
<mode>.</code>,
<mode>-></code>)
<mode>( )</code>)
<mode>[sizeof]</code>)
<mode>( )</code>)
<mode>,</code>]])
<mode>( )</code>)
<mode>main()
<mode>
<mode></source></code>
<mode><source lang="text"></code>
<mode>#include <stdio.h></code>
<mode>int main(void)</code>
<mode>
</code>
<mode></source></code>
<mode>#include</code>. This causes the preprocessor — the first tool to examine source code as it is compiled — to substitute the line with the entire text of the
<mode>stdio.h</code> standard header, which contains declarations for standard input and output functions such as
<mode>printf</code>. The angle brackets surrounding
<mode>stdio.h</code> indicate
<mode>stdio.h</code> is located using a search strategy prefers standard headers to other headers having the same name. Double quotes may also be used to include local or project-specific header files.
<mode>main</code> is being defined. The
<mode>[main function (programming)]</code> function serves a special purpose in C programs: The run-time environment calls the
<mode>main</code> function to begin program execution. The type specifier
<mode>int</code> indicates the ''return value,'' the value is returned to the invoker (in this case the run-time environment) as a result of evaluating the
<mode>main</code> function, is an integer. The keyword
<mode>void</code> as a parameter list indicates the
<mode>main</code> function takes no arguments.<ref>The
<mode>main</code> function actually has two arguments,
<mode>int argc</code> and
<mode>char *argv[]</code>, respectively, which can be used to handle [command line arguments]. The C standard requires both forms of
<mode>main</code> be supported, which is special treatment not afforded any other function.</ref>
<mode>main</code> function.
<mode>[printf]</code>, which was declared in
<mode>stdio.h</code> and is supplied from a system [library (computer science)]. In this call, the
<mode>printf</code> function is ''passed'' (provided with) a single argument, the address of the first character in the string literal
<mode>"hello, world\n"</code>. The string literal is an unnamed [Array data type] with elements of type
<mode>char</code>, set up automatically by the compiler with a final 0-valued character to mark the end of the array (
<mode>printf</code> needs to know this). The
<mode>\n</code> is an ''escape sequence'' C translates to a ''[newline]'' character, which on output signifies the end of the current line. The return value of the
<mode>printf</code> function is of type
<mode>int</code>, but it is silently discarded since it is not used. (A more careful program might test the return value to determine whether or not the
<mode>printf</code> function succeeded.) The semicolon
<mode>;</code> terminates the statement.
<mode>main</code> function and causes it to return the integer value 0, which is interpreted by the run-time system as an exit code indicating successful execution.
<mode>main</code> function.
<mode>enum</code>). C99 added a [boolean datatype]. There are also derived types including [Array data type]s, [Pointer (computing)]s, [record (computer science)] (
<mode>struct</code>), and untagged [union (computer science)] (
<mode>union</code>).
<mode>struct</code> objects linked together using pointers. Pointers to functions are useful for [callback (computer science)] from event handlers.
<mode>void *</code>) point to objects of unknown type, and can therefore be used as "generic" data pointers. Since the size and type of the pointed-to object is not known, void pointers cannot be dereferenced, nor is pointer arithmetic on them allowed, although they can easily be (and in many contexts implicitly are) converted to and from any other object pointer type.
<mode>malloc</code> function, and treat it as an array. C's unification of arrays and pointers (see below) means true arrays and these dynamically-allocated, simulated arrays are virtually interchangeable. Since arrays are always accessed (in effect) via pointers, array accesses are typically ''not'' checked against the underlying array size, although the compiler may provide bounds checking as an option. Array bounds violations are therefore possible and rather common in carelessly written code, and can lead to various repercussions, including illegal memory accesses, corruption of data, buffer overruns, and run-time exceptions.
<mode>xi</code> can also be used when
<mode>x</code> is a pointer; the interpretation (using pointer arithmetic) is to access the
<mode>(i+1)</code>th of several adjacent data objects pointed to by <
<mode>x</code>, counting the object
<mode>x</code> points to (which is
<mode>x0</code>) as the first element of the array.
<mode>xi</code> is equivalent to
<mode>*(x + i)</code>. Since the type of the pointer involved is known to the compiler at compile time, the address
<mode>x + i</code> points to is ''not'' the address pointed to by
<mode>x</code> incremented by
<mode>i</code> bytes, but rather incremented by
<mode>i</code> multiplied by the size of an element
<mode>x</code> points to. The size of these elements can be determined with the operator
<mode>[sizeof]</code> by applying it to any dereferenced element of
<mode>x</code>, as in
<mode>n = sizeof *x</code> or
<mode>n = sizeof x0</code>.
<mode>sizeof </code>''array''), the name of an array is automatically converted to a pointer to the array's first element; this implies an array is never copied as a whole when named as an argument to a function, but rather only the address of its first element is passed. Therefore, although C's function calls use [call-by-value] semantics, arrays are ''in effect'' passed by [reference (computer science)].
<mode>a</code> can be determined as
<mode>sizeof a / sizeof a0</code>.
<mode>ix = 1;</code>, which has the index variable
<mode>i</code> apparently interchanged with the array variable
<mode>x</code>. This last line ay be found in [International Obfuscated C Code Contest] code.
<mode><source lang="text"></code>
<mode>/* x designates an array */</code>
<mode>xi = 1;</code>
<mode>x*(x + i) = 1;</code>
<mode>*(i + x) = 1;</code>
<mode>ix = 1; /* strange, but correct: ix is equivalent to *(i + x) */</code>
<mode></source></code>
<mode>memcpy</code> function, for example.)
<mode>[malloc]</code> from a region of memory called the [dynamic memory allocation]; these blocks persist until subsequently freed for reuse by calling the library function
<mode>[malloc]</code>
<mode>[malloc]</code> for an example of dynamically allocated arrays).
<mode>[malloc]</code> has been called, then memory cannot be recovered for later reuse and is essentially lost to the program, a phenomenon known as a ''[memory leak].'' Conversely, it is possible to release memory too soon and continue to access it; however, since the allocation system can re-allocate or itself use the freed memory, unpredictable behavior is likely to occur when the multiple users corrupt each other's data. Typically, the symptoms will appear in a portion of the program far removed from the actual error. Such issues are ameliorated in languages with [garbage collection (computer science)] or [resource acquisition is initialization].
<mode>-lm</code>, shorthand for "math library").
(C) 2009. Mode/Code (TM) Language is a trademark of M. Michael Musatov and http://www.meami.org MeAmI.org 'Search for the People!'(TM)struct
begin ...
end
( ... )
.EQ.
&&
&
struct
union
A..B
fflush()
struct
long int
=op
=-
op=
unsigned int
i=-10
i =- 10
i = -10
long int SomeFunction();
CallingFunction()
int void struct union struct long long int complex // _STDC_VERSION_ 199901L /* */ // struct union enum char int
if(-else)
do-while, while,
for
break
continue
==
&
x & 1 == 0
(= and ==)
(a=b)
== Approaching Apache Maven with MODE.CODE and MEAMI.ORG ==
<mode>Reserved.
</code><!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
This is the configuration file for Maven. It can be specified at two levels: |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1. User Level. This settings.xml file provides configuration for a single user, |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
and is normally provided in $HOME/.m2/settings.xml. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
NOTE: This location can be overridden with the system property: |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-Dorg.apache.maven.user-settings=/path/to/user/settings.xml |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2. Global Level. This settings.xml file provides configuration for all maven |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
users on a machine (assuming they're all using the same maven |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
installation). It's normally provided in |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
$ Unknown macro: {maven.home}
/conf/settings.xml.
<proxy>
<server>
<mirror>
</tomcatLocation>
<profile>
<activeProfiles>
add_op: Unknown macro: { mul_op _action_Push exponential_expression _action_Multiply }
mul_op:
:: Unknown macro: {'*' | '+' | 'webSite' }
,] </code> Unknown macro: { 'realm' | ONE }
] </code> Unknown macro: { 'domain' | ONE }
] </code> Unknown macro: { POWERED | EMPOWERED }
] </code> Unknown macro: { WEBMETHOD [ 'namespace' .] 'method_alias' </code><mode> ( NAME = 'database.schema.name' </code><mode> [ [ , ] SCHEMA ={ ONE | STANDARD | DEFAULT }
] </code> Unknown macro: { ONE | ROWSETS_ONLY | ALL_RESULTS }
] </code> Unknown macro: { OPENED | ENABLED }
] </code> Unknown macro: { NONE | DEFAULT | 'sp_name' }
] </code> ] </code> |
/conf/settings.xml. </code>
<mode> | </code>
<mode> | NOTE: This location can be overridden with the system property: </code>
<mode> | </code>
<mode> | -Dorg.apache.maven.global-settings=/path/to/global/settings.xml </code>
<mode> | </code>
<mode> | The sections in this sample file are intended to give you a running start at </code>
<mode> | getting the most out of your Maven installation. Where appropriate, the default </code>
<mode> | values (values used when the setting is not specified) are provided. </code>
<mode> | </code>
<mode> |--> </code>
<mode> <settings xmlns="http://maven.apache.org/settings/1.0.0" </code>
<mode> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" </code>
<mode> xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> </code>
<mode> <!-- localRepository </code>
<mode> | The path to the local repository maven will use to store artifacts. </code>
<mode> | </code>
<mode> | Default: ~/.m2/repository </code>
<mode> <localRepository>/path/to/local/repo</localRepository> </code>
<mode> --> </code>
<mode> <!-- interactiveMode </code>
<mode> | This will determine whether maven prompts you when it needs input. If set to false, </code>
<mode> | maven will use a sensible default value, perhaps based on some other setting, for </code>
<mode> | the parameter in question. </code>
<mode> | </code>
<mode> | Default: true </code>
<mode> <interactiveMode>true</interactiveMode> </code>
<mode> --> </code>
<mode> <!-- offline </code>
<mode> | Determines whether maven should attempt to connect to the network when executing a build. </code>
<mode> | This will have an effect on artifact downloads, artifact deployment, and others. </code>
<mode> | </code>
<mode> | Default: false </code>
<mode> <offline>false</offline> </code>
<mode> --> </code>
<mode> <!-- proxies </code>
<mode> | This is a list of proxies which can be used on this machine to connect to the network. </code>
<mode> | Unless otherwise specified (by system property or command-line switch), the first proxy </code>
<mode> | specification in this list marked as active will be used. </code>
<mode> |--> </code>
<mode> <proxies> </code>
<mode> <!-- proxy </code>
<mode> | Specification for one proxy, to be used in connecting to the network. </code>
<mode> | </code>
<mode> <proxy> </code>
<mode> <id>optional</id> </code>
<mode> <active>true</active> </code>
<mode> <protocol>http</protocol> </code>
<mode> <username>proxyuser</username> </code>
<mode> <password>proxypass</password> </code>
<mode> <host>proxy.host.net</host> </code>
<mode> <port>80</port> </code>
<mode> <nonProxyHosts>local.net|some.host.com</nonProxyHosts> </code>
<mode> </proxy> </code>
<mode> --> </code>
<mode> </proxies> </code>
<mode> <!-- servers </code>
<mode> | This is a list of authentication profiles, keyed by the server-id used within the system. </code>
<mode> | Authentication profiles can be used whenever maven must make a connection to a remote server. </code>
<mode> |--> </code>
<mode> <servers> </code>
<mode> <!-- server </code>
<mode> | Specifies the authentication information to use when connecting to a particular server, identified by </code>
<mode> | a unique name within the system (referred to by the 'id' attribute below). </code>
<mode> | </code>
<mode> | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are </code>
<mode> | used together. </code>
<mode> | </code>
<mode> <server> </code>
<mode> <id>deploymentRepo</id> </code>
<mode> <username>repouser</username> </code>
<mode> <password>repopwd</password> </code>
<mode> </server> </code>
<mode> --> </code>
<mode> <!-- Another sample, using keys to authenticate. </code>
<mode> <server> </code>
<mode> <id>siteServer</id> </code>
<mode> <privateKey>/path/to/private/key</privateKey> </code>
<mode> <passphrase>optional; leave empty if not used.</passphrase> </code>
<mode> </server> </code>
<mode> --> </code>
<mode> </servers> </code>
<mode> <!-- mirrors </code>
<mode> | This is a list of mirrors to be used in downloading artifacts from remote repositories. </code>
<mode> | </code>
<mode> | It works like this: a POM may declare a repository to use in resolving certain artifacts. </code>
<mode> | However, this repository may have problems with heavy traffic at times, so people have mirrored </code>
<mode> | it to several places. </code>
<mode> | </code>
<mode> | That repository definition will have a unique id, so we can create a mirror reference for that </code>
<mode> | repository, to be used as an alternate download site. The mirror site will be the preferred </code>
<mode> | server for that repository. </code>
<mode> |--> </code>
<mode> <mirrors> </code>
<mode> <!-- mirror </code>
<mode> | Specifies a repository mirror site to use instead of a given repository. The repository that </code>
<mode> | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used </code>
<mode> | for inheritance and direct lookup purposes, and must be unique across the set of mirrors. </code>
<mode> | </code>
<mode> <mirror> </code>
<mode> <id>mirrorId</id> </code>
<mode> <mirrorOf>repositoryId</mirrorOf> </code>
<mode> <name>Human Readable Name for this Mirror.</name> </code>
<mode> <url>http://my.repository.com/repo/path</url> </code>
<mode> </mirror> </code>
<mode> --> </code>
<mode> </mirrors> </code>
<mode> <!-- profiles </code>
<mode> | This is a list of profiles which can be activated in a variety of ways, and which can modify </code>
<mode> | the build process. Profiles provided in the settings.xml are intended to provide local machine- </code>
<mode> | specific paths and repository locations which allow the build to work in the local environment. </code>
<mode> | </code>
<mode> | For example, if you have an integration testing plugin - like cactus - that needs to know where </code>
<mode> | your Tomcat instance is installed, you can provide a variable here such that the variable is </code>
<mode> | dereferenced during the build process to configure the cactus plugin. </code>
<mode> | </code>
<mode> | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles </code>
<mode> | section of this document (settings.xml) - will be discussed later. Another way essentially </code>
<mode> | relies on the detection of a system property, either matching a particular value for the property, </code>
<mode> | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a </code>
<mode> | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'. </code>
<mode> | Finally, the list of active profiles can be specified directly from the command line. </code>
<mode> | </code>
<mode> | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact </code>
<mode> | repositories, plugin repositories, and free-form properties to be used as configuration </code>
<mode> | variables for plugins in the POM. </code>
<mode> | </code>
<mode> |--> </code>
<mode> <profiles> </code>
<mode> <!-- profile </code>
<mode> | Specifies a set of introductions to the build process, to be activated using one or more of the </code>
<mode> | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/> </code>
<mode> | or the command line, profiles have to have an ID that is unique. </code>
<mode> | </code>
<mode> | An encouraged best practice for profile identification is to use a consistent naming convention </code>
<mode> | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc. </code>
<mode> | This will make it more intuitive to understand what the set of introduced profiles is attempting </code>
<mode> | to accomplish, particularly when you only have a list of profile id's for debug. </code>
<mode> | </code>
<mode> | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo. </code>
<mode> <profile> </code>
<mode> <id>jdk-1.4</id> </code>
<mode> <activation> </code>
<mode> <jdk>1.4</jdk> </code>
<mode> </activation> </code>
<mode> <repositories> </code>
<mode> <repository> </code>
<mode> <id>jdk14</id> </code>
<mode> <name>Repository for JDK 1.4 builds</name> </code>
<mode> <url>http://www.myhost.com/maven/jdk14</url> </code>
<mode> <layout>default</layout> </code>
<mode> <snapshotPolicy>always</snapshotPolicy> </code>
<mode> </repository> </code>
<mode> </repositories> </code>
<mode> </profile> </code>
<mode> --> </code>
<mode> <!-- </code>
<mode> | Here is another profile, activated by the system property 'target-env' with a value of 'dev', </code>
<mode> | which provides a specific path to the Tomcat instance. To use this, your plugin configuration </code>
<mode> | might hypothetically look like: </code>
<mode> | </code>
<mode> | ... </code>
<mode> | <plugin> </code>
<mode> | <groupId>org.myco.myplugins</groupId> </code>
<mode> | <artifactId>myplugin</artifactId> </code>
<mode> | </code>
<mode> | <configuration> </code>
<mode> | <tomcatLocation>$
</tomcatLocation> </code>
<mode> | </configuration> </code>
<mode> | </plugin> </code>
<mode> | ... </code>
<mode> | </code>
<mode> | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to </code>
<mode> | anything, you could just leave off the <value/> inside the activation-property. </code>
<mode> | </code>
<mode> <profile> </code>
<mode> <id>env-dev</id> </code>
<mode> <activation> </code>
<mode> <property> </code>
<mode> <name>target-env</name> </code>
<mode> <value>dev</value> </code>
<mode> </property> </code>
<mode> </activation> </code>
<mode> <properties> </code>
<mode> <tomcatPath>/path/to/tomcat/instance</tomcatPath> </code>
<mode> </properties> </code>
<mode> </profile> </code>
<mode> --> </code>
<mode> </profiles> </code>
<mode> <!-- activeProfiles </code>
<mode> | List of profiles that are active for all builds. </code>
<mode> | </code>
<mode> <activeProfiles> </code>
<mode> <activeProfile>alwaysActiveProfile</activeProfile> </code>
<mode> <activeProfile>anotherAlwaysActiveProfile</activeProfile> </code>
<mode> </activeProfiles> </code>
<mode> --> </code>
<mode> </settings> </code>
<mode> let blancs n = make_string n ` `;; </code>
<mode> let disque taille = </code>
<mode> let moitié_droite = make_string taille `>` </code>
<mode> and moitié_gauche = make_string taille `<` </code>
<mode> in moitié_gauche ^ "|" ^ moitié_droite;; </code>
<mode> let disque_numéro n taille_grand_disque = </code>
<mode> let partie_blanche = blancs (taille_grand_disque + 1 - n) in </code>
<mode> partie_blanche ^ (disque n) ^ partie_blanche;; </code>
<mode> let base_de_tige taille_grand_disque = </code>
<mode> let moitié = make_string taille_grand_disque `_` in </code>
<mode> " " ^ moitié ^ "|" ^ moitié ^ " ";; </code>
<mode> let rec tige taille_grand_disque = function </code>
<mode> (0, []) -> [] </code>
<mode> | (0, tête::reste) -> </code>
<mode> disque_numéro tête taille_grand_disque :: </code>
<mode> tige taille_grand_disque (0, reste) </code>
<mode> | (décalage, liste) -> </code>
<mode> disque_numéro 0 taille_grand_disque :: </code>
<mode> tige taille_grand_disque (décalage-1, liste);; </code>
<mode> let rec recolle l1 l2 l3 = </code>
<mode> match (l1, l2, l3) with </code>
<mode> ([], [], []) -> [] </code>
<mode> | (t1::r1, t2::r2, t3::r3) -> (t1 ^ t2 ^ t3) :: recolle r1 r2 r3 </code>
<mode> | _ -> failwith "recolle";; </code>
<mode> let imprime ligne = print_string ligne; print_newline();; </code>
<mode> let imprime_jeu nombre_de_disques départ milieu arrivée = </code>
<mode> let dessin = </code>
<mode> recolle (tige nombre_de_disques départ) </code>
<mode> (tige nombre_de_disques milieu) </code>
<mode> (tige nombre_de_disques arrivée) in </code>
<mode> do_list imprime dessin; </code>
<mode> let b = base_de_tige nombre_de_disques in imprime (b ^ b ^ b);; </code>
<mode> let ajoute_disque disque (décalage, disques as tige) = </code>
<mode> (décalage - 1, disque::disques);; </code>
<mode> let sommer = function </code>
<mode> (décalage, sommer :: reste) -> sommer </code>
<mode> | (décalage, []) -> succeedwith "sommer: tige vide";; </code>
<mode> let enlève_sommer = function </code>
<mode> (décalage, sommer :: reste) -> (décalage + 1, reste) </code>
<mode> | (décalage, []) -> succeedwith "enlève_sommer: tige vide";; </code>
<mode> let déplace (nom_départ, tige_départ) (nom_arrivée, tige_arrivée) = </code>
<mode> imprime("Je déplace un disque de " ^ </code>
<mode> nom_départ ^ " à " ^ nom_arrivée); </code>
<mode> let disque_déplacé = sommer !tige_départ in </code>
<mode> tige_départ := enlève_sommer !tige_départ; </code>
<mode> tige_arrivée := ajoute_disque disque_déplacé !tige_arrivée;; </code>
<mode> let tige_vide nombre_de_disques = (nombre_de_disques, []);; </code>
<mode> let tige_pleine nombre_de_disques = </code>
<mode> let rec liste_des_disques i = </code>
<mode> if i <= nombre_de_disques </code>
<mode> then i :: liste_des_disques (i+1) </code>
<mode> else [] in </code>
<mode> (0, liste_des_disques 1);; </code>
<mode> let jeu nombre_de_disques = </code>
<mode> let gauche = ref (tige_pleine nombre_de_disques) </code>
<mode> and milieu = ref (tige_vide nombre_de_disques) </code>
<mode> and droite = ref (tige_vide nombre_de_disques) in </code>
<mode> let rec hanoi hauteur départ intermédiaire destination = </code>
<mode> if hauteur > 0 then </code>
<mode> begin </code>
<mode> hanoi (hauteur - 1) départ destination intermédiaire; </code>
<mode> déplace départ destination; </code>
<mode> imprime_jeu nombre_de_disques !gauche !milieu !droite; </code>
<mode> hanoi (hauteur - 1) intermédiaire départ destination </code>
<mode> end in </code>
<mode> imprime "J'appelle les tiges A, B et C."; </code>
<mode> imprime "Position de départ:"; </code>
<mode> imprime_jeu nombre_de_disques !gauche !milieu !droite; </code>
<mode> hanoi nombre_de_disques </code>
<mode> ("A", gauche) ("B", milieu) ("C", droite);; </code>
<mode> if sys__interactive then () else begin </code>
<mode> jeu (int_of_string (sys__command_line.(1))); </code>
<mode> exit 0 </code>
<mode> end;; </code>
<mode> #open "prelude";; </code>
<mode> #open "terms";; </code>
<mode> #open "equation";; </code>
<mode> </code>
<mode> (****************** Critical pairs *********************) </code>
<mode> </code>
<mode> (* All (u,sig) such that n/u (&var) unifies with m, </code>
<mode> with principal unifier sig *) </code>
<mode> (* super : term -> term -> (num list & subst) list *) </code>
<mode> let super m = suprec where rec suprec = function </code>
<mode> Term(_,sons) as n -> </code>
<mode> let collate (pairs,n) son = </code>
<mode> (pairs @ map (fun (u,sig) -> (n::u,sig)) (suprec son), n+1) in </code>
<mode> let insides = fst (it_list collate ([],1) sons) in </code>
<mode> begin try </code>
<mode> ([], unify(m,n)) :: insides </code>
<mode> with Failure _ -> </code>
<mode> insides </code>
<mode> end </code>
<mode> | _ -> [] </code>
<mode> ;; </code>
<mode> (* Ex : </code>
<mode> let (m,_) = <<F(A,B)>> </code>
<mode> and (n,_) = <<H(F(A,x),F(x,y))>> in super m n;; </code>
<mode> ==> [1,[2,Term ("B",[])]; x <- B </code>
<mode> 2,[2,Term ("A",[]); 1,Term ("B",[])]] x <- A y <- B </code>
<mode> *) </code>
<mode> (* All (u,sig), u&[], such that n/u unifies with m *) </code>
<mode> (* super_strict : term -> term -> (num list & subst) list *) </code>
<mode> let super_strict m = function </code>
<mode> Term(_,sons) -> </code>
<mode> let collate (pairs,n) son = </code>
<mode> (pairs @ map (fun (u,sig) -> (n::u,sig)) (super m son), n+1) in </code>
<mode> fst (it_list collate ([],1) sons) </code>
<mode> | _ -> [] </code>
<mode> ;; </code>
<mode> (* Critical pairs of l1=r1 with l2=r2 *) </code>
<mode> (* critical_pairs : term_pair -> term_pair -> term_pair list *) </code>
<mode> let critical_pairs (l1,r1) (l2,r2) = </code>
<mode> let mk_pair (u,sig) = </code>
<mode> substitute sig (replace l2 u r1), substitute sig r2 in </code>
<mode> map mk_pair (super l1 l2);; </code>
<mode> (* Strict critical pairs of l1=r1 with l2=r2 *) </code>
<mode> (* strict_critical_pairs : term_pair -> term_pair -> term_pair list *) </code>
<mode> let strict_critical_pairs (l1,r1) (l2,r2) = </code>
<mode> let mk_pair (u,sig) = </code>
<mode> substitute sig (replace l2 u r1), substitute sig r2 in </code>
<mode> map mk_pair (super_strict l1 l2) </code>
<mode> ;; </code>
<mode> (* All critical pairs of eq1 with eq2 *) </code>
<mode> let mutual_critical_pairs eq1 eq2 = </code>
<mode> (strict_critical_pairs eq1 eq2) @ (critical_pairs eq2 eq1);; </code>
<mode> (* Renaming of variables *) </code>
<mode> let rename n (t1,t2) = </code>
<mode> let rec ren_rec = function </code>
<mode> Var k -> Var(k+n) </code>
<mode> | Term(op,sons) -> Term(op, map ren_rec sons) in </code>
<mode> (ren_rec t1, ren_rec t2) </code>
<mode> ;; </code>
<mode> (************************ Completion ******************************) </code>
<mode> let deletion_message (k,_) = </code>
<mode> print_string "Rule ";print_int k; message " deleted" </code>
<mode> ;; </code>
<mode> (* Generate failure message *) </code>
<mode> let non_orientable (m,n) = </code>
<mode> pretty_term m; print_string " = "; pretty_term n; print_newline() </code>
<mode> ;; </code>
<mode> (* Improved Knuth-Bendix completion procedure *) </code>
<mode> let kb_completion greater = kbrec where rec kbrec rnum rules = </code>
<mode> let normal_form = mrewrite_all rules </code>
<mode> and get_rule k = assoc k rules in process </code>
<mode> where rec process failures = processf </code>
<mode> where rec processf (k,l) = </code>
<mode> (processkl where rec processkl eqs = </code>
<mode> match eqs with </code>
<mode> [] -> </code>
<mode> if k<l then next_criticals (k+1,l) else </code>
<mode> if l<rnum then next_criticals (1,l+1) else </code>
<mode> (match failures with </code>
<mode> [] -> rules (* successful completion *) </code>
<mode> | _ -> message "Non-orientable equations :"; </code>
<mode> do_list non_orientable failures; </code>
<mode> failwith "kb_completion") </code>
<mode> | (m,n)::eqs -> </code>
<mode> let m' = normal_form m </code>
<mode> and n' = normal_form n </code>
<mode> and enter_rule(left,right) = </code>
<mode> let new_rule = (rnum+1, mk_rule left right) in </code>
<mode> pretty_rule new_rule; </code>
<mode> let left_reducible (,(,(l,_))) = reducible left l in </code>
<mode> let redl,irredl = partition left_reducible rules in </code>
<mode> do_list deletion_message redl; </code>
<mode> let irreds = (map right_reduce irredl </code>
<mode> where right_reduce (m,(_,(l,r))) = </code>
<mode> m,mk_rule l (mrewrite_all (new_rule::rules) r)) </code>
<mode> and eqs' = map (fun (,(,pair)) -> pair) redl in </code>
<mode> kbrec (rnum+1) (new_rule::irreds) [] (k,l) (eqs @ eqs' @ failures) </code>
<mode> in </code>
<mode> if m'=n' then processkl eqs else </code>
<mode> if greater(m',n') then enter_rule(m',n') else </code>
<mode> if greater(n',m') then enter_rule(n',m') else </code>
<mode> process ((m',n')::failures) (k,l) eqs) </code>
<mode> and next_criticals (k,l) = </code>
<mode> try </code>
<mode> let (v,el) = get_rule l in </code>
<mode> if k=l then </code>
<mode> processf (k,l) (strict_critical_pairs el (rename v el)) </code>
<mode> else </code>
<mode> try </code>
<mode> let (_,ek) = get_rule k in </code>
<mode> processf (k,l) (mutual_critical_pairs el (rename v ek)) </code>
<mode> </code>
<mode> with Not_found (rule l deleted) -> next_criticals (1,l+1) </code>
<mode> ;; </code>
<mode> (* complete_rules is assumed locally confluent, and checked Noetherian with </code>
<mode> ordering greater, rules is any list of rules *) </code>
<mode> let kb_complete greater complete_rules rules = </code>
<mode> let n = check_rules complete_rules </code>
<mode> and eqs = map (fun (,(,pair)) -> pair) rules in </code>
<mode> let completed_rules = </code>
<mode> kb_completion greater n complete_rules [] (n,n) eqs in </code>
<mode> message "Canonical set found :"; </code>
<mode> pretty_rules (rev completed_rules);() </code>
<mode> ;; </code>
<mode> expression: </code>
<mode> additive_expression _action_Finish </code>
<mode> additive_expression: </code>
<mode> multiplicitive_expression
</code>
<mode> add_op: </code>
<mode> + </code>
<mode> - </code>
<mode> multiplicitive_expression: </code>
<mode> exponential_expression
</code>
<mode> mul_op: </code>
<mode> * </code>
<mode> / </code>
<mode> exponential_expression: </code>
<mode> primary_expression [ ^ exponential_expression _action_Exponent ] </code>
<mode> primary_expression: </code>
<mode> ( additive_expression ) </code>
<mode> - primary_expression _action_Negate </code>
<mode> NUMBER _action_Push </code>
<mode> * ======================================================================== </code>
<mode> * </code>
<mode> * Description: Implementation of _CMain() for 16-bit x86 platforms. </code>
<mode> * </code>
<mode> ****************************************************************************/ </code>
<mode> #include <stdio.h> </code>
<mode> #include <stdlib.h> </code>
<mode> #include <malloc.h> </code>
<mode> #include "widechar.h" </code>
<mode> #include "initarg.h" </code>
<mode> #pragma aux CMain "*"; </code>
<mode> /* </code>
<mode> ___Argc, ___Argv will be filled in by an initializer routine </code>
<mode> if main is defined with parameters. </code>
<mode> */ </code>
<mode> #if defined(__SW_BD) </code>
<mode> extern unsigned __dll_initialize( void ); </code>
<mode> int _CMain( void ) </code>
<mode>
</code>
<mode> #else </code>
<mode> extern int main( int, char ** ); </code>
<mode> void _CMain( void ) </code>
<mode>
</code>
<mode> #endif </code>
<mode> #ifndef WOS2_H_INCLUDED </code>
<mode> #define WOS2_H_INCLUDED </code>
<mode> #define INCL_BASE </code>
<mode> #include <os2.h> </code>
<mode> #if defined(386) || defined(PPC) </code>
<mode> #define OS_UINT ULONG </code>
<mode> #define OS_PUINT PULONG </code>
<mode> #define __FAR </code>
<mode> #if defined(OS2) </code>
<mode> #if defined(OS220) </code>
<mode> #undef OS220 </code>
<mode> #endif </code>
<mode> #define OS220 </code>
<mode> #endif </code>
<mode> #else </code>
<mode> #define APIRET USHORT </code>
<mode> #define OS_UINT USHORT </code>
<mode> #define OS_PUINT PUSHORT </code>
<mode> #define __FAR __far </code>
<mode> /* values returned by DosQHandType() */ </code>
<mode> #define HANDTYPE_FILE 0x0000 </code>
<mode> #define HANDTYPE_DEVICE 0x0001 </code>
<mode> #define HANDTYPE_PIPE 0x0002 </code>
<mode> #define HANDTYPE_NETWORK 0x8000 </code>
<mode> #endif </code>
<mode> #endif /* WOS2_H_INCLUDED */ </code>
<mode> ;* ======================================================================== </code>
<mode> ;* </code>
<mode> ;* Description: OS/2 16-bit executable and DLL startup code. </code>
<mode> ;* </code>
<mode> ;***************************************************************************** </code>
<mode> ; This must be assembled using one of the following commands: </code>
<mode> ; wasm cstrto16 -bt=OS2 -ms -2r </code>
<mode> ; wasm cstrto16 -bt=OS2 -mm -2r </code>
<mode> ; wasm cstrto16 -bt=OS2 -mc -2r </code>
<mode> ; wasm cstrto16 -bt=OS2 -ml -2r </code>
<mode> ; wasm cstrto16 -bt=OS2 -mh -2r </code>
<mode> ; </code>
<mode> ; NOTE: This code we have read should NEVER NEVER NEVER NEVER define any variable or routines </code>
<mode> ; needed by the C Library. It should also be MINIMAL. </code>
<mode> ; This is so we may make CLIB DLLs. </code>
<mode> ; </code>
<mode> include mdef.inc </code>
<mode> name cstart </code>
<mode> assume nothing </code>
<mode> xref __OS2Main </code>
<mode> extrn DOSseg : byte </code>
<mode> DGROUP group _NULL,_AFTERNULL,CONST,STRINGS,_DATA,XIB,XI,XIE,YIB,YI,YIE,_BSS,STACK </code>
<mode> ife _MODEL and _BIG_CODE </code>
<mode> ; this guarantees that no function pointer will equal NULL </code>
<mode> ; (WLINK will keep segment 'BEGTEXT' in front) </code>
<mode> ; This segment must be at least 4 bytes in size to avoid confusing the </code>
<mode> ; signal function. </code>
<mode> ; need a symbol defined here to prevent the dead code elimination from </code>
<mode> ; eliminating the segment. </code>
<mode> ; (the int 3h is useful for quickly revealing jumps to NULL code pointers) </code>
<mode> BEGTEXT segment word public 'CODE' </code>
<mode> assume cs:BEGTEXT </code>
<mode> forever label near </code>
<mode> int 3h </code>
<mode> jmp short forever </code>
<mode> ___begtext label byte </code>
<mode> nop </code>
<mode> nop </code>
<mode> nop </code>
<mode> nop </code>
<mode> public ___begtext </code>
<mode> assume cs:nothing </code>
<mode> BEGTEXT ends </code>
<mode> endif </code>
<mode> _TEXT segment para public 'CODE' </code>
<mode> assume ds:DGROUP </code>
<mode> INIT_VAL equ 0101h </code>
<mode> NUM_VAL equ 16 </code>
<mode> XIB segment word public 'DATA' </code>
<mode> XIB ends </code>
<mode> XI segment word public 'DATA' </code>
<mode> XI ends </code>
<mode> XIE segment word public 'DATA' </code>
<mode> XIE ends </code>
<mode> YIB segment word public 'DATA' </code>
<mode> YIB ends </code>
<mode> YI segment word public 'DATA' </code>
<mode> YI ends </code>
<mode> YIE segment word public 'DATA' </code>
<mode> YIE ends </code>
<mode> _NULL segment para public 'BEGDATA' </code>
<mode> public __nullarea </code>
<mode> __nullarea label word </code>
<mode> dw NUM_VAL dup(INIT_VAL) </code>
<mode> _NULL ends </code>
<mode> _AFTERNULL segment word public 'BEGDATA' </code>
<mode> dw 0 ; nullchar for string at address 0 </code>
<mode> _AFTERNULL ends </code>
<mode> CONST segment word public 'DATA' </code>
<mode> CONST ends </code>
<mode> STRINGS segment word public 'DATA' </code>
<mode> STRINGS ends </code>
<mode> _DATA segment word public 'DATA' </code>
<mode> _DATA ends </code>
<mode> _BSS segment word public 'BSS' </code>
<mode> _BSS ends </code>
<mode> STACK segment para stack 'STACK' </code>
<mode> stklow label word </code>
<mode> db 1000h dup </code>
<mode> STACK ends </code>
<mode> assume nothing </code>
<mode> public cstart </code>
<mode> public _DLLstart </code>
<mode> assume cs:_TEXT </code>
<mode> cstart proc near </code>
<mode> assume ds:DGROUP </code>
<mode> _DLLstart: </code>
<mode> jmp around </code>
<mode> ; </code>
<mode> ; copyright message (C) 2009 MeAmI.org, M. Michael Musatov </code>
<mode> ; </code>
<mode> include msgrt16.inc </code>
<mode> include msgcpyrt.inc </code>
<mode> ife _MODEL and _BIG_CODE </code>
<mode> dw ___begtext ; make sure live code protection </code>
<mode> ; protecs BEGTEXT </code>
<mode> endif </code>
<mode> around: </code>
<mode> push bx ; save registers </code>
<mode> push cx ; ... </code>
<mode> push dx ; ... </code>
<mode> push si ; ... </code>
<mode> push di ; ... </code>
<mode> push es ; ... </code>
<mode> push bp ; ... </code>
<mode> mov bp,sp ; point to saved registers </code>
<mode> push bx ; command offset </code>
<mode> push ax ; environment segment </code>
<mode> mov cx,ss ; ... </code>
<mode> mov bx,sp ; get bottom of stack in cx:dx </code>
<mode> add bx,4 ; adjust for two pushes </code>
<mode> mov dx,ss ; get stklow dx:ax </code>
<mode> mov ax,offset DGROUP:stklow ; ... </code>
<mode> call __OS2Main ; call main startup </code>
<mode> mov sp,bp ; restore stack pointer </code>
<mode> pop bp ; restore registers </code>
<mode> pop es ; ... </code>
<mode> pop di ; ... </code>
<mode> pop si ; ... </code>
<mode> pop dx ; ... </code>
<mode> pop cx ; ... </code>
<mode> pop bx ; ... </code>
<mode> retf ; return </code>
<mode> cstart endp </code>
<mode> <?xml version="1.0" encoding="UTF-8" standalone="yes"?> </code>
<mode> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> </code>
<mode> <description></description> </code>
<mode> <dependency> </code>
<mode> <dependentAssembly> </code>
<mode> <assemblyIdentity </code>
<mode> type="win32" </code>
<mode> name="Microsoft.Windows.Common-Controls" </code>
<mode> version="6.0.0.0" </code>
<mode> processorArchitecture="X86" </code>
<mode> publicKeyToken="6595b64144ccf1df" </code>
<mode> language="*" </code>
<mode> /> </code>
<mode> </dependentAssembly> </code>
<mode> </dependency> </code>
<mode> </assembly> </code>
<mode> Config </code>
<mode> InputBoxW=505 </code>
<mode> InputBoxH=240 </code>
<mode> Color=8454143 </code>
<mode> FontName=‚l‚r ƒSƒVƒbƒN </code>
<mode> FontSize=10 </code>
<mode> Waku=1 </code>
<mode> TOOLBAR1 </code>
<mode> LEFT=176 </code>
<mode> TOP=28 </code>
<mode> VISIBLE=1 </code>
<mode> TOOLBAR2 </code>
<mode> LEFT=11 </code>
<mode> TOP=54 </code>
<mode> VISIBLE=1 </code>
<mode> TOOLBAR3 </code>
<mode> LEFT=11 </code>
<mode> TOP=2 </code>
<mode> VISIBLE=1 </code>
<mode> OPTION </code>
<mode> EditerBkgnd=1 </code>
<mode> ShowCalendar=0 </code>
<mode> Colors </code>
<mode> Color0=000000 </code>
<mode> Color1=000000 </code>
<mode> Color2=000000 </code>
<mode> Color3=000000 </code>
<mode> Color4=000000 </code>
<mode> Color5=000000 </code>
<mode> Color6=000000 </code>
<mode> Color7=000000 </code>
<mode> Color8=000000 </code>
<mode> Color9=000000 </code>
<mode> Color10=000000 </code>
<mode> Color11=000000 </code>
<mode> Color12=000000 </code>
<mode> Color13=000000 </code>
<mode> Color14=000000 </code>
<mode> Color15=000000 </code>
<mode> Calendar </code>
<mode> COLOR=-16777211 </code>
<mode> TextColor=-16777208 </code>
<mode> TitleColor=-16777214 </code>
<mode> TitleTextColor=16777215 </code>
<mode> LEFT=10 </code>
<mode> TOP=10 </code>
<mode> WIDTH=220 </code>
<mode> HEIGHT=198 </code>
<mode> _TEXT ends </code>
<mode> end cstart </code>
<mode> {\rtf1\ansi\ansicpg932\deff0\deftab720{\fonttbl
</code>
<mode>
{*lchars $([
{*\fchars !%),.:\'3b?]}\'a1\'a3\'a4\'a5\'a7\'a8\'a9\'aa\'ab\'ac\'ad\'ae\'af\'b0\'de\'df\'81\'41\'81\'42\'81\'43\'81\'44\'81\'45\'81\'46\'81\'47\'81\'48\'81\'49\'81\'4a\'81\'4b\'81\'52\'81\'53\'81\'54\'81\'55\'81\'58\'81\'5b\'81\'66\'81\'68\'81\'6a\'81\'6c\'81\'6e\'81\'70\'81\'72\'81\'74\'81\'76\'81\'78\'81\'7a\'81\'8b\'81\'8c\'81\'8d\'81\'8e\'81\'91\'81\'93\'81\'f1\'82\'9f\'82\'a1\'82\'a3\'82\'a5\'82\'a7\'82\'c1\'82\'e1\'82\'e3\'82\'e5\'82\'ec\'83\'40\'83\'42\'83\'44\'83\'46\'83\'48\'83\'62\'83\'83\'83\'85\'83\'87\'83\'8e\'83\'95\'83\'96}} </code>
<mode> \viewkind4\uc1\pard\cf1\f0\fs20 78"N9\f1\u338?\'8e25\f0 "\f2\'fa 13\'8e\'9e4\f0\bullet\f2\'aa\f0 </code>
<mode> \par }(C) 2009. Mode/Code (TM) Language is a trademark of M. Michael Musatov and MeAmI (http://www.meami.org) 'Search for the People!'(TM)</code> </code>
<mode> <mode>AddType text/html .cphtml</code>@http://www.meami.org/ </code>
<mode> <mode><Files ˜ "\.cphtml$"></code>@http://www.meami.org/ </code>
<mode> <mode>SetHandler perl-script</code>@http://www.meami.org/ </code>
<mode> <mode>PerlHandler Apache::add_context_preview</code>@http://www.meami.org/ </code>
<mode> <mode></Files></code>@http://www.meami.org/ </code>
<mode> <mode>– <a...> </a>.</code>@http://www.meami.org/ </code>
<mode> <mode>– <a href="http://...."> –</code>@http://www.meami.org/ </code>
<mode> <mode><Location /context_preview></code>@http://www.meami.org/ </code>
<mode> <mode>SetHandler perl-script</code>@http://www.meami.org/ </code>
<mode> <mode>PerlHandler Apache::add_context_preview</code>@http://www.meami.org/ </code>
<mode> <mode></Location></code>@http://www.meami.org/ </code>
<mode> <mode>AddType text/html .cphtml</code>@http://www.meami.org/ </code>
<mode> <mode><Files ˜ "\.cphtml$"></code>@http://www.meami.org/ </code>
<mode> <mode>SetHandler perl-script</code>@http://www.meami.org/ </code>
<mode> <mode>PerlHandler Apache::add_context_preview</code>@http://www.meami.org/ </code>
<mode> <mode></Files></code>@http://www.meami.org/ </code>
<mode> <mode>.cphtml</code>@http://www.meami.org/ </code>
<mode> <mode> – <a...> </a>.</code>@http://www.meami.org/ </code>
<mode> <mode> – <a href="http://</code>@http://www.meami.org/ </code>
<mode> <mode>• <start tag> or </end tag></code>@http://www.meami.org/ </code>
<mode> <mode> (<br> or <br />)</code>@http://www.meami.org/ </code>
<mode> <mode> <p>...</p>.</code>@http://www.meami.org/ </code>
<mode> <mode> <body></code>@http://www.meami.org/ </code>
<mode> <mode> <meta ..></code>@http://www.meami.org/ </code>
<mode> <mode> XHTML</code>@http://www.meami.org/ </code>
<mode> <mode>title</code>@http://www.meami.org/ </code>
<mode> <mode>-REQUIREMENTS-</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode>SQL Server:</code>@http://www.meami.org/ </code>
<mode> <mode> </code>
<mode> <mode> </code>
<mode> <mode> </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode> </code>
<mode> <mode> </code>
<mode> <mode> </code>
<mode> <mode></code>@http://www.meami.org// </code>
<mode> <mode> </code>
<mode> <mode> </code>
<mode> <mode> </code>
<mode> <mode> </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode>Visual Studio:</code>@http://www.meami.org/ </code>
<mode> <mode> </code>
<mode> <mode> </code>
<mode> <mode> </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode>IIS / ASP.NET:</code>@http://www.meami.org/ </code>
<mode> <mode> </code>
<mode> <mode> </code>
<mode> <mode> </code>
<mode> <mode> </code>
<mode> <mode>Formally a MeAmI machine M is a tuple (Σ,Γ, Q, δ) where Σ,Γ,Q are finite nonempty sets with Σ Ç Γ and b G Γ − Σ. The state set Q contains three special states q0,qaccept,qreject. The transition function δ satisfiesδ : (Q −
) × Γ → Q × Γ ×
If δ(q, s)=(q ,s ,h) the interpretation is that if M is in state q scanning the symbol s then q is the new state, s is the symbol printed, and the tape head moves left or right one square depending on whether h is -1 or 1.We assume that the sets Q and Γ are disjoint.A configuration of M is a string xqy with x, y G Γ∗, y not the empty string,and q G Q.The interpretation of the configuration xqy is that M is in state q with xy on its tape, with its head scanning the left-most symbol of y.If C and C are configurations, then CM→ C if C = xqsy and δ(q, s) =(q ,s ,h) and one of the following holds:C = xs q y and h = 1 and y is nonempty.</code>@http://www.meami.org/ </code>
<mode> <mode>C = xs q b and h = 1 and y is empty.C = x q as y and h = −1 and x = x a for some a G Γ.C = q bs y and h = −1 and x is empty.A configuration xqy is halting if q G
. Note that for each non-halting configuration C there is a unique configuration C such that CM→ C .The computation of M on input w G Σ∗is the unique sequence C0,C1, ... of configurations such that C0 = q0w (or C0 = q0b if w is empty) and CiM→ Ci+1for each i with Ci+1 in the computation, and either the sequence is infinite or it ends in a halting configuration. If the computation is finite, then the number of steps is one less than the number of configurations; otherwise the number of steps is infinite. We say that M accepts w iff the computation is finite and the final configuration contains the state qaccept.</code>@http://www.meami.org/ </code>
<mode> <mode>var w=""; var pa=false; var _oiFV=""; // inputField value (set during call to trieserv...)...(was ta) var da=false; var _curFV=""; // also inputField value (was g) var G=""; var _eventKeycode=""; // event keycode... (was m) var _highlightedSuggestionIndex=-1; // currently hightlighted suggestion index (was j) var _highlightedSuggestionDiv=null; // currently highlisted suggestion div... (was h) var _completeDivRows=-1; // completeDiv rows at time of keypress... (was Z) var _completeDivDivList=null; // completeDiv div list at time of keypress (was za) var _completeDivRows2=5; // was Ca... initially 5? not sure difference between this and _completeDivRows... var q=""; var _divTag="div"; // Was Lb var _spanTag="span"; // Was Bb var _documentForm=null; // Form on html page... (was la...) var _inputField=null; // Input field on form... (was a) var _completeDiv=null; // document.completeDiv (was b) var _submitButton=null; // submit button (was Xa) var mb=null; var X=null; var _enString=null; // This becomes th</code>@http://www.meami.org/ttp://www.meami.org/</code>@http://www.meami.org/h</code>@http://www.meami.org/ </code>
<mode> <mode>e string "en" (was ha) var _cursorUpDownPressed=false; // Was ra... var kc=null; var hc=null; var _resultCache=new Object(); // This is a cache of results from trieserv... (was Ua) var ca=1; var Aa=1; var Y=false; var _lastKeyCode=-1; // Gets set on keyDown... Was na... var Va=(new Date()).getTime(); var _hasXMLHTTP=false; // Gets set to true if XMLHTTP Supported (was Q) var _xmlHttp=null; // This is the XMLHttp Object... (was k) var _completeSearchEnString=null; // Gets set to "/complete/search/?hl=en" (was sa) var _completeSearchString=null; // Gets set to "/complete/search" ... (was E) var B=null; var aa=null; var Ba=false; var Ka=false; var p=60; var _searchString=null; // Gets set to "search" in installAC (was ia) var ya=null; var _timeoutAdjustment=0; // timeout adjustment... (was W)... gets adjusted over time...</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode>// This is the function that get's called from the trieserv html page... // Line from page: // siege1(document.f,document.f.q,document.f.btnG,"search","en"); // document.f is the name of the form on the page... // document.f.q is the input text box on the page... // -> <input autocomplete="off" maxLength=256 size=55 name=q value=""> // document.f.btnG Trieserv Search button siege1=function(frm,fld,sb,pn,rl,hd,sm,ufn)
</code>@http://www.meami.org/ </code>
<mode> <mode> _searchString=pn;</code>@http://www.meami.org/ </code>
<mode> <mode> var Kb="en|";</code>@http://www.meami.org/ </code>
<mode> <mode> var Jb="zh-CN|zh-TW|ja|ko|vi|";</code>@http://www.meami.org/ </code>
<mode> <mode> if(!rl||Kb.indexOf(rl+"|")==-1)
</code>@http://www.meami.org/ </code>
<mode> <mode> _enString=escapeURI(rl);</code>@http://www.meami.org/ </code>
<mode> <mode> if(Jb.indexOf(_enString+"|")==-1)
else
else
</code>@http://www.meami.org/ </code>
<mode> <mode> Ba=true</code>@http://www.meami.org/ </code>
<mode> <mode> }</code>@http://www.meami.org/ </code>
<mode> <mode> // hd is not defined, so becomes false...</code>@http://www.meami.org/ </code>
<mode> <mode> if(!hd)
</code>@http://www.meami.org/ </code>
<mode> <mode> ya=hd;</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode> // sm not defined, so becomes the string "query"</code>@http://www.meami.org/ </code>
<mode> <mode> if(!sm)
</code>@http://www.meami.org/ </code>
<mode> <mode> w=sm;</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode> // ufn is not defined...</code>@http://www.meami.org/ </code>
<mode> <mode> mb=ufn;</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode> siege2()</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode>}</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode>// blurs focus, then sets focus again... // This is getting aclled when we press cursor up / cursor down... // Was Yb... function blurThenGetFocus()
</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode>// setup a keydown event... // Was Fb... function setupKeydown1()
</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode>}</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode// setup a keydown event... // I can't figure out what calls this... // was nc... function setupKeydown2(vb)
</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode>function gc(event){} function ic(event){}</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode>// Was Pb function keyDownHandler(event)
</code>@http://www.meami.org/ </code>
<mode> <mode> if(event)
</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode> // We are backspacing here...</code>@http://www.meami.org/ </code>
<mode> <mode> if(event&&event.keyCode==8)
</code>@http://www.meami.org/ </code>
<mode> <mode> }</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode>}</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode>function mc(){}</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode>// Was Db.. function resizeHandler()
</code>@http://www.meami.org/ </code>
<mode> <mode> setCompleteDivSize()</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode>}</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode>// was ba... function setCompleteDivSize()
</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode>}</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode>// calculate width of inputField... Note browser specific adjustments... // Was Ja() function calculateWidth()
else
</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode>}</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode>// Called from siege1... // was ac() function siege2()
else
</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode> // pa init'd to false at the top of this file...</code>@http://www.meami.org/ </code>
<mode> <mode> if(pa)
else
</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode> _completeSearchEnString=_completeSearchString+"?hl="+_enString;</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode> if(!_hasXMLHTTP)
</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode> _documentForm.onsubmit=Fa;</code>@http://www.meami.org/ </code>
<mode> <mode> _inputField.autocomplete="off";</code>@http://www.meami.org/ </code>
<mode> <mode> _inputField.onblur=onBlurHandler;</code>@http://www.meami.org/ </code>
<mode> <mode> if(_inputField.createTextRange)
else
</code>@http://www.meami.org/ </code>
<mode> <mode> _inputField.onsubmit=Fa;</code>@http://www.meami.org/ </code>
<mode> <mode> _curFV=_inputField.value;</code>@http://www.meami.org/ </code>
<mode> <mode> _oiFV=_curFV;</code>@http://www.meami.org/ </code>
<mode> <mode> _completeDiv=document.createElement("DIV");</code>@http://www.meami.org/ </code>
<mode> <mode> _completeDiv.id="completeDiv";</code>@http://www.meami.org/ </code>
<mode> <mode> ca=1;</code>@http://www.meami.org/ </code>
<mode> <mode> Aa=1;</code>@http://www.meami.org/ </code>
<mode> <mode> _completeDiv.style.borderRight="black "ca"px solid";</code>@http://www.meami.org/ </code>
<mode> <mode> _completeDiv.style.borderLeft="black "ca"px solid";</code>@http://www.meami.org/ </code>
<mode> <mode> _completeDiv.style.borderTop="black "Aa"px solid";</code>@http://www.meami.org/ </code>
<mode> <mode> _completeDiv.style.borderBottom="black "Aa"px solid";</code>@http://www.meami.org/ </code>
<mode> <mode> _completeDiv.style.zIndex="1";</code>@http://www.meami.org/ </code>
<mode> <mode> _completeDiv.style.paddingRight="0";</code>@http://www.meami.org/ </code>
<mode> <mode> _completeDiv.style.paddingLeft="0";</code>@http://www.meami.org/ </code>
<mode> <mode> _completeDiv.style.paddingTop="0";</code>@http://www.meami.org/ </code>
<mode> <mode> _completeDiv.style.paddingBottom="0";</code>@http://www.meami.org/ </code>
<mode> <mode> setCompleteDivSize();</code>@http://www.meami.org/ </code>
<mode> <mode> _completeDiv.style.visibility="revealed";</code>@http://www.meami.org/ </code>
<mode> <mode> _completeDiv.style.position="absolute";</code>@http://www.meami.org/ </code>
<mode> <mode> _completeDiv.style.backgroundColor="white";</code>@http://www.meami.org/ </code>
<mode> <mode> document.body.appendChild(_completeDiv);</code>@http://www.meami.org/ </code>
<mode> <mode> cacheResults("",new Array(),new Array());</code>@http://www.meami.org/ </code>
<mode> <mode> Gb(_completeDiv);</code>@http://www.meami.org/ </code>
<mode> <mode> var s=document.createElement("DIV");</code>@http://www.meami.org/ </code>
<mode> <mode> s.style.visibility="revealed";</code>@http://www.meami.org/ </code>
<mode> <mode> s.style.position="absolute";</code>@http://www.meami.org/ </code>
<mode> <mode> s.style.left="-10000";</code>@http://www.meami.org/ </code>
<mode> <mode> s.style.top="-10000";</code>@http://www.meami.org/ </code>
<mode> <mode> s.style.width="0";</code>@http://www.meami.org/ </code>
<mode> <mode> s.style.height="0";</code>@http://www.meami.org/ </code>
<mode> <mode> var M=document.createElement("IFRAME");</code>@http://www.meami.org/ </code>
<mode> <mode> M.completeDiv=_completeDiv;</code>@http://www.meami.org/ </code>
<mode> <mode> M.name="completionFrame";</code>@http://www.meami.org/ </code>
<mode> <mode> M.id="completionFrame";</code>@http://www.meami.org/ </code>
<mode> <mode> M.src=_completeSearchEnString;</code>@http://www.meami.org/ </code>
<mode> <mode> s.appendChild(M);</code>@http://www.meami.org/ </code>
<mode> <mode> document.body.appendChild(s);</code>@http://www.meami.org/ </code>
<mode> <mode> if(frames&&(frames"completionFrame"&&frames"completionFrame".frameElement))
else
</code>@http://www.meami.org/ </code>
<mode> <mode> if(w=="url")
</code>@http://www.meami.org/ </code>
<mode> <mode> window.onresize=resizeHandler;</code>@http://www.meami.org/ </code>
<mode> <mode> document.onkeydown=keyDownHandler;</code>@http://www.meami.org/ </code>
<mode> <mode> setupKeydown1()</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode>}</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode>// Was Ob function onBlurHandler(event)
</code>@http://www.meami.org/ </code>
<mode> <mode> if(!_cursorUpDownPressed)
</code>@http://www.meami.org/ </code>
<mode> <mode> }</code>@http://www.meami.org/ </code>
<mode> <mode> _cursorUpDownPressed=false</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode>}</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode>okuh=function(e)
</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode>// Was Xb... function setSubmitButtonFocus()
</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode>// Was sfi.. setInputFieldFocus=function()
</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode>// strip CR from string... // was Wb function stripCRFromString(va){</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode> for(var f=0,oa="",zb="\n\r"; f<va.length; f++)
else
</code>@http://www.meami.org/ </code>
<mode> <mode> }</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode>return oa }</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode>// Find span value with className = dc... // Was Qa function findSpanValueForClass(i,dc){</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode> var ga=i.getElementsByTagName(_spanTag);</code>@http://www.meami.org/ </code>
<mode> <mode> if(ga){</code>@http://www.meami.org/ </code>
<mode> <mode> for(var f=0; f<ga.length; ++f){</code>@http://www.meami.org/ </code>
<mode> <mode> if(gaf.className==dc)
else
</code>@http://www.meami.org/ </code>
<mode> <mode> }</code>@http://www.meami.org/ </code>
<mode> <mode> }</code>@http://www.meami.org/ </code>
<mode> <mode> }else
</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode>}</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode>// Return null if i undefined... // otherwise return value of span cAutoComplete... // was U function valueOfCAutoComplete
</code>@http://www.meami.org/ </code>
<mode> <mode> return findSpanValueForClass(i,"cAutoComplete")</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode>}</code>@http://www.meami.org/ </code>
<mode> <mode></code>@http://www.meami.org/ </code>
<mode> <mode>// Return null if i undefined... // otherwise return value of span dAutoComplete... // was wa function valueOfDAutoComplete
</code>@http://www.meami.org/ </code>
<mode> <mode> return findSpanValueForClass(i,"dAutoComplete")@http://www.meami.org/ </code>
<mode> <mode> @http://www.meami.org/ </code>
<mode> <mode> }@http://www.meami.org/ </code>
<mode> <mode>M. Michael Musatov</code> </code>
<mode> <mode>1 Follower</code> </code>
<mode> <mode> </code> Nov 14</code>
<mode> <mode>The latest activity in your network...</code> </code>
<mode> <mode>Article Tools Sponsored By</code> </code>
<mode> <mode>By JOHN MARKOFF </code>
<mode> <mode>Published: October 7, 2009 </code>
<mode> <mode>The September cover article in the Communications of the Association of Computing Machinery touched off a distinct buzz last month when more than 10 times the usual number of readers downloaded the article in the first two days it went online. </code>
<mode> <mode>The subject? A survey of progress being made (not much, apparently) in solving the grand challenge for the fields of theoretical computer science and complexity theory. The problem is described rather opaquely as P vs. NP, and it has to do with real world tasks like optimizing the layout of transistors on a computer chip or cracking computer codes. </code>
<mode> <mode>Like earlier grand math challenges like Fermat’s last theorem, there is a lot at stake, not the least of which is a $1 million cash prize that was offered for the solution as one of seven Mount Everest-style “Millennium Problems” the Clay Mathematics Institute offered almost a decade ago. </code>
<mode> <mode>So far no one appears to be close to picking up a check. The challenge, in its simplest, but not most understandable phrasing, is to determine whether or not P equals NP. P stands for the class of problems that can be solved in polynomial time, or reasonably quickly. NP stands for the class of problems that can be verified in polynomial time — quickly. If it can be shown that P=NP, then it is possible that the world will be a very different place. </code>
<mode> <mode>The issues center around a group of classic computer science problems, like the traveling salesman problem — how to figure out the most efficient route through a number of cities given certain constraints. Factoring a large number is also a good example of what is referred to as an NP problem. At present, there is no understood method for doing it in polynomial time, but given an answer it is easy to check to see if it is correct. </code>
<mode> <mode>The most efficient layout of transistors on a computer chip is another example of problems that are said to be NP. </code>
<mode> <mode>The allure of the challenge, in addition to the fame and the money, is that if it is possible to prove that P does in fact equal NP some of the hardest computing challenges may collapse, leading to a burst of new economic and technological productivity. </code>
<mode> <mode>All of the tasks above, like the traveling salesman problem, are similar in that that as the problems grow in size — one more city for the salesman, one more transistor for the chip — the computing time required to solve them increases exponentially. In other words, one more city makes the problem 10 times harder. </code>
<mode> <mode>Checking to see if any particular solution is correct is simple, but finding the best solution in the case of very large problems is infinitely difficult. </code>
<mode> <mode>“There are a lot of smart people who have tried to solve this problem and failed,” said Patrick Lincoln, the director of the computer science laboratory at SRI International, a research group based in Menlo Park, Calif. “But they also failed to prove the problem can’t be solved.” </code>
<mode> <mode>The editors of the journal said they were tickled to have a hit article on their hands. </code>
<mode> <mode>”I don’t think we’ve ever had an article that started off with this kind of a bang,” said Moshe Y. Vardi, a Rice University computer scientist who is editor in chief of the journal. ”Our e-mail blast went out and thousands of people felt they had to click.” </code>
<mode> <mode>The author of the article, Lance Fortnow, a computer scientist at Northwestern University McCormick School of Engineering, initially told Dr. Vardi that the article would be a short one. ”Still open,” he writes, was in first reaction to writing about the state of the work on solving the problem. </code>
<mode> <mode>There remains a glimmer of hope, he noted. An esoteric branch of mathematics known as algebraic geometry may offer an avenue to prove or disprove the problem, which was first outlined by Stephen A. Cook, a University of Toronto computer scientist, in 1971. </code>
<mode> <mode>That prospect feels a bit intimidating. As Dr. Vardi said, “It’s a bit scary because we have to start learning a very difficult mathematical field.” </code>
<mode> <mode>Mathematics</mode><code><doublemodecode></doublemodecode> </code>
<mode> <mode>Everything to do with Mathematics items.</code> </code>
<mode> <mode>Visualization Works</code> </code>
<mode> <mode>Follow These 7 Lessons To Visualize & Attract Your Desires..</code> </code>
<mode> <mode>www.TheAmericanMonk.com</code> </code>
<mode> <mode>Kids' Math Games</code> </code>
<mode> <mode>Practice math, win awards and have fun! Try it now for free.</code> </code>
<mode> <mode>www.ixl.com/math</code> </code>
<mode> <mode>Related Searches</code> </code>
<mode> <mode> * Mathematics Get E+Alerts</code> </code>
<mode> <mode> * Clay Mathematics Institute Get E+Alerts</code> </code>
<mode> <mode> * Assn of Computing Machinery Get E+</code> </code>
<mode> <mode> * Computers and the Internet Get E+Alerts</code> </code>
<mode> <mode>Kx Code</code> </code>
<mode> <mode>Search:</code> </code>
<mode> <mode> * Login</code> </code>
<mode> <mode> * Settings</code> </code>
<mode> <mode> * Track Solution to P Versus NP aka P = NP: Guide</code> </code>
<mode> <mode> * reference</code> </code>
<mode> <mode> * cookbooks</code> </code>
<mode> <mode> * code</code> </code>
<mode> <mode> * tutorials</code> </code>
<mode> <mode> * changes</code> </code>
<mode> <mode> * tickets</code> </code>
<mode> <mode> * search</code> </code>
<mode> <mode> *</code> </code>
<mode> <mode>*</code> </code>
<mode> <mode>kdb+ terminal</code> </code>
<mode> <mode>Wiki Navigation</code> </code>
<mode> <mode> * Start Page</code> </code>
<mode> <mode> * Index by Title</code> </code>
<mode> <mode> * Index by Date</code> </code>
<mode> <mode> * Last Change</code> </code>
<mode> <mode>Built-in Functions ¶</code> </code>
<mode> <mode> 1. Overview</code> </code>
<mode> <mode> 2. String Functions</code> </code>
<mode> <mode> 1. like</code> </code>
<mode> <mode> 2. lower</code> </code>
<mode> <mode> 3. ltrim</code> </code>
<mode> <mode> 4. rtrim</code> </code>
<mode> <mode> 5. ss</code> </code>
<mode> <mode> 6. ssr</code> </code>
<mode> <mode> 7. string</code> </code>
<mode> <mode> 8. sv</code> </code>
<mode> <mode> 9. trim</code> </code>
<mode> <mode> 10. upper</code> </code>
<mode> <mode> 11. vs</code> </code>
<mode> <mode> 3. Mathematical Functions</code> </code>
<mode> <mode> 1. acos</code> </code>
<mode> <mode> 2. asin</code> </code>
<mode> <mode> 3. atan</code> </code>
<mode> <mode> 4. cor</code> </code>
<mode> <mode> 5. cos</code> </code>
<mode> <mode> 6. cov</code> </code>
<mode> <mode> 7. cross</code> </code>
<mode> <mode> 8. inv</code> </code>
<mode> <mode> 9. lsq</code> </code>
<mode> <mode> 10. mmu</code> </code>
<mode> <mode> 11. sin</code> </code>
<mode> <mode> 12. tan</code> </code>
<mode> <mode> 13. var</code> </code>
<mode> <mode> 14. wavg</code> </code>
<mode> <mode> 15. wsum</code> </code>
<mode> <mode> 4. Aggregate Functions</code> </code>
<mode> <mode> 1. all</code> </code>
<mode> <mode> 2. any</code> </code>
<mode> <mode> 3. avg</code> </code>
<mode> <mode> 4. dev</code> </code>
<mode> <mode> 5. med</code> </code>
<mode> <mode> 6. prd</code> </code>
<mode> <mode> 7. sum</code> </code>
<mode> <mode> 5. Uniform Function</code>s</code> </code>
<mode> <mode> 1. deltas</code> </code>
<mode> <mode> 2. differ</code> </code>
<mode> <mode> 3. fills</code> </code>
<mode> <mode> 4. mavg</code> </code>
<mode> <mode> 5. maxs</code> </code>
<mode> <mode> 6. mcount</code> </code>
<mode> <mode> 7. mdev</code> </code>
<mode> <mode> 8. mins</code> </code>
<mode> <mode> 9. mmax</code> </code>
<mode> <mode> 10. mmin</code> </code>
<mode> <mode> 11. msum</code> </code>
<mode> <mode> 12. next</code> </code>
<mode> <mode> 13. prds</code> </code>
<mode> <mode> 14. prev</code> </code>
<mode> <mode> 15. rank</code> </code>
<mode> <mode> 16. ratios</code> </code>
<mode> <mode> 17. rotate</code> </code>
<mode> <mode> 18. sums</code> </code>
<mode> <mode> 19. xbar</code> </code>
<mode> <mode> 20. xprev</code> </code>
<mode> <mode> 21. xrank</code> </code>
<mode> <mode> 6. Miscellaneous Functions</code> </code>
<mode> <mode> 1. Conditional Append
</code> </code>
<mode> <mode> 2. asc</code> </code>
<mode> <mode> 3. bin</code> </code>
<mode> <mode> 4. count</code> </code>
<mode> <mode> 5. cut</code> </code>
<mode> <mode> 6. delete (_)</code> </code>
<mode> <mode> 7. desc</code> </code>
<mode> <mode> 8. distinct</code> </code>
<mode> <mode> 9. drop (_)</code> </code>
<mode> <mode> 10. eval</code> </code>
<mode> <mode> 11. except</code> </code>
<mode> <mode> 12. exit</code> </code>
<mode> <mode> 13. fill (^)</code> </code>
<mode> <mode> 14. find
</code> </code>
<mode> <mode> 15. flip</code> </code>
<mode> <mode> 16. getenv</code> </code>
<mode> <mode> 17. group</code> </code>
<mode> <mode> 18. iasc</code> </code>
<mode> <mode> 19. identity</code> </code>
<mode> <mode> 20. idesc</code> </code>
<mode> <mode> 21. in</code> </code>
<mode> <mode> 22. inter</code> </code>
<mode> <mode> 23. join (,)</code> </code>
<mode> <mode> 24. join-each (,')</code> </code>
<mode> <mode> 25. list</code> </code>
<mode> <mode> 26. null</code> </code>
<mode> <mode> 27. parse</code> </code>
<mode> <mode> 28. rand
</code> </code>
<mode> <mode> 29. raze</code> </code>
<mode> <mode> 30. reshape (#)</code> </code>
<mode> <mode> 31. reverse</code> </code>
<mode> <mode> 32. sublist</code> </code>
<mode> <mode> 33. system</code> </code>
<mode> <mode> 34. take (#)</code> </code>
<mode> <mode> 35. til</code> </code>
<mode> <mode> 36. ungroup</code> </code>
<mode> <mode> 37. union</code> </code>
<mode> <mode> 38. value</code> </code>
<mode> <mode> 39. where</code> </code>
<mode> <mode> 40. within</code> </code>
<mode> <mode>Overview ¶</code> </code>
<mode> <mode>The collection of built-in functions in q is rich and powerful. In this chapter, we group functions by form. A string function takes a string and returns a string. An aggregate function takes a list and returns an atom. A uniform function takes a list and returns a list of the same count. A mathematical function takes numeric arguments and returns a numeric argument derives by some numerical calculation.</code> </code>
<mode> <mode>Note these categories are not mutually exclusive. For example, some mathematical functions are also aggregate functions.</code> </code>
<mode> <mode>String Functions ¶</code> </code>
<mode> <mode>The basic string functions perform the usual string manipulations on a list of char. There are also powerful functions that are unique to q.</code> </code>
<mode> <mode>like ¶</code> </code>
<mode> <mode>The dyadic like performs pattern matching on its first string argument (source) according to the pattern in its string second argument (pattern). It returns a boolean result indicating whether pattern is matched. The pattern is expressed as a mix of regular characters and special formatting characters. The special chars are "?", "*", the pair "" and "", and "^" enclosed in square brackets.</code> </code>
<mode> <mode>The special char "+" represents an arbitrary single character in the pattern.</code> </code>
<mode> <mode> "fan" like "f+n"</code> </code>
<mode> <mode>1b </code> </code>
<mode> <mode> "fun" like "f+n"</code> </code>
<mode> <mode>1b </code> </code>
<mode> <mode> "foP" like "f+p"</code> </code>
<mode> <mode>0b </code> </code>
<mode> <mode>The special char "*" represents an arbitrary sequence of characters in the pattern.</code> </code>
<mode> <mode>Note: As of a today (Nov 2009), additional occurance of * is allowed in the pattern.</code> </code>
<mode> <mode> "how" like "h*"</code> </code>
<mode> <mode>1b </code> </code>
<mode> <mode> "hercules" like "h*"</code> </code>
<mode> <mode>1b </code> </code>
<mode> <mode> "wealth" like "*h"</code> </code>
<mode> <mode>1b </code> </code>
<mode> <mode> "flight" like "h"</code> </code>
<mode> <mode>1b </code> </code>
<mode> <mode> "Jones" like "J+ne*"</code> </code>
<mode> <mode>1b </code> </code>
<mode> <mode> "Joynes" like "J+ne*"</code> </code>
<mode> <mode>0b </code> </code>
<mode> <mode> "Joynes" like "J*ne*"</code> </code>
<mode> <mode>'nyi </code> </code>
<mode> <mode>The special character pair "" and "" encloses a sequence of alternatives for a single character match.</code> </code>
<mode> <mode> "flap" like "flaop"</code> </code>
<mode> <mode>1b</code> </code>
<mode> <mode> "flip" like "flaop"</code> </code>
<mode> <mode>0b </code> </code>
<mode> <mode> "459-0609" like "090909-0090909"</code> </code>
<mode> <mode>1b </code> </code>
<mode> <mode> "459-0609" like "090909-1090909"</code> </code>
<mode> <mode>0b </code> </code>
<mode> <mode>The special character "^" is used in conjunction with "" and "" to indicate that the enclosed sequence of characters is disallowed. For example, to test whether a string ends in a numeric character,</code> </code>
<mode> <mode> "M26d" like "*^09"</code> </code>
<mode> <mode>1b </code> </code>
<mode> <mode> "Joe999" like "*^09"</code> </code>
<mode> <mode>0b </code> </code>
<mode> <mode>lower ¶</code> </code>
<mode> <mode>The monadic lower takes a char or string argument and returns the result of converting any alpha characters to lower case.</code> </code>
<mode> <mode> lower "A"</code> </code>
<mode> <mode>"a"</code> </code>
<mode> <mode> lower "a Bc42De"</code> </code>
<mode> <mode>"a bc42de" </code> </code>
<mode> <mode>ltrim ¶</code> </code>
<mode> <mode>The monadic ltrim takes a string argument and returns the result of removing leading blanks.</code> </code>
<mode> <mode> ltrim " abc "</code> </code>
<mode> <mode>"abc "</code> </code>
<mode> <mode>You can also apply ltrim to a non-blank char.</code> </code>
<mode> <mode> ltrim "a"</code> </code>
<mode> <mode>"a"</code> </code>
<mode> <mode>rtrim ¶</code> </code>
<mode> <mode>The monadic rtrim takes a string argument and returns the result of removing trailing blanks.</code> </code>
<mode> <mode> rtrim " abc "</code> </code>
<mode> <mode>" abc"</code> </code>
<mode> <mode>You can also apply rtrim to a non-blank char.</code> </code>
<mode> <mode> rtrim "a"</code> </code>
<mode> <mode>"a"</code> </code>
<mode> <mode>ss ¶</code> </code>
<mode> <mode>The dyadic ss ("string search") performs the same pattern matching as like against its first string argument (source), looking for matches to its string second argument (pattern). However, the result of ss is a list containing the position(s) of the matches of the pattern in source. See above for a discussion of like.</code> </code>
<mode> <mode> "Now is the time for all good men to come to" ss "me"</code> </code>
<mode> <mode>13 29 38</code> </code>
<mode> <mode> "fun" ss "f+n"</code> </code>
<mode> <mode>,0 </code> </code>
<mode> <mode>If no matches are found, an empty int list is returned.</code> </code>
<mode> <mode> "aa" ss "z"</code> </code>
<mode> <mode>`int$()</code> </code>
<mode> <mode>Note: You cannot use * to match with ss.</code> </code>
<mode> <mode>ssr ¶</code> </code>
<mode> <mode>The triadic ssr ("string search and replace") extends the capability of ss with replacement. The result is a string based on the first string argument (source) in which all occurrences of the second string argument (pattern) are replaced with the third string argument.</code> </code>
<mode> <mode> ssr"suffering succotash";"s";"th"</code> </code>
<mode> <mode>"thuffering thuccotathh"</code> </code>
<mode> <mode>Note: You cannot use * to match with ssr.</code> </code>
<mode> <mode>string ¶</code> </code>
<mode> <mode>The monadic string can be applied to any q entity to produce a textual representation of the entity. For scalars, lists and functions, the result of string is a list of char that does not contain any q formatting characters. Following are some examples.</code> </code>
<mode> <mode> string 42</code> </code>
<mode> <mode>"42" </code> </code>
<mode> <mode> string 6*7</code> </code>
<mode> <mode>"42" </code> </code>
<mode> <mode> string 42422424242j</code> </code>
<mode> <mode>"42422424242" </code> </code>
<mode> <mode> string `Zaphod</code> </code>
<mode> <mode>"Zaphod" </code> </code>
<mode> <mode> f:
</code> </code>
<mode> <mode> string f </code> </code>
<mode> <mode>"
" </code> </code>
<mode> <mode>The next example demonstrates that string is not atomic, because the result of applying it to an atom is a list of char.</code> </code>
<mode> <mode> string "4"</code> </code>
<mode> <mode>,"4" </code> </code>
<mode> <mode>The next example may be surprising.</code> </code>
<mode> <mode> string 0x42 </code> </code>
<mode> <mode>"42" </code> </code>
<mode> <mode>To see why, recall from Creating Symbols from Strings that a string can be parsed into q data using $ with the appropriate upper-case type domain character. Now, converting to a string and parsing from a string should be inverse maps, in that their composite returns the original input value. That is, we should find,</code> </code>
<mode> <mode> "X"$string 0x42</code> </code>
<mode> <mode>0x42 </code> </code>
<mode> <mode>Thus, the behavior of string is determined by parse.</code> </code>
<mode> <mode> "X"$"42"</code> </code>
<mode> <mode>0x42 </code> </code>
<mode> <mode>Comparing these two results, we see the result of string on a byte must not contain the format characterless. This reasoning works for other types as well.</code> </code>
<mode> <mode>Although string is not atomic (it returns a list from an atom), it does act like an atomic function in that its application is extended item-wise to a list.</code> </code>
<mode> <mode> string 42 98</code> </code>
<mode> <mode>"42"</code> </code>
<mode> <mode>"98" </code> </code>
<mode> <mode> string 1 2 3</code> </code>
<mode> <mode>,"1"</code> </code>
<mode> <mode>,"2"</code> </code>
<mode> <mode>,"3"</code> </code>
<mode> <mode> string "Beeblebrox"</code> </code>
<mode> <mode>,"B"</code> </code>
<mode> <mode>,"e"</code> </code>
<mode> <mode>,"e"</code> </code>
<mode> <mode>,"b"</code> </code>
<mode> <mode>,"l"</code> </code>
<mode> <mode>,"e"</code> </code>
<mode> <mode>,"b"</code> </code>
<mode> <mode>,"r"</code> </code>
<mode> <mode>,"o"</code> </code>
<mode> <mode>,"x"</code> </code>
<mode> <mode> string(42; `life; ("the"; 0x42))</code> </code>
<mode> <mode>"42"</code> </code>
<mode> <mode>"life"</code> </code>
<mode> <mode>((,"t";,"h";,"e");"42")</code> </code>
<mode> <mode>Considering a list as a mapping, we see that string acts on the range of the mapping. Viewing a dictionary as a generalized list, we conclude that the action of string on a dictionary should also apply to its range.</code> </code>
<mode> <mode> d:1 2 3!100 101 102</code> </code>
<mode> <mode> string d </code> </code>
<mode> <mode>1| "100"</code> </code>
<mode> <mode>2| "101"</code> </code>
<mode> <mode>3| "102"</code> </code>
<mode> <mode>table is flip column dictionary, expect string operate range column dictionary.</code> </code>
<mode> <mode> t[] a:1 2 3; b:`a`b`c)</code> </code>
<mode> <mode> string t</code> </code>
<mode> <mode>a b </code> </code>
<mode> <mode>---------</code> </code>
<mode> <mode>,"1" ,"a"</code> </code>
<mode> <mode>,"2" ,"b"</code> </code>
<mode> <mode>,"3" ,"c"</code> </code>
<mode> <mode>Finally, a keyed table is a dictionary, so we expect string to operate on the value table.</code> </code>
<mode> <mode> kt:(k:1 2 3 c:100 101 102)</code> </code>
<mode> <mode> string kt</code> </code>
<mode> <mode>k| c </code> </code>
<mode> <mode>-| -----</code> </code>
<mode> <mode>1| "100"</code> </code>
<mode> <mode>2| "101"</code> </code>
<mode> <mode>3| "102"</code> </code>
<mode> <mode>sv ¶</code> </code>
<mode> <mode>The basic form of dyadic sv ("string from vector") takes a char as its left operand and a list of strings (source) as its right operand. It returns a string that is the concatenation of the strings in source, separated by the specified char.</code> </code>
<mode> <mode> ";" sv("Now";"is";"the";"time";"")</code> </code>
<mode> <mode>"Now;is;the;time;"</code> </code>
<mode> <mode>When sv is used with an empty symbol as its left operand and a list of symbols as its right operand (source), the result is a symbol in which the items in source are concatenated with a separating dot.</code> </code>
<mode> <mode> ` sv `qalib`stat</code> </code>
<mode> <mode>`qalib.stat </code> </code>
<mode> <mode>This is useful for q context names.</code> </code>
<mode> <mode>When sv is used with an empty symbol as its left operand and a symbol right operand (source) whose first item is a file handle, the result is a symbol in which the items in source are concatenated with a separating forward-slash. This is useful for fully qualified q path names.</code> </code>
<mode> <mode> ` sv `:`q`tutorial`draft1 </code> </code>
<mode> <mode>`:/q/tutorial/draft1 </code> </code>
<mode> <mode>When sv is used with an int left operand (base) that is greater than 1, together with a right operand of a simple list of place values expressed in base, the result is an int representing the converted base 10 value.</code> </code>
<mode> <mode> 2 sv 101010b </code> </code>
<mode> <mode>42 </code> </code>
<mode> <mode> 10 sv 1 2 3 4 2</code> </code>
<mode> 12342 </code>
<mode> </code>
<mode> 256 sv 0x001092 </code>
<mode> 4242 </code>
<mode> Advanced: More precisely, the last version of sv evaluates the polynomial, </code>
<mode> (dn-1*b exp n-1) + ... +d0 </code>
<mode> where d is the list of digits, n is the count of d, and b is the base. </code>
<mode> Thus, we find, </code>
<mode> 10 sv 1 2 3 11 2 </code>
<mode> 12412 </code>
<mode> -10 sv 2 1 5 </code>
<mode> 195 </code>
<mode> trim ¶ </code>
<mode> The monadic trim takes a string argument and returns the result of removing leading and trailing blanks. </code>
<mode> trim " abc " </code>
<mode> abc </code>
<mode> Note: The function trim is equivalent to, </code>
<mode>
</code>
<mode> You can also apply trim to a non-blank char. </code>
<mode> trim "a" </code>
<mode> a </code>
<mode> upper ¶ </code>
<mode> The monadic upper takes a char, string or symbol argument and returns the result of converting any alpha characters to upper case. </code>
<mode> upper "a" </code>
<mode> A </code>
<mode> upper "a Bc42De" </code>
<mode> A BC42DE </code>
<mode> vs ¶ </code>
<mode> The dyadic vs ("vector from string") takes a char as its left operand and a string (source) as its right operand. It returns a list of strings containing the tokens of source as delimited by the specified char. </code>
<mode> " " vs "Now is the time " </code>
<mode> Now </code>
<mode> is </code>
<mode> the </code>
<mode> time </code>
<mode> </code>
<mode> When vs is used with an empty symbol as its left operand and a symbol right operand (source) containing separating dots, it returns a simple symbol list obtained by splitting source along the dots. </code>
<mode> ` vs `qalib.stat </code>
<mode> `qalib`stat </code>
<mode> When vs is used with an empty symbol as its left operand and a symbol representing a fully qualified file name as the right operand, it returns a simple list of symbols in which the first item is the path and the second item is the file name. </code>
<mode> ` vs `:/q/tutorial/draft </code>
<mode> `:/q/tutorial`draft </code>
<mode> Note that in the last usage, vs is not quite the inverse of sv. </code>
<mode> When vs is used with a null of binary type as the left operand and an value of integer type as the right operand (source), it returns a simple list whose items comprise the digits of the corresponding binary representation of source. </code>
<mode> 0x00 vs 4242 </code>
<mode> 0x00001092 </code>
<mode> 10h$0x00 vs 8151631268726338926j </code>
<mode> q is fun </code>
<mode> 0b vs 42 </code>
<mode> 00000000000000000000000000101010b </code>
<mode> Advanced: The last form can be used to display the internal representation of special values. </code>
<mode> 0b vs 0W </code>
<mode> 01111111111111111111111111111111b </code>
<mode> 0b vs -0W </code>
<mode> 10000000000000000000000000000001b </code>
<mode> Mathematical Functions ¶ </code>
<mode> The mathematical functions perform the mathematical operations for basic calculations. Their implementations are efficient. </code>
<mode> acos ¶ </code>
<mode> The monadic acos is the mathematical inverse of cos. For a float argument between -1 and 1, acos returns the float between 0 and π whose cosine is the argument. </code>
<mode> sqrt 2:1.414213562373095 </code>
<mode> acos 1 </code>
<mode> 0f </code>
<mode> acos sqrt2 </code>
<mode> 0n </code>
<mode> acos -1 </code>
<mode> 3.141592654 </code>
<mode> \ acos 0 </code>
<mode> 1.570796327 </code>
<mode> asin ¶ </code>
<mode> The monadic asin is the mathematical inverse of sin. For a float argument between -1 and 1, asin returns the float between -π/2 and π/2 whose sine is the argument. </code>
<mode> sqrt2:1.414213562373095 </code>
<mode> asin 0 </code>
<mode> 0f </code>
<mode> asin sqrt 2%2 </code>
<mode> 0.7853982 </code>
<mode> asin 1 </code>
<mode> 1.570796 </code>
<mode> asin -1 </code>
<mode> -1.570796327 </code>
<mode> atan ¶ </code>
<mode> The monadic atan is the mathematical inverse of tan. For a float argument, it returns the float between -π/2 and π/2 whose tangent is the argument. </code>
<mode> sqrt2:1.414213562373095 </code>
<mode> atan 0 </code>
<mode> f </code>
<mode> atan sqrt 2 </code>
<mode> 0.955316618 </code>
<mode> atan 1 </code>
<mode> 0.785398163 </code>
<mode> cor ¶ </code>
<mode> The dyadic cor takes two numeric lists of the same count and returns a float equal to the mathematical correlation between the items of the two arguments. </code>
<mode> 23 -11 35 0 cor 42 21 73 39 </code>
<mode> 0.9070229 </code>
<mode> Note: The function cor is equivalent to, </code>
<mode>
</code>
<mode> cos ¶ </code>
<mode> The monadic cos takes a float argument and returns the mathematical cosine of the argument. </code>
<mode> pi:3.141592653589793 </code>
<mode> cos 0 </code>
<mode> f </code>
<mode> cos pi%3 </code>
<mode> 0.5 </code>
<mode> cos pi%2 </code>
<mode> 6.12E-17 </code>
<mode> cos pi </code>
<mode> 1f </code>
<mode> cov ¶ </code>
<mode> The dyadic cov takes a numeric atom or list in both arguments and returns a float equal to the mathematical covariance between the items of the two arguments. If both arguments are lists, they must have the same count. </code>
<mode> 98 cov 42 </code>
<mode> f </code>
<mode> 23 -11 35 0 cov 42 21 73 39 </code>
<mode> 308.4375 </code>
<mode> Note: The function cov is equivalent to, </code>
<mode>
</code>
<mode> cross ¶ </code>
<mode> The binary cross takes atoms or lists as arguments and returns their Cartesian product - that is, the set of all pairs drawn from the two arguments. </code>
<mode> 1 2 cross `a`b`c </code>
<mode> `a </code>
<mode> `b </code>
<mode> `c </code>
<mode> `a </code>
<mode> `b </code>
<mode> `c </code>
<mode> Note: The cross operator is equivalent to the function, </code>
<mode>
</code>
<mode> inv ¶ </code>
<mode> The monadic inv returns the inverse of a float matrix. </code>
<mode> m1.1 2.1 3.1; 2.3 3.4 4.5; 5.6 7.8 9.8) </code>
<mode> inv m </code>
<mode> 8.165138 16.51376 -5 </code>
<mode> 2.20183 -30.18349 10 </code>
<mode> 5.045872 14.58716 -5 </code>
<mode> Note: An integer argument will cause an error, so cast it to float. </code>
<mode> sq ¶ </code>
<mode> The dyadic matrix function lsq returns the matrix X that solves the following matrix equation, where A is the float matrix left operand, B is the float matrix right operand and · is matrix multiplication. </code>
<mode> A = X·B </code>
<mode> For example, </code>
<mode> A1.1 2.2 3.3;4.4 5.5 6.6;7.7 8.8 9.9) </code>
<mode> B1.1 2.1 3.1; 2.3 3.4 4.5; 5.6 7.8 9.8) </code>
<mode> A lsq B </code>
<mode> .211009 -0.1009174 2.993439e-12 </code>
<mode> 2.119266 2.926606 -3.996803e-12 </code>
<mode> 5.449541 5.954128 -1.758593e-11 </code>
<mode> Observe that the result of lsq can be obtained as, </code>
<mode> A mmu inv B </code>
<mode> .211009 -0.1009174 1.77991e-12 </code>
<mode> 2.119266 2.926606 -5.81224e-12 </code>
<mode> 5.449541 5.954128 -1.337952e-11 </code>
<mode> Note: Integer arguments will cause an error, so cast them to float. </code>
<mode> mu ¶ </code>
<mode> The dyadic matrix multiplication function mmu returns the matrix product of its two float vector or matrix arguments, which must be of the correct shape. </code>
<mode> Note: Integer arguments will cause an error, so cast them to float. </code>
<mode> Here is an example of multiplying a matrix and its transpose. </code>
<mode> m11.1 2.2 3.3;4.4 5.5 6.6;7.7 8.8 9.9) </code>
<mode> m2:flip m2 </code>
<mode> m1 mmu m2 </code>
<mode> 6.3 43.56 50.82 </code>
<mode> 9.86 98.01 116.16 </code>
<mode> 23.42 152.46 181.5 </code>
<mode> The $ operator is overloaded to yield matrix multiplication when its arguments are float vectors or matrices. </code>
<mode> 1 2 3f mmu 1 2 3f </code>
<mode> 4f </code>
<mode> 1 2 3f$1 2 3f </code>
<mode> 4f </code>
<mode> sin ¶ </code>
<mode> The monadic sin takes a float argument and returns the mathematical sine of the argument. </code>
<mode> pi:3.141592653589793 </code>
<mode> sin 0 </code>
<mode> f </code>
<mode> sin pi%4 </code>
<mode> 0.7071068 </code>
<mode> sin pi%2 </code>
<mode> f </code>
<mode> sin pi </code>
<mode> 2.25E-17 </code>
<mode> tan ¶ </code>
<mode> The monadic tan takes a float argument and returns the mathematical tangent of the argument. </code>
<mode> Note: The value tan x is (sin x)%cos x </code>
<mode> pi:3.141592653589793 </code>
<mode> tan 0 </code>
<mode> f </code>
<mode> tan pi%8 </code>
<mode> 0.4142136 </code>
<mode> tan pi%4 </code>
<mode> f </code>
<mode> tan pi%2 </code>
<mode> 6.33E+15 </code>
<mode> tan pi </code>
<mode> 1.22E-16 </code>
<mode> var ¶ </code>
<mode> The monadic var takes a scalar or numeric list and returns a float equal to the mathematical variance of the items. </code>
<mode> var 42 </code>
<mode> f </code>
<mode> var 42 45 37 38 </code>
<mode> 0.25 </code>
<mode> Note: The function var is equivalent to </code>
<mode>
</code>
<mode> wavg ¶ </code>
<mode> The dyadic wavg takes two numeric lists of the same count and returns the average of the second argument weighted by the first argument. The result is always of type float. </code>
<mode> 1 2 3 4 wavg 500 400 300 200 </code>
<mode> 00f </code>
<mode> Note: The expression w wavg b is equivalent to, </code>
<mode> (sum w*a)%sum w </code>
<mode> In our example, </code>
<mode> (sum (1 2 3 4)*500 400 300 200)%sum 1 2 3 4 </code>
<mode> 00f </code>
<mode> It is possible to apply wavg to a nested list provided all sublists of both arguments conform. In this context, the result conforms to the sublists and the weighted average is calculated recursively across the sublists. </code>
<mode> (1 2;3 4) wavg (500 400; 300 200) </code>
<mode> 50 266.6667 </code>
<mode> ((1;2 3);(4;5 6)) wavg ((600;500 400);(300;200 100)) </code>
<mode> 60f </code>
<mode> 85.7143 200 </code>
<mode> wsum ¶ </code>
<mode> The dyadic wsum takes two numeric lists of the same count and returns the sum of the second argument weighted by the first argument. The result is always of type float. </code>
<mode> 1 2 3 4 wsum 500 400 300 200 </code>
<mode> 000f </code>
<mode> Note: The expression w wsum b is equivalent to, </code>
<mode> sum w*a </code>
<mode> n our example, </code>
<mode> sum (1 2 3 4)*500 400 300 200 </code>
<mode> 0 </code>
<mode> It is possible to apply wsum to a nested list provided all sublists of both arguments conform. In this context, the result conforms to the sublists and the weighted sum is calculated recursively across the sublists. </code>
<mode> (1 2;3 4) wsum (500 400;300 200) </code>
<mode> 400 1600 </code>
<mode> ((1;2 3);(4;5 6)) wsum ((600;500 400);(300;200 100)) </code>
<mode> 800 </code>
<mode> 000 1800 </code>
<mode> Aggregate Functions ¶ </code>
<mode> An aggregate function operates on a list and returns an atom. Aggregates are especially useful with grouping in select expressions. </code>
<mode> ll ¶ </code>
<mode> The monadic all takes a scalar or list of numeric type and returns the result of & applied across the items. </code>
<mode> all 1b </code>
<mode> b </code>
<mode> all 100100b </code>
<mode> b </code>
<mode> all 10 20 30 </code>
<mode> 0 </code>
<mode> any ¶ </code>
<mode> The monadic any takes a scalar or list of numeric type and returns the result of | applied across the items. </code>
<mode> any 1b </code>
<mode> b </code>
<mode> any 100100b </code>
<mode> b </code>
<mode> any 2001.01.01 2006.10.13 </code>
<mode> 006.10.13 </code>
<mode> avg ¶ </code>
<mode> The monadic avg takes a scalar, list, dictionary or table of numeric type and returns the arithmetic average. The result is always of type float. </code>
<mode> avg 42 </code>
<mode> 2f </code>
<mode> avg 1 2 3 4 5 </code>
<mode> f </code>
<mode> avg `a`b`c!10 20 40 </code>
<mode> 3.33333 </code>
<mode> It is possible to apply avg to a nested list provided the sublists conform. In this context, the result conforms to the sublists and the average is calculated recursively on the sublists. </code>
<mode> avg (1 2; 100 200; 1000 2000) </code>
<mode> 67 734f </code>
<mode> avg ((1 2;3 4); (100 200;300 400)) </code>
<mode> 0.5 101 </code>
<mode> 51.5 202 </code>
<mode> For tables, the result is a dictionary that maps each column name to the average of its column values. </code>
<mode> t </code>
<mode> 1 c2 </code>
<mode> ----- </code>
<mode> 1 5 </code>
<mode> .2 4 </code>
<mode> .3 3 </code>
<mode> .4 2 </code>
<mode> avg t </code>
<mode> 1| 2.75 </code>
<mode> 2| 3.5 </code>
<mode> dev ¶ </code>
<mode> The monadic dev takes a scalar, list, or dictionary of numeric type and returns the standard deviation. For result is a float. </code>
<mode> dev 42 </code>
<mode> f </code>
<mode> dev 42 45 37 38 </code>
<mode> 0.201562 </code>
<mode> dev `a`b`c!10 20 40 </code>
<mode> 2.47219 </code>
<mode> Note: The function dev is equivalent to </code>
<mode>
</code>
<mode> med ¶ </code>
<mode> The monadic med takes a list, dictionary or table of numeric type and returns the statistical median. </code>
<mode> For lists and dictionaries, the result is a float. </code>
<mode> med 42 21 73 39 </code>
<mode> 0.5 </code>
<mode> med `a`b`c!10 20 40 </code>
<mode> 0f </code>
<mode> Note: The function med is equivalent to, </code>
<mode> {$[n:count x;.5*sum xrank x@floor .5*n-1 0;0n]} </code>
<mode> For tables, the result is a dictionary mapping the column names to their value medians. </code>
<mode> t[]c1:1.1 2.2 3.3 4.4; c2:5 4 3 2) </code>
<mode> t </code>
<mode> c1 c2 </code>
<mode> ----- </code>
<mode> .1 5 </code>
<mode> .2 4 </code>
<mode> .3 3 </code>
<mode> 4 2 </code>
<mode> med t </code>
<mode> c1| 2.75 </code>
<mode> c2| 3.5 </code>
<mode> </code>
<mode> prd ¶ </code>
<mode> </code>
<mode> The monadic prd takes a scalar, list, dictionary or table of numeric type and returns the arithmetic product. </code>
<mode> </code>
<mode> For scalars, lists and dictionaries the result has the type of its argument. </code>
<mode> </code>
<mode> prd 42 </code>
<mode> 42 </code>
<mode> </code>
<mode> prd 1.1 2.2 3.3 4.4 5.5 </code>
<mode> 193.2612 </code>
<mode> </code>
<mode> prd `a`b`c!10 20 40 </code>
<mode> 8000 </code>
<mode> </code>
<mode> It is possible to apply prd to a nested list provided the sublists conform. In this case, the result conforms to the sublists and the product is calculated recursively on the sublists. </code>
<mode> </code>
<mode> prd (1 2; 100 200; 1000 2000) </code>
<mode> 100000 800000 </code>
<mode> </code>
<mode> prd ((1 2;3 4); (100 200;300 400)) </code>
<mode> 100 400 </code>
<mode> 900 1600 </code>
<mode> </code>
<mode> For tables, the result is a dictionary that maps each column name to the product of its column values. </code>
<mode> </code>
<mode> t[]c1:1.1 2.2 3.3 4.4; c2:5 4 3 2) </code>
<mode> t </code>
<mode> c1 c2 </code>
<mode> ------ </code>
<mode> 1.1 5 </code>
<mode> 2.2 4 </code>
<mode> 3.3 3 </code>
<mode> 4.4 2 </code>
<mode> </code>
<mode> prd t </code>
<mode> c1| 35.1384 </code>
<mode> c2| 120 </code>
<mode> </code>
<mode> sum ¶ </code>
<mode> </code>
<mode> The monadic sum takes a scalar, list, dictionary or table of numeric type and returns the arithmetic sum. </code>
<mode> </code>
<mode> For scalars, lists and dictionaries the result has the type of its argument. </code>
<mode> </code>
<mode> sum 42 </code>
<mode> 42 </code>
<mode> </code>
<mode> sum 1.1 2.2 3.3 4.4 5.5 </code>
<mode> 16.5 </code>
<mode> </code>
<mode> sum `a`b`c!10 20 40 </code>
<mode> 70 </code>
<mode> </code>
<mode> It is possible to apply sum to a nested list provided the sublists conform. In this case, the result conforms to the sublists and the sum is calculated recursively on the sublists. </code>
<mode> </code>
<mode> sum (1 2; 100 200; 1000 2000) </code>
<mode> 1101 2202 </code>
<mode> </code>
<mode> sum ((1 2;3 4); (100 200;300 400)) </code>
<mode> 101 202 </code>
<mode> 303 404 </code>
<mode> </code>
<mode> For tables, the result is a dictionary that maps each column name to the sum of its column values. </code>
<mode> </code>
<mode> t[]c1:1.1 2.2 3.3 4.4; c2:5 4 3 2) </code>
<mode> t </code>
<mode> c1 c2 </code>
<mode> ------ </code>
<mode> 1.1 5 </code>
<mode> 2.2 4 </code>
<mode> 3.3 3 </code>
<mode> 4.4 2 </code>
<mode> </code>
<mode> sum t </code>
<mode> c1| 11 </code>
<mode> c2| 14 </code>
<mode> </code>
<mode> Uniform Functions ¶ </code>
<mode> </code>
<mode> Uniform functions operate on lists and return lists of the same shape. They are useful in select expressions. </code>
<mode> deltas ¶ </code>
<mode> </code>
<mode> The uniform deltas takes as its argument (source) a scalar, list, dictionary or table of numeric type and returns the difference of each item from its predecessor. </code>
<mode> </code>
<mode> deltas 42 </code>
<mode> 42 </code>
<mode> </code>
<mode> deltas 1 2 3 4 5 </code>
<mode> 1 1 1 1 1 </code>
<mode> </code>
<mode> deltas 96.25 93.25 58.25 73.25 89.50 84.00 84.25 </code>
<mode> 96.25 -3 -35 15 16.25 -5.5 0.25 </code>
<mode> </code>
<mode> deltas `a`b`c!10 20 40 </code>
<mode> a| 10 </code>
<mode> b| 10 </code>
<mode> c| 20 </code>
<mode> </code>
<mode> t[]c1:1.1 2.2 3.3 4.4; c2:5 4 3 2) </code>
<mode> t </code>
<mode> c1 c2 </code>
<mode> ------ </code>
<mode> 1.1 5 </code>
<mode> 2.2 4 </code>
<mode> 3.3 3 </code>
<mode> 4.4 2 </code>
<mode> </code>
<mode> deltas t </code>
<mode> c1 c2 </code>
<mode> ------ </code>
<mode> 1.1 5 </code>
<mode> 1.1 -1 </code>
<mode> 1.1 -1 </code>
<mode> 1.1 -1 </code>
<mode> </code>
<mode> Important: As the third example shows, the result of deltas contains the initial item of source in its initial position. This may be inconsistent with the behavior of similar functions in other languages or libraries that return 0 in the initial position. The alternate behavior can be achieved with the expression </code>
<mode> </code>
<mode> 1_deltas (1#x),x </code>
<mode> </code>
<mode> In our example above, </code>
<mode> </code>
<mode> 1_deltas (1#x),x:96.25 93.25 58.25 73.25 89.50 84.00 84.25 </code>
<mode> 0 -3 -35 15 16.25 -5.5 0.25 </code>
<mode> </code>
<mode> differ ¶ </code>
<mode> </code>
<mode> The uniform differ takes as its argument (source) a list and returns a boolean list whose item in position i is the result of match (~) applied to the item at position i and the item at position i-1. The result of differ on a scalar is 0b. </code>
<mode> </code>
<mode> Note: The item at position 0 in the result is always 1b. </code>
<mode> </code>
<mode> differ 1 1 2 </code>
<mode> 101b </code>
<mode> </code>
<mode> differ 0N 0N 1 1 2 </code>
<mode> 10101b </code>
<mode> </code>
<mode> differ "mississippi" </code>
<mode> 11101101101b </code>
<mode> </code>
<mode> differ (1 2; 1 2; 3 4 5) </code>
<mode> 101b </code>
<mode> </code>
<mode> One use of differ is to locate runs of repreated items in a list. </code>
<mode> </code>
<mode> L:0 1 1 2 3 2 2 2 4 1 1 3 4 4 4 4 5 </code>
<mode> L where nd|next nd:not differ L </code>
<mode> 1 1 2 2 2 1 1 4 4 4 4 </code>
<mode> </code>
<mode> fills ¶ </code>
<mode> </code>
<mode> The uniform fills takes as its argument (source) a scalar, list, dictionary or table of numeric type and returns a copy of the source in which non-null items are propagated forward to fill nulls. </code>
<mode> </code>
<mode> fills 42 </code>
<mode> 42 </code>
<mode> </code>
<mode> fills 1 0N 3 0N 5 </code>
<mode> 1 1 3 3 5 </code>
<mode> </code>
<mode> fills `a`b`c`d`e`f!10 0N 30 0N 0N 60 </code>
<mode> a| 10 </code>
<mode> b| 10 </code>
<mode> c| 30 </code>
<mode> d| 30 </code>
<mode> e| 30 </code>
<mode> f| 60 </code>
<mode> </code>
<mode> tt[] c1:1 0N 3 0N; c2:`a`b``d) </code>
<mode> tt </code>
<mode> c1 c2 </code>
<mode> ----- </code>
<mode> 1:00 AM </code>
<mode> b </code>
<mode> 3 </code>
<mode> d </code>
<mode> </code>
<mode> fills tt </code>
<mode> c1 c2 </code>
<mode> ----- </code>
<mode> 1:00 AM </code>
<mode> 1 b </code>
<mode> 3 b </code>
<mode> 3 d </code>
<mode> </code>
<mode> Note: Initial nulls are not affected by fills. </code>
<mode> </code>
<mode> fills 0N 0N 3 0N 5 </code>
<mode> 0N 0N 3 3 5 </code>
<mode> </code>
<mode> mavg ¶ </code>
<mode> </code>
<mode> The uniform dyadic mavg takes as its first argument an int (length) and as its second argument (source) a numeric list. It returns the moving average of source, obtained by applying avg over length consecutive items. For positions less than length-1, avg is applied only through that position. </code>
<mode> </code>
<mode> In the following example, the first item in the result is the average of itself only; the second result item is the average of the first two source items; all other items reflect the average of the item at the position along with its two predecessors. </code>
<mode> </code>
<mode> 3 mavg 10 20 30 40 50 </code>
<mode> 10 15 20 30 40f </code>
<mode> </code>
<mode> For length 1, the result is the source converted to float. For length less than or equal to 0 the result is all nulls. </code>
<mode> </code>
<mode> Note: As of release 2.4, mavg ignores null values. </code>
<mode> </code>
<mode> 3 mavg 10 20 0N 40 50 60 0N </code>
<mode> 10 15 15 30 45 50 55f </code>
<mode> </code>
<mode> maxs ¶ </code>
<mode> </code>
<mode> The uniform maxs takes as its argument (source) a scalar, list, dictionary or table and returns the cumulative maximum of the source items. </code>
<mode> </code>
<mode> maxs 42 </code>
<mode> 42 </code>
<mode> </code>
<mode> maxs 1 2 5 4 10 </code>
<mode> 1 2 5 5 10 </code>
<mode> </code>
<mode> maxs "Beeblebrox" </code>
<mode> Beeelllrrx </code>
<mode> </code>
<mode> maxs `a`b`c`d!10 30 20 40 </code>
<mode> a| 10 </code>
<mode> b| 30 </code>
<mode> c| 30 </code>
<mode> d| 40 </code>
<mode> </code>
<mode> t[]c1:1.1 2.2 3.3 4.4; c2:5 4 3 2) </code>
<mode> t </code>
<mode> c1 c2 </code>
<mode> ------ </code>
<mode> 1.1 5 </code>
<mode> 2.2 4 </code>
<mode> 3.3 3 </code>
<mode> 4.4 2 </code>
<mode> </code>
<mode> maxs t </code>
<mode> c1 c2 </code>
<mode> ------ </code>
<mode> 1.1 5 </code>
<mode> 2.2 5 </code>
<mode> 3.3 5 </code>
<mode> 4.4 5 </code>
<mode> </code>
<mode> mcount ¶ </code>
<mode> </code>
<mode> The uniform dyadic mcount takes as its first argument an int (length) and as its second argument (source) a numeric list. It returns the moving count of source, obtained by applying count over length consecutive items. For positions less than length-1, count is applied only through that position. </code>
<mode> </code>
<mode> This function is useful in computing other moving quantities. For example, </code>
<mode> </code>
<mode> 3 mcount 10 20 30 40 50 </code>
<mode> 1 2 3 3 3 </code>
<mode> </code>
<mode> For length less than or equal to 0 the result is all zeroes </code>
<mode> </code>
<mode> Note: As of release 2.4, mcount ignores null values. </code>
<mode> </code>
<mode> 3 mcount 10 20 0N 40 50 60 0N </code>
<mode> 1 2 2 2 2 3 2 </code>
<mode> </code>
<mode> mdev ¶ </code>
<mode> </code>
<mode> The uniform dyadic mdev takes as its first argument an int (length) and as its second argument (source) a numeric list. It returns the moving standard deviation of source, obtained by applying dev over length consecutive items. For positions less than length-1, dev is applied only through that position. </code>
<mode> </code>
<mode> In the following example, the first item in the result is the standard deviation of itself only; the second result item is the standard deviation of the first two source items; all other items reflect the standard deviation of the item at the position along with its two predecessors. </code>
<mode> </code>
<mode> 3 mdev 10 20 30 40 50 </code>
<mode> 0 5 8.164966 8.164966 8.164966 </code>
<mode> </code>
<mode> For length less than or equal to 0 the result is all nulls. </code>
<mode> mins ¶ </code>
<mode> </code>
<mode> The uniform mins takes as its argument (source) a scalar, list, dictionary or table and returns the cumulative minimum of the source items. </code>
<mode> </code>
<mode> mins 42 </code>
<mode> 42 </code>
<mode> </code>
<mode> mins 10 4 5 1 2 </code>
<mode> 10 4 4 1 1 </code>
<mode> </code>
<mode> mins "Beeblebrox" </code>
<mode> BBBBBBBBBB </code>
<mode> </code>
<mode> mins `a`b`c`d!40 10 30 20 </code>
<mode> a| 40 </code>
<mode> b| 10 </code>
<mode> c| 10 </code>
<mode> d| 10 </code>
<mode> </code>
<mode> t[]c1:1.1 2.2 3.3 4.4; c2:5 4 3 2) </code>
<mode> t </code>
<mode> c1 c2 </code>
<mode> ------ </code>
<mode> 1.1 5 </code>
<mode> 2.2 4 </code>
<mode> 3.3 3 </code>
<mode> 4.4 2 </code>
<mode> </code>
<mode> mins t </code>
<mode> c1 c2 </code>
<mode> ------ </code>
<mode> 1.1 5 </code>
<mode> 1.1 4 </code>
<mode> 1.1 3 </code>
<mode> 1.1 2 </code>
<mode> </code>
<mode> mmax ¶ </code>
<mode> </code>
<mode> The uniform dyadic mmax takes as its first argument an int (length) and as its second argument (source) a numeric list. It returns the moving maximum of source, obtained by applying max over length consecutive items. For positions less than length-1, max is applied only through that position. </code>
<mode> </code>
<mode> In the following example, the first item in the result is the max of itself only; the second result item is the max of the first two source items; all other items reflect the max of the item at the position along with its two predecessors. </code>
<mode> </code>
<mode> 3 mmax 20 10 30 50 40 </code>
<mode> 20 20 30 50 50 </code>
<mode> </code>
<mode> For length less than or equal to 0 the result is source. </code>
<mode> mmin ¶ </code>
<mode> </code>
<mode> The uniform dyadic mmin takes as its first argument an int (length) and as its second argument (source) a numeric list. It returns the moving minimum of source, obtained by applying min over length consecutive items. For positions less than length-1, min is applied only through that position. </code>
<mode> </code>
<mode> In the following example, the first item in the result is the min of itself only; the second result item is the min of the first two source items; all other items reflect the min of the item at the position along with its two predecessors. </code>
<mode> </code>
<mode> 3 mmin 20 10 30 50 40 </code>
<mode> 20 10 10 10 30 </code>
<mode> </code>
<mode> For length less than or equal to 0 the result is source. </code>
<mode> msum ¶ </code>
<mode> </code>
<mode> The uniform dyadic msum takes as its first argument an int (length) and as its second argument (source) a numeric list. It returns the moving sum of source, obtained by applying sum over length consecutive items. For positions less than length-1, sum is applied only through that position. </code>
<mode> </code>
<mode> In the following example, the first item in the result is the sum of itself only; the second result item is the sum of the first two source items; all other items reflect the sum of the item at the position along with its two predecessors. </code>
<mode> </code>
<mode> 3 msum 10 20 30 40 50 </code>
<mode> 10 30 60 90 120 </code>
<mode> </code>
<mode> For length less than or equal to 0 the result is all zeros. </code>
<mode> next ¶ </code>
<mode> </code>
<mode> The uniform next takes as its argument (source) a scalar, list or table of numeric type and returns the source shifted one position to the left with no wrapping. For lists and dictionaries, the last item of the result is a null matching the type of source. For tables, the last record of the result is a row of nulls. </code>
<mode> </code>
<mode> next 1 2 3 4 5 </code>
<mode> 2 3 4 5 0N </code>
<mode> </code>
<mode> t[]c1:1.1 2.2 3.3 4.4; c2:5 4 3 2) </code>
<mode> t </code>
<mode> c1 c2 </code>
<mode> ------ </code>
<mode> 1.1 5 </code>
<mode> 2.2 4 </code>
<mode> 3.3 3 </code>
<mode> 4.4 2 </code>
<mode> </code>
<mode> next t </code>
<mode> c1 c2 </code>
<mode> ------ </code>
<mode> 2.2 4 </code>
<mode> 3.3 3 </code>
<mode> 4.4 2 </code>
<mode> </code>
<mode> prds ¶ </code>
<mode> </code>
<mode> The uniform sums takes as its argument (source) a scalar, list, dictionary or table of numeric type and returns the cumulative product of the source items. </code>
<mode> </code>
<mode> prds 42 </code>
<mode> 42 </code>
<mode> </code>
<mode> prds 1 2 3 4 5 </code>
<mode> 1 2 6 24 120 </code>
<mode> </code>
<mode> prds `a`b`c!10 20 40 </code>
<mode> a| 10 </code>
<mode> b| 200 </code>
<mode> c| 8000 </code>
<mode> </code>
<mode> t[]c1:1.1 2.2 3.3 4.4; c2:5 4 3 2) </code>
<mode> t </code>
<mode> c1 c2 </code>
<mode> ------ </code>
<mode> 1.1 5 </code>
<mode> 2.2 4 </code>
<mode> 3.3 3 </code>
<mode> 4.4 2 </code>
<mode> </code>
<mode> prds t </code>
<mode> c1 c2 </code>
<mode> ----------- </code>
<mode> 1.1 5 </code>
<mode> 2.42 20 </code>
<mode> 7.986 60 </code>
<mode> 35.1384 120 </code>
<mode> </code>
<mode> prev ¶ </code>
<mode> </code>
<mode> The uniform prev takes as its argument (source) a scalar, list, dictionary or table. It returns the source shifted one position forward with initial null filling. </code>
<mode> </code>
<mode> prev 42 </code>
<mode> 42 </code>
<mode> </code>
<mode> prev 1 2 3 4 5 </code>
<mode> 0N 1 2 3 4 </code>
<mode> </code>
<mode> prev `a`b`c!10 20 40 </code>
<mode> a| </code>
<mode> b| 10 </code>
<mode> c| 20 </code>
<mode> </code>
<mode> t[]c1:`a`b`c;c2:10 20 40) </code>
<mode> t </code>
<mode> c1 c2 </code>
<mode> ----- </code>
<mode> a 10 </code>
<mode> b 20 </code>
<mode> c 40 </code>
<mode> </code>
<mode> prev t </code>
<mode> c1 c2 </code>
<mode> ----- </code>
<mode> a 10 </code>
<mode> b 20 </code>
<mode> </code>
<mode> rank ¶ </code>
<mode> </code>
<mode> The uniform rank takes as its argument (source) a list, dictionary or table whose values are sortable. It returns a list of int containing the order of each item in the source under an ascending sort. For dictionaries, the operation is against the range. </code>
<mode> </code>
<mode> rank 5 2 3 1 4 </code>
<mode> 4 1 2 0 3 </code>
<mode> </code>
<mode> rank `a`b`c`e`f! 5 2 3 1 4 </code>
<mode> 4 1 2 0 3 </code>
<mode> </code>
<mode> For tables and keyed tables, the result is a list with the rank of the records under ascending sort of the first column or the key column. </code>
<mode> </code>
<mode> ttt[] c1:2.2 1.1 3.3 5.5 4.4; c2:1 2 3 4 5) </code>
<mode> ttt </code>
<mode> c1 c2 </code>
<mode> ------ </code>
<mode> 2.2 1 </code>
<mode> 1.1 2 </code>
<mode> 3.3 3 </code>
<mode> 5.5 4 </code>
<mode> 4.4 5 </code>
<mode> </code>
<mode> rank ttt </code>
<mode> 1 0 2 4 3 </code>
<mode> </code>
<mode> kt:(k:103 102 101 105 104 d:1 2 3 4 5) </code>
<mode> kt </code>
<mode> k | d </code>
<mode> ---| - </code>
<mode> 103| 1 </code>
<mode> 102| 2 </code>
<mode> 101| 3 </code>
<mode> 105| 4 </code>
<mode> 104| 5 </code>
<mode> </code>
<mode> rank kt </code>
<mode> 2 1 0 4 3 </code>
<mode> </code>
<mode> ratios ¶ </code>
<mode> </code>
<mode> The uniform ratios takes as its argument (source) a scalar, list, dictionary or table of numeric type and returns the float ratio of each item to its predecessor. </code>
<mode> </code>
<mode> ratios 42 </code>
<mode> 42 </code>
<mode> </code>
<mode> ratios 1 2 3 4 5 </code>
<mode> 1 2 1.5 1.333333 1.25 </code>
<mode> </code>
<mode> ratios 96.25 93.25 58.25 73.25 89.50 84.00 84.25 </code>
<mode> 96.25 0.9688312 0.6246649 1.257511 1.221843 0.9385475 1.002976 </code>
<mode> </code>
<mode> deltas `a`b`c!10 20 40 </code>
<mode> a| 10 </code>
<mode> b| 10 </code>
<mode> c| 20 </code>
<mode> </code>
<mode> t[]c1:1.1 2.2 3.3 4.4; c2:5 4 3 2) </code>
<mode> t </code>
<mode> c1 c2 </code>
<mode> ------ </code>
<mode> 1.1 5 </code>
<mode> 2.2 4 </code>
<mode> 3.3 3 </code>
<mode> 4.4 2 </code>
<mode> </code>
<mode> ratios t </code>
<mode> c1 c2 </code>
<mode> ------------------ </code>
<mode> 1.1 5 </code>
<mode> 2 0.8 </code>
<mode> 1.5 0.75 </code>
<mode> 1.333333 0.6666667 </code>
<mode> </code>
<mode> Important: As the second example shows, the result of ratios contains the initial item of source in its initial position. This may be inconsistent with the behavior of similar functions in other languages or libraries that return 1 in the initial position. The alternate behavior can be achieved with the expression, </code>
<mode> </code>
<mode> 1,ratios 1_x </code>
<mode> </code>
<mode> In our example above, </code>
<mode> </code>
<mode> 1,ratios 1_x:96.25 93.25 58.25 73.25 89.50 84.00 84.25 </code>
<mode> 1 </code>
<mode> 93.25 </code>
<mode> 0.6246649 </code>
<mode> 1.257511 </code>
<mode> 1.221843 </code>
<mode> 0.9385475 </code>
<mode> 1.002976 </code>
<mode> </code>
<mode> rotate ¶ </code>
<mode> </code>
<mode> The uniform dyadic rotate takes as its first argument an int (length) and as its second argument (source) a numeric list or table. It returns the source shifted length positions to the left with wrapping if length is positive, or length positions to the right with wrapping if length is negative. For length 0, it returns the source. </code>
<mode> </code>
<mode> 2 rotate 1 2 3 4 5 </code>
<mode> 3 4 5 1 2 </code>
<mode> </code>
<mode> -2 rotate 1 2 3 4 5 </code>
<mode> 4 5 1 2 3 </code>
<mode> </code>
<mode> t[]c1:1.1 2.2 3.3 4.4; c2:5 4 3 2) </code>
<mode> t </code>
<mode> c1 c2 </code>
<mode> --------- </code>
<mode> 1.1 5 </code>
<mode> 2.2 4 </code>
<mode> 3.3 3 </code>
<mode> 4.4 2 </code>
<mode> </code>
<mode> 2 rotate t </code>
<mode> c1 c2 </code>
<mode> ------ </code>
<mode> 1.1 5 </code>
<mode> 2.2 4 </code>
<mode> 3.3 3 </code>
<mode> 4.4 2 </code>
<mode> </code>
<mode> sums ¶ </code>
<mode> </code>
<mode> The uniform sums takes as its argument (source) a scalar, list, dictionary or table of numeric type and returns the cumulative sum of the source items. </code>
<mode> </code>
<mode> sums 42 </code>
<mode> 42 </code>
<mode> </code>
<mode> sums 1 2 3 4 5 </code>
<mode> 1 3 6 10 15 </code>
<mode> </code>
<mode> sums `a`b`c!10 20 40 </code>
<mode> a| 10 </code>
<mode> b| 30 </code>
<mode> c| 70 </code>
<mode> </code>
<mode> t[]c1:1.1 2.2 3.3 4.4; c2:5 4 3 2) </code>
<mode> t </code>
<mode> c1 c2 </code>
<mode> ------ </code>
<mode> 1.1 5 </code>
<mode> 2.2 4 </code>
<mode> 3.3 3 </code>
<mode> 4.4 2 </code>
<mode> </code>
<mode> sums t </code>
<mode> c1 c2 </code>
<mode> ------ </code>
<mode> 1.1 5 </code>
<mode> 3.3 9 </code>
<mode> 6.6 12 </code>
<mode> 11 14 </code>
<mode> </code>
<mode> xbar ¶ </code>
<mode> </code>
<mode> The uniform dyadic xbar takes as its first argument a non-negative numeric atom (width) and a second argument (source) that is a numeric list, dictionary or table. It returns an entity that conforms to source, in which each item of source is mapped to the largest multiple of the width that is less than or equal to that item. The type of the result is that of the width parameter. </code>
<mode> </code>
<mode> 3 xbar 2 7 12 17 22 </code>
<mode> 0 6 12 15 21 </code>
<mode> </code>
<mode> 5.5 xbar 59.25 53.75 81.00 96.25 93.25 58.25 73.25 89.50 84.00 84.25 </code>
<mode> 55 49.5 77 93.5 88 55 71.5 88 82.5 82.5 </code>
<mode> </code>
<mode> 15 xbar `a`b`c!10 20 40 </code>
<mode> a| 0 </code>
<mode> b| 15 </code>
<mode> c| 30 </code>
<mode> </code>
<mode> t[]c1:1.1 2.2 3.3 4.4; c2:5 4 3 2) </code>
<mode> t </code>
<mode> c1 c2 </code>
<mode> ------ </code>
<mode> 1.1 5 </code>
<mode> 2.2 4 </code>
<mode> 3.3 3 </code>
<mode> 4.4 2 </code>
<mode> </code>
<mode> 2 xbar t </code>
<mode> c1 c2 </code>
<mode> ----- </code>
<mode> 0 4 </code>
<mode> 2 4 </code>
<mode> 2 2 </code>
<mode> 4 2 </code>
<mode> </code>
<mode> Since xbar is atomic in its second argument it can be applied to a nested list. </code>
<mode> </code>
<mode> 5 xbar ((11;21 31);201 301) </code>
<mode> 10 20 30 </code>
<mode> 200 300 </code>
<mode> </code>
<mode> xprev ¶ </code>
<mode> </code>
<mode> The dyadic xprev takes an int as its first argument (shift) and is uniform in its second argument (source), which can be a list or a table. It returns a result that conforms to source. When shift is 0 or positive, each entity in source is shifted shift positions forward in the result, with the initial shift entries null filled. </code>
<mode> </code>
<mode> 2 xprev 10 20 30 40 </code>
<mode> 0N 0N 10 20 </code>
<mode> </code>
<mode> t[]c1:`a`b`c`d;c2:10 20 30 40) </code>
<mode> t </code>
<mode> c1 c2 </code>
<mode> ----- </code>
<mode> a 10 </code>
<mode> b 20 </code>
<mode> c 30 </code>
<mode> d 40 </code>
<mode> </code>
<mode> 2 xprev t </code>
<mode> c1 c2 </code>
<mode> ----- </code>
<mode> </code>
<mode> </code>
<mode> a 10 </code>
<mode> b 20 </code>
<mode> </code>
<mode> When shift is negative, the result is a copy of source with the initial shift entries null filled. </code>
<mode> </code>
<mode> -2 xprev 10 20 30 40 </code>
<mode> 30 40 0N 0N </code>
<mode> </code>
<mode> xrank ¶ </code>
<mode> </code>
<mode> The binary xrank is uniform in its right operand (source), which is a list, dictionary, table or keyed table whose values are sortable. The left operand is a positive int (quantile). It returns a list of int containing the quantile of the source distribution to which each item of source belongs. The analysis is applied to the range of a dictionary and the first column of a table. </code>
<mode> </code>
<mode> For example, by choosing quantile to be 4, xrank determines into which quartile each item of source falls. </code>
<mode> </code>
<mode> 4 xrank 30 10 40 20 90 </code>
<mode> 1 0 2 0 3 </code>
<mode> </code>
<mode> 4 xrank `a`b`c`d`e!30 10 40 20 90 </code>
<mode> 1 0 2 0 3 </code>
<mode> </code>
<mode> t[]c1:30 10 40 20 90;c1:`a`b`c`d`e) </code>
<mode> t </code>
<mode> c1 c11 </code>
<mode> ------ </code>
<mode> 30 a </code>
<mode> 10 b </code>
<mode> 40 c </code>
<mode> 20 d </code>
<mode> 90 e </code>
<mode> </code>
<mode> 4 xrank t </code>
<mode> 1 0 2 0 3 </code>
<mode> </code>
<mode> Choosing quantile to be 100 gives percentile ranking. </code>
<mode> Miscellaneous Functions ¶ </code>
<mode> </code>
<mode> We collect here the built-in functions that don't fit into any of the previously defined categories. </code>
<mode> Conditional Append ¶ </code>
<mode> </code>
<mode> The left operand of conditional append ( ? ) is a symbol representing the name of a list of symbols (target) and the right operand is a symbol, the right operand is appended to target if and only if it is not in target. There is no effect when the right operand is already in target. The result is the enumeration of the right operand in target. </code>
<mode> </code>
<mode> v:`a`b`c </code>
<mode> `v?`z </code>
<mode> `v$`z </code>
<mode> </code>
<mode> v </code>
<mode> `a`b`c`z </code>
<mode> </code>
<mode> `v?`b </code>
<mode> `v$`b </code>
<mode> </code>
<mode> v </code>
<mode> `a`b`c`z </code>
<mode> </code>
<mode> Note: While conditional append is normally used with a target list of unique items, this is not a requirement. </code>
<mode> asc ¶ </code>
<mode> </code>
<mode> The monadic function asc operates on a list or a dictionary (source). The result of asc on a list is a list comprising the items of source sorted in increasing order with the s# attribute applied. The result of asc on a dictionary is an equivalent mapping with the range items sorted in increasing order and with the s# attribute applied. </code>
<mode> </code>
<mode> asc 3 7 2 8 1 9 </code>
<mode> `s#1 2 3 7 8 9 </code>
<mode> </code>
<mode> asc `b`c`a!3 2 1 </code>
<mode> a| 1 </code>
<mode> c| 2 </code>
<mode> b| 3 </code>
<mode> </code>
<mode> bin ¶ </code>
<mode> </code>
<mode> The dyadic bin takes a simple list of items (target) in strictly increasing order as its first argument and is atomic in its second argument (token). Loosely speaking, the result of bin is the position at which token would fall in target. </code>
<mode> </code>
<mode> More precisely, the result is -1 if token is less than the first item in target. Otherwise, the result is the position of the right-most item of target that is less than or equal to token; this reduces to the found position if the token is in target. If token is greater than the last item in target, the result is the count of target. </code>
<mode> </code>
<mode> Note: For large sorted lists, the binary search performed by bin is generally more efficient than the linear search algorithm used by in. </code>
<mode> </code>
<mode> Some examples with simple lists, </code>
<mode> </code>
<mode> 1 2 3 4 bin 3 </code>
<mode> 2 </code>
<mode> </code>
<mode> "xyz" bin "a" </code>
<mode> -1 </code>
<mode> </code>
<mode> 1.0 2.0 3.0 bin 0.0 2.0 2.5 3.0 </code>
<mode> -1 1 1 2 </code>
<mode> </code>
<mode> Observe that the type of token must strictly match that of target. </code>
<mode> </code>
<mode> 1 2 3 bin 1.5 </code>
<mode> `type </code>
<mode> </code>
<mode> We can apply bin to a dictionary to perform reverse lookup, provided the dictionary domain is in increasing order. When source is a dictionary, bin takes a token whose type matches that of the dictionary range. The result is null if token is less than every item of the range. Otherwise, the result is the right-most domain element whose corresponding range element is less than or equal to token. Loosely put, when token is not found, the result is the domain item after which you would make an insertion to place it into the dictionary in proper order. </code>
<mode> </code>
<mode> Note that the result reduces to the corresponding domain item if token is found in target, and is the last domain item if token is greater than every range item. </code>
<mode> </code>
<mode> d:10 20 30!`first`second`third </code>
<mode> d bin `second </code>
<mode> 20 </code>
<mode> </code>
<mode> d bin `missing </code>
<mode> 10 </code>
<mode> </code>
<mode> d bin `zero </code>
<mode> 30 </code>
<mode> </code>
<mode> d bin `aaa </code>
<mode> 0N </code>
<mode> </code>
<mode> Because a table is a list of records, we expect bin to return the row number of a record. </code>
<mode> </code>
<mode> t[] a:1 2 3; b:`a`b`c) </code>
<mode> t </code>
<mode> a b </code>
<mode> — </code>
<mode> 1:00 AM </code>
<mode> 2 b </code>
<mode> 3 c </code>
<mode> </code>
<mode> t bin `a`b!(2;`b) </code>
<mode> 1 </code>
<mode> </code>
<mode> As always, the record can be abbreviated to the list of row values. </code>
<mode> </code>
<mode> t bin (1;`a) </code>
<mode> 0 </code>
<mode> t bin (0;`z) </code>
<mode> 0N </code>
<mode> </code>
<mode> Observe that a record that is not found results in a null result. </code>
<mode> </code>
<mode> Finally, since a keyed table is a dictionary, bin will perform a reverse lookup on a record of the value table, which can be abbreviated to a list of row values. </code>
<mode> </code>
<mode> kt:(k:1 2 3 c:100 101 102) </code>
<mode> kt </code>
<mode> k| c </code>
<mode> -| — </code>
<mode> 1| 100 </code>
<mode> 2| 101 </code>
<mode> 3| 102 </code>
<mode> </code>
<mode> kt bin (enlist `c)!enlist 101 </code>
<mode> k| 2 </code>
<mode> </code>
<mode> kt bin 101 </code>
<mode> k| 2 </code>
<mode> </code>
<mode> Warning: While the items of the first argument of bin should be in strictly increasing order for the result to meaningful, this condition is not enforced. The results of bin when the first argument is not strictly increasing are predictable but not particularly useful. </code>
<mode> count ¶ </code>
<mode> </code>
<mode> The monadic count returns a non-negative int representing the number of entities in its argument. Its domain comprises scalars, lists, dictionaries, tables and keyed tables. </code>
<mode> </code>
<mode> count 3 </code>
<mode> 1 </code>
<mode> </code>
<mode> count 10 20 30 </code>
<mode> 3 </code>
<mode> </code>
<mode> count `a`b`c`d!10 20 30 40 </code>
<mode> 4 </code>
<mode> </code>
<mode> count ([] a:10 20 30; b:1.1 2.2 3.3) </code>
<mode> 3 </code>
<mode> </code>
<mode> count (k:10 20 c:`one`two) </code>
<mode> 2 </code>
<mode> </code>
<mode> Note: You cannot use count to determine whether an entity is a scalar or list since scalars and singletons both have count 1. </code>
<mode> </code>
<mode> count 3 </code>
<mode> 1 </code>
<mode> </code>
<mode> count enlist 3 </code>
<mode> 1 </code>
<mode> </code>
<mode> This test is accomplished instead by testing the sign of the type of the entity. </code>
<mode> </code>
<mode> 0>type 3 </code>
<mode> 1b </code>
<mode> 0>type enlist 3 </code>
<mode> 0b </code>
<mode> </code>
<mode> Aside: Do you know why they call it count? Because it loves to count!! Nyah, ha, ha, ha, ha. Vun, and two, and tree, and.... </code>
<mode> cut ¶ </code>
<mode> </code>
<mode> The binary operator cut is related to the _ operator. It is the same as _ when the right operand is a dictionary and the left operand is a list of items from the dictionary domain. </code>
<mode> </code>
<mode> d:1 2 3!`a`b`c </code>
<mode> (enlist 2) cut d </code>
<mode> 1| a </code>
<mode> 3| c </code>
<mode> </code>
<mode> However, for a list right operand source and an int left operand size, cut returns a new list created by collecting the items of source into sublists of count size. </code>
<mode> </code>
<mode> 5 cut til 13 </code>
<mode> 0 1 2 3 4 </code>
<mode> 5 6 7 8 9 </code>
<mode> 10 11 12 </code>
<mode> </code>
<mode> Advanced: The cut function is equivalent to, </code>
<mode> </code>
<mode> {$0>type x;x*til neg floor neg(count y)mod x;x_y} </code>
<mode> </code>
<mode> delete (_) ¶ </code>
<mode> </code>
<mode> The symbol _ is overloaded to have several meanings depending on the signature of its operands. See also drop. </code>
<mode> </code>
<mode> Note: When _ is used as an operator, whitespace is required to the left if the left operand is a name. This is because _ is a valid non-initial name character. Whitespace is permitted but not required to the right. </code>
<mode> </code>
<mode> When the first argument of dyadic ( _ ) is a list of non-negative int and the second argument (source) is a list, it produces a new list obtained by breaking source into sublists at the positions indicated in the first argument. An example will make this clear. </code>
<mode> </code>
<mode> 0 3_100 200 300 400 500 </code>
<mode> 100 200 300 </code>
<mode> 400 500 </code>
<mode> </code>
<mode> Each sublist includes the items from the beginning cut position up to, but not including, the next cut position. The final cut includes the items to the end of source. Observe that if the left argument does not begin with 0, the initial items of source will not be included in the result. </code>
<mode> </code>
<mode> 2 4_2006.01 2006.02 2006.03 2006.04 2006.05 2006.06 </code>
<mode> 2006.03 2006.04 </code>
<mode> 2006.05 2006.06 </code>
<mode> </code>
<mode> When the right operand of _ is a dictionary (source) and the left operand is a list of key values whose type matches source, the result is a dictionary obtained by removing the specified key-value pairs from the target. </code>
<mode> </code>
<mode> For example, </code>
<mode> </code>
<mode> d:1 2 3!`a`b`c </code>
<mode> (enlist 42) _ d </code>
<mode> 1| a </code>
<mode> 2| b </code>
<mode> 3| c </code>
<mode> </code>
<mode> (enlist 2) _ d </code>
<mode> 1| a </code>
<mode> 3| c </code>
<mode> </code>
<mode> 1 3 _ d </code>
<mode> 2| b </code>
<mode> </code>
<mode> (enlist 32) _ d </code>
<mode> 1| a </code>
<mode> 2| b </code>
<mode> 3| c </code>
<mode> </code>
<mode> 1 2 3 _ d </code>
<mode> _ </code>
<mode> </code>
<mode> Note: The operand must be a list, so a single key value must be enlisted. </code>
<mode> </code>
<mode> When the first argument of dyadic delete ( _ ) is a list or a dictionary (source) and the second argument is a position in the list or an item in the domain of the dictionary, the result is a new entity obtained by deleting the specified item from the source. </code>
<mode> </code>
<mode> L: 101 102 103 104 105 </code>
<mode> L _2 </code>
<mode> 101 102 104 105 </code>
<mode> </code>
<mode> d:`a`b`c`d!101 102 103 104 </code>
<mode> d _ `b </code>
<mode> a| 101 </code>
<mode> c| 103 </code>
<mode> d| 104 </code>
<mode> </code>
<mode> Since a table is a list, delete can be applied by row number. </code>
<mode> </code>
<mode> t[]c1:1 2 3;c2:101 102 103;c3:`x`y`z) </code>
<mode> t </code>
<mode> c1 c2 c3 </code>
<mode> --------- </code>
<mode> 1 101 x </code>
<mode> 2 102 y </code>
<mode> 3 103 z </code>
<mode> </code>
<mode> t _ 1 </code>
<mode> c1 c2 c3 </code>
<mode> --------- </code>
<mode> 1 101 x </code>
<mode> 3 103 z </code>
<mode> </code>
<mode> Since a keyed table is a dictionary, delete can be applied by key value. </code>
<mode> </code>
<mode> kt:(k:101 102 103c:`one`two`three) </code>
<mode> kt </code>
<mode> k | c </code>
<mode> ---| ----- </code>
<mode> 101| one </code>
<mode> 102| two </code>
<mode> 103| three </code>
<mode> </code>
<mode> kt _ 102 </code>
<mode> k | c </code>
<mode> ---| ----- </code>
<mode> 101| one </code>
<mode> 103| three </code>
<mode> </code>
<mode> desc ¶ </code>
<mode> </code>
<mode> The monadic function desc operates on a list or a dictionary (source). The result of desc on a list is a list comprising the items of source sorted in decreasing order with the s# attribute applied. The result of desc on a dictionary is an equivalent mapping with the range items sorted in decreasing order and with the s# attribute applied. </code>
<mode> </code>
<mode> desc 3 7 2 8 1 9 </code>
<mode> 9 8 7 3 2 1 </code>
<mode> </code>
<mode> desc `b`c`a!3 2 1 </code>
<mode> b| 3 </code>
<mode> c| 2 </code>
<mode> a| 1 </code>
<mode> </code>
<mode> distinct ¶ </code>
<mode> </code>
<mode> The monadic function distinct returns the distinct entities in its argument. For a list, it returns the distinct items in the list, in order of first occurrence. </code>
<mode> </code>
<mode> distinct 1 2 3 2 3 4 6 4 3 5 6 </code>
<mode> 1 2 3 4 6 5 </code>
<mode> </code>
<mode> For a table, distinct returns a table comprising the distinct records of the argument, in the order of first occurrence. </code>
<mode> </code>
<mode> tdup[]a:1 2 3 2 1; b:`washington`adams`jefferson`adams`wasington) </code>
<mode> tdup </code>
<mode> a b </code>
<mode> ------------ </code>
<mode> 1 washington </code>
<mode> 2 adams </code>
<mode> 3 jefferson </code>
<mode> 2 adams </code>
<mode> 1 wasington </code>
<mode> </code>
<mode> distinct tdup </code>
<mode> a b </code>
<mode> ------------ </code>
<mode> 1 washington </code>
<mode> 2 adams </code>
<mode> 3 jefferson </code>
<mode> 1 wasington </code>
<mode> </code>
<mode> Observe that all fields of the records must be identical for the records to be considered identical. Otherwise put, if any field differs, the records are distinct. </code>
<mode> </code>
<mode> When applied to an int n, distinct produces a random int between 0 (inclusive) and n (exclusive). </code>
<mode> </code>
<mode> distinct 42 </code>
<mode> 37 </code>
<mode> distinct 42 </code>
<mode> 39 </code>
<mode> </code>
<mode> drop (_) ¶ </code>
<mode> </code>
<mode> The symbol _ is overloaded to have several meanings depending on the signature of its operands. See also delete. </code>
<mode> </code>
<mode> Note: When _ is used as an operator, whitespace is required to the left if the left operand is a name. This is because _ is a valid non-initial name character. Whitespace is permitted but not required to the right. </code>
<mode> </code>
<mode> When the first argument of the dyadic _ is an int and the second argument (source) is a list, the result is a new list created via removal from source. A positive int in the first argument indicates that the removal occurs from the beginning of the source, whereas a negative int in the first argument indicates that the removal occurs from the end of the source. </code>
<mode> </code>
<mode> The source can be a list, a dictionary, a table or a keyed table. </code>
<mode> </code>
<mode> 2_10 20 30 40 </code>
<mode> 30 40 </code>
<mode> </code>
<mode> -3_`one`two`three`four`five </code>
<mode> `one`two </code>
<mode> </code>
<mode> 2_`a`b`c`d!10 20 30 40 </code>
<mode> c| 30 </code>
<mode> d| 40 </code>
<mode> </code>
<mode> -1_([] a:10 20 30 40; b:1.1 2.2 3.3 4.4) </code>
<mode> a b </code>
<mode> ------ </code>
<mode> 10 1.1 </code>
<mode> 20 2.2 </code>
<mode> 30 3.3 </code>
<mode> </code>
<mode> 2_(k:10 20 30 c:`one`two`three) </code>
<mode> k | c </code>
<mode> --| ----- </code>
<mode> 30| three </code>
<mode> </code>
<mode> The result of drop is of the same type and shape as source and is never a scalar. </code>
<mode> </code>
<mode> 1_42 67 </code>
<mode> ,67 </code>
<mode> </code>
<mode> Observe that for nested lists, the deletion occurs at the top-most level. </code>
<mode> </code>
<mode> 1_(100 101 102;103 104 105) </code>
<mode> 103 104 105 </code>
<mode> </code>
<mode> In the degenerate case, the result is an empty entity derived from source. </code>
<mode> </code>
<mode> 4_10 20 30 40 </code>
<mode> `int$() </code>
<mode> </code>
<mode> 4_`a`b`c`d!10 20 30 40 </code>
<mode> 4_([] a:10 20 30 40; b:1.1 2.2 3.3 4.4) </code>
<mode> a b </code>
<mode> – </code>
<mode> </code>
<mode> 3_(k:10 20 30 c:`one`two`three) </code>
<mode> k| c </code>
<mode> -| - </code>
<mode> </code>
<mode> eval ¶ </code>
<mode> </code>
<mode> The monadic eval evaluates a list that represents a valid q parse tree, which can be produced by parse or by hand (if you know what you're doing). A discussion of parse trees is beyond the scope of this manual. </code>
<mode> </code>
<mode> show pt:parse "a:6*7" </code>
<mode> : </code>
<mode> `a </code>
<mode> (*;6;7) </code>
<mode> </code>
<mode> eval pt </code>
<mode> 42 </code>
<mode> </code>
<mode> except ¶ </code>
<mode> </code>
<mode> The dyadic except takes a simple list or a dictionary whose range is a simple list as its first argument (target) and returns a list containing the items of target excluding those that are in its second argument, which can be a scalar or a list. The returned items are in the order of their first occurrence in target. </code>
<mode> </code>
<mode> 1 2 3 4 3 2 except 2 </code>
<mode> 1 3 4 3 </code>
<mode> </code>
<mode> 1 2 3 4 3 2 except 1 2 10 </code>
<mode> 3 4 3 </code>
<mode> </code>
<mode> "Now is the time_" except "_" </code>
<mode> Now is the time </code>
<mode> </code>
<mode> d:`a`c`d`e!1 2 1 2 </code>
<mode> d except 1 </code>
<mode> 2 2 </code>
<mode> </code>
<mode> The result of except is never a scalar. </code>
<mode> </code>
<mode> 1 2 except 1 </code>
<mode> ,2 </code>
<mode> </code>
<mode> 1 2 except 2 1 </code>
<mode> `int$() </code>
<mode> </code>
<mode> d except 1 2 </code>
<mode> `int$() </code>
<mode> </code>
<mode> exit ¶ </code>
<mode> </code>
<mode> The monadic exit takes an int as its argument and a and executes the system command
with the specified parameter. </code>
<mode> </code>
<mode> Warning: Exit does not prompt for a confirmation. </code>
<mode> fill (^) ¶ </code>
<mode> </code>
<mode> The dyadic fill ( ^ ) takes an atom as its first argument and a list or dictionary (target) as its second argument. For a list, it returns a list obtained by substituting the first argument for every occurrence of null in target. It operates on the range of a dictionary. </code>
<mode> </code>
<mode> 42^1 2 3 0N 5 0N </code>
<mode> 1 2 3 42 5 42 </code>
<mode> </code>
<mode> ";"^"Now is the time" </code>
<mode> Now;is;the;time </code>
<mode> </code>
<mode> `NULL^`First`Second``Fourth </code>
<mode> `First`Second`NULL`Fourth </code>
<mode> </code>
<mode> d:`a`b`c`d!100 0N 200 0N </code>
<mode> 42^d </code>
<mode> a| 100 </code>
<mode> b| 42 </code>
<mode> c| 200 </code>
<mode> d| 42 </code>
<mode> </code>
<mode> Observe that the action of fill is recursive - i.e., it is applied to sublists of the target. </code>
<mode> </code>
<mode> 42^(1;0N;(100;200 0N)) </code>
<mode> 42^ </code>
<mode> a| 100 </code>
<mode> b| 42 </code>
<mode> c| 200 </code>
<mode> d| 42 </code>
<mode> </code>
<mode> find ¶ </code>
<mode> </code>
<mode> When the first argument (target) of find ( ? ) is a simple list, find is atomic in the second argument (source) and returns the positions in target of the initial occurrence of each item of source. </code>
<mode> </code>
<mode> The simplest case is when source is a scalar. </code>
<mode> </code>
<mode> 100 99 98 87 96?98 </code>
<mode> 2 </code>
<mode> "Now is the time"?"t" </code>
<mode> 7 </code>
<mode> </code>
<mode> If source is not found in target, find returns the count of target - i.e., the position one past the last element. </code>
<mode> </code>
<mode> `one`two`three?`four </code>
<mode> 3 </code>
<mode> </code>
<mode> In this context, find is atomic in its second argument, so it is extended item-wise to a source list. </code>
<mode> </code>
<mode> "Now is the time"?"the" </code>
<mode> 7 8 9 </code>
<mode> </code>
<mode> Note that find always returns the position of the first occurrence of each atom. </code>
<mode> </code>
<mode> "Now is the time"?"time" </code>
<mode> 7 4 13 9 </code>
<mode> </code>
<mode> When the first argument (target) of find is a general list, find considers both elements to be general lists and attempts to locate the second argument (source) in the target, returning the position where it is found or the count of target if not found. </code>
<mode> </code>
<mode> (1 2;3 4)?3 4 </code>
<mode> 1 </code>
<mode> </code>
<mode> Observe that find only compares items at the top level of the two arguments and does not look for nested items, </code>
<mode> </code>
<mode> ((0;1 2);3 4;5 6)?1 2 </code>
<mode> 3 </code>
<mode> ((0;1 2);3 4;5 6)?(1;(2;3 4)) </code>
<mode> 3 </code>
<mode> </code>
<mode> When the first argument (target) of find is a dictionary, find represents reverse lookup and is atomic in the second argument (source). In other words, find returns the domain item mapping to source if source is in the range, or a null appropriate to the domain type otherwise. </code>
<mode> </code>
<mode> d:1 2 3!100 101 102 </code>
<mode> d </code>
<mode> 1| 100 </code>
<mode> 2| 101 </code>
<mode> 3| 102 </code>
<mode> </code>
<mode> d?101 </code>
<mode> 2 </code>
<mode> </code>
<mode> d?99 </code>
<mode> 0N </code>
<mode> </code>
<mode> d?102 100 </code>
<mode> 3 1 </code>
<mode> </code>
<mode> When the first argument (target) of find is a table and the second argument (source) is a record of the target, find returns the position of source if it is in target, or the count of target otherwise. </code>
<mode> </code>
<mode> t[] a:1 2 3; b:`a`b`c) </code>
<mode> t </code>
<mode> a b </code>
<mode> — </code>
<mode> 1:00 AM </code>
<mode> 2 b </code>
<mode> 3 c </code>
<mode> t?`a`b!(2;`b) </code>
<mode> 1 </code>
<mode> </code>
<mode> As usual with records, you can abbreviate the record to its row values. </code>
<mode> </code>
<mode> t?(3;`c) </code>
<mode> 2 </code>
<mode> </code>
<mode> When the first argument of find is a keyed table, since a keyed table is a dictionary, find performs a reverse lookup on a record from the value table. </code>
<mode> </code>
<mode> kt:(k:1 2 3 c:100 101 102) </code>
<mode> kt </code>
<mode> k| c </code>
<mode> -| — </code>
<mode> 1| 100 </code>
<mode> 2| 101 </code>
<mode> 3| 102 </code>
<mode> </code>
<mode> kt?`c!101 </code>
<mode> k| 2 </code>
<mode> </code>
<mode> Again, a record of the value table can be abbreviated to its row value(s). </code>
<mode> </code>
<mode> kt?102 </code>
<mode> k| 3 </code>
<mode> </code>
<mode> flip ¶ </code>
<mode> </code>
<mode> The monadic function flip takes a rectangular list, a column dictionary or a table as its argument (source). The result is the transpose of source. </code>
<mode> </code>
<mode> When source is a rectangular list, the items are rearranged, effectively reversing the first two indices in indexing at depth. For example, </code>
<mode> </code>
<mode> L1 2 3; (10 20; 100 200; 1000 2000)) </code>
<mode> L </code>
<mode> 1 2 3 </code>
<mode> 10 20 100 200 1000 2000 </code>
<mode> </code>
<mode> L1;0 </code>
<mode> 10 20 </code>
<mode> </code>
<mode> fL:flip L </code>
<mode> fL </code>
<mode> 1 10 20 </code>
<mode> 2 100 200 </code>
<mode> 3 1000 2000 </code>
<mode> </code>
<mode> fL0;1 </code>
<mode> 10 20 </code>
<mode> </code>
<mode> When source is a singleton list whose item is a simple list, flip creates a vertical list. </code>
<mode> </code>
<mode> flip enlist 101 103 </code>
<mode> 101 </code>
<mode> 103 </code>
<mode> </code>
<mode> This idiom is used to index multiple key values into keyed tables. </code>
<mode> </code>
<mode> kt:(k:101 102 103 c:`one`two`three) </code>
<mode> kt flip enlist 101 103 </code>
<mode> c </code>
<mode> ----- </code>
<mode> one </code>
<mode> three </code>
<mode> </code>
<mode> When source is a column dictionary, the result is a table with the given column names and values. Row and column access are effectively reversed, but no data is rearranged. </code>
<mode> </code>
<mode> d`a`b`c!1 2 3;1.1 2.2 3.3;("one";"two";"three")) </code>
<mode> d </code>
<mode> `a`b`c!1 2 3 </code>
<mode> 1.1 2.2 3.3 </code>
<mode> ("one";"two";"three") </code>
<mode> </code>
<mode> d`b;0 </code>
<mode> 1.1 </code>
<mode> </code>
<mode> t:flip d </code>
<mode> t </code>
<mode> a b c </code>
<mode> ----------- </code>
<mode> 1 1.1 one </code>
<mode> 2 2.2 two </code>
<mode> 3 3.3 three </code>
<mode> </code>
<mode> t0;`b </code>
<mode> 1.1 </code>
<mode> </code>
<mode> When source is a table, the result is the underlying column dictionary. Row and column access are effectively reversed, but no data is rearranged. </code>
<mode> </code>
<mode> t[]a:1 2 3;b:1.1 2.2 3.3;c"one";"two";"three")) </code>
<mode> t </code>
<mode> a b c </code>
<mode> ------------- </code>
<mode> 1 1.1 "one" </code>
<mode> 2 2.2 "two" </code>
<mode> 3 3.3 "three" </code>
<mode> </code>
<mode> t1;`c </code>
<mode> two </code>
<mode> </code>
<mode> d:flip t </code>
<mode> d </code>
<mode> a| 1 2 3 </code>
<mode> b| 1.1 2.2 3.3 </code>
<mode> c| "one" "two" "three" </code>
<mode> </code>
<mode> d`c;1 </code>
<mode> two </code>
<mode> </code>
<mode> getenv ¶ </code>
<mode> </code>
<mode> The monadic function getenv takes a symbol argument representing the name of an OS environment variable and returns the value (if any) of that environment variable. </code>
<mode> </code>
<mode> getenv `SHELL </code>
<mode> /bin/bash </code>
<mode> </code>
<mode> group ¶ </code>
<mode> </code>
<mode> The monadic function group operates on a list (source) and returns a dictionary in which each distinct item in source is mapped to a list of the indices of its occurrences in source. The items in the domain of the result are in the order of their first appearance in source. </code>
<mode> </code>
<mode> group "i miss mississippi" </code>
<mode> i| 0 3 8 11 14 17 </code>
<mode> | 1 6 </code>
<mode> m| 2 7 </code>
<mode> s| 4 5 9 10 12 13 </code>
<mode> p| 15 16 </code>
<mode> </code>
<mode> This can be used to extract specific information about the occurrences, such as, </code>
<mode> </code>
<mode> dm:group "i miss mississippi" </code>
<mode> count each dm </code>
<mode> i| 6 </code>
<mode> | 2 </code>
<mode> m| 2 </code>
<mode> s| 6 </code>
<mode> p| 2 </code>
<mode> first each dm </code>
<mode> i| 0 </code>
<mode> | 1 </code>
<mode> m| 2 </code>
<mode> s| 4 </code>
<mode> p| 15 </code>
<mode> </code>
<mode> iasc ¶ </code>
<mode> </code>
<mode> The monadic function iasc operates on a list or a dictionary (source). Considering source as a mapping, the result of iasc is a list comprising the domain items arranged in increasing order of their associated range items. Otherwise put, retrieving the items of source in the order specified by iasc sorts source in ascending order. </code>
<mode> </code>
<mode> L:3 7 2 8 1 9 </code>
<mode> iasc L </code>
<mode> 4 2 0 1 3 5 </code>
<mode> </code>
<mode> Liasc L </code>
<mode> 1 2 3 7 8 9 </code>
<mode> </code>
<mode> d:`b`c`a!3 2 1 </code>
<mode> iasc d </code>
<mode> `a`c`b </code>
<mode> </code>
<mode> diasc d </code>
<mode> 1 2 3 </code>
<mode> </code>
<mode> identity ¶ </code>
<mode> </code>
<mode> The monadic function denoted by double colon ( :: ), is the identity function, meaning that the return value is the same as the argument. </code>
<mode> </code>
<mode> ::42 </code>
<mode> 42 </code>
<mode> </code>
<mode> ::`zaphod </code>
<mode> `zaphod </code>
<mode> </code>
<mode> ::"Life the Universe and Everything" </code>
<mode> Life the Universe and Everything </code>
<mode> </code>
<mode> Note: The identity function cannot be used with juxtaposition or @. Its argument must be enclosed in brackets. </code>
<mode> </code>
<mode> :: 42 </code>
<mode> ' </code>
<mode> </code>
<mode> idesc ¶ </code>
<mode> </code>
<mode> The monadic function idesc operates on a list or a dictionary (source). Considering source as a mapping, the result of idesc is a list comprising the domain items arranged in decreasing order of their associated range items. Otherwise put, retrieving the items of source in the order specified by idesc sorts source in descending order. </code>
<mode> </code>
<mode> L:3 7 2 8 1 9 </code>
<mode> idesc L </code>
<mode> 5 3 1 0 2 4 </code>
<mode> </code>
<mode> Lidesc L </code>
<mode> 9 8 7 3 2 1 </code>
<mode> </code>
<mode> d:`b`c`a!3 2 1 </code>
<mode> idesc d </code>
<mode> `b`c`a </code>
<mode> didesc d </code>
<mode> 3 2 1 </code>
<mode> </code>
<mode> in ¶ </code>
<mode> </code>
<mode> The dyadic function in is atomic in its first argument (source) and takes a second argument (target) that is an atom or list. It returns a boolean result that indicates whether source appears in target. The comparison is strict with regard to type. </code>
<mode> </code>
<mode> 3 in 8 </code>
<mode> 0b </code>
<mode> </code>
<mode> 42 in 0 6 7 42 98 </code>
<mode> 1b </code>
<mode> </code>
<mode> "cat" in "abcdefg" </code>
<mode> 110b </code>
<mode> </code>
<mode> `zap in `zaphod`beeblebrox </code>
<mode> 0b </code>
<mode> </code>
<mode> 2 in 0 2 4j </code>
<mode> 'type </code>
<mode> </code>
<mode> inter ¶ </code>
<mode> </code>
<mode> The dyadic inter can be applied to lists, dictionaries and tables. It returns an entity of the same type as its arguments, containing those elements of the first argument that appear in the second argument. </code>
<mode> </code>
<mode> 1 1 2 3 inter 1 2 3 4 </code>
<mode> 1 1 2 3 </code>
<mode> </code>
<mode> "ab cd " inter " bc f" </code>
<mode> b c </code>
<mode> </code>
<mode> Note: Lists are not sets and the operation of inter on lists is not identical to intersection of sets. In particular, the result of inter does not comprise the distinct items common to the two arguments. One consequence is that the expression, </code>
<mode> </code>
<mode> (x inter y)~y inter x </code>
<mode> </code>
<mode> is not true in general. </code>
<mode> </code>
<mode> When applied to dictionaries, inter returns the set of common range items that are mapped from the the same domain items. </code>
<mode> </code>
<mode> d1:1 2 3!100 200 300 </code>
<mode> d2:2 4 6!200 400 600 </code>
<mode> d1 inter d2 </code>
<mode> ,200 </code>
<mode> </code>
<mode> Tables that have the same columns can participate in inter. The result is a table with the records that are common to the two tables. </code>
<mode> </code>
<mode> t1 </code>
<mode> a b </code>
<mode> -------- </code>
<mode> 1 first </code>
<mode> 2 second </code>
<mode> 3 third </code>
<mode> </code>
<mode> t2 </code>
<mode> a b </code>
<mode> -------- </code>
<mode> 2 second </code>
<mode> 4 fourth </code>
<mode> 6 sixth </code>
<mode> </code>
<mode> t1 inter t2 </code>
<mode> a b </code>
<mode> -------- </code>
<mode> 2 second </code>
<mode> </code>
<mode> join (,) ¶ </code>
<mode> </code>
<mode> The dyadic join ( , ) can take many different combinations of arguments. </code>
<mode> </code>
<mode> When both operands are either lists or atoms, the result is a list with the item(s) of the left operand followed by the item(s) of the right operand. </code>
<mode> </code>
<mode> 2,3 </code>
<mode> 2 3 </code>
<mode> </code>
<mode> `a,`b`c </code>
<mode> `a`b`c </code>
<mode> </code>
<mode> "xy","yz" </code>
<mode> xyyz </code>
<mode> </code>
<mode> 1.1 2.2,3 4 </code>
<mode> 1.1 </code>
<mode> 2.2 </code>
<mode> 3 </code>
<mode> 4 </code>
<mode> </code>
<mode> Observe that the result is a general list unless all items are of a homogeneous type. </code>
<mode> </code>
<mode> When both operands are dictionaries, the result is the merge of the dictionaries using upsert semantics. The domain of the result is the (set theoretic) union of the two domains. Range assignment of the right operand prevails on common domain items. </code>
<mode> </code>
<mode> d1:1 2 3!`a`b`c </code>
<mode> d2:3 4 5!`cc`d`e </code>
<mode> d1,d2 </code>
<mode> 1| a </code>
<mode> 2| b </code>
<mode> 3| cc </code>
<mode> 4| d </code>
<mode> 5| e </code>
<mode> </code>
<mode> When both operands are tables having the same column names and types, the result is a table in which the records of the right operand are appended to those of the left operand. </code>
<mode> </code>
<mode> t1[]a:1 2 3;b:`x`y`z) </code>
<mode> t1 </code>
<mode> a b </code>
<mode> — </code>
<mode> 1 x </code>
<mode> 2 y </code>
<mode> 3 z </code>
<mode> </code>
<mode> t2[]a:3 4;b:`yy`z) </code>
<mode> t2 </code>
<mode> a b </code>
<mode> ---- </code>
<mode> 3 yy </code>
<mode> 4 z </code>
<mode> </code>
<mode> t1,t2 </code>
<mode> a b </code>
<mode> ---- </code>
<mode> 1 x </code>
<mode> 2 y </code>
<mode> 3 z </code>
<mode> 3 yy </code>
<mode> 4 z </code>
<mode> </code>
<mode> When both operands are keyed tables having the same key and value columns, the result is a keyed table in which the records of the left operand are upserted with those of the right operand. </code>
<mode> </code>
<mode> kt1:(k:1 2 3v:`a`b`c) </code>
<mode> kt1 </code>
<mode> k| v </code>
<mode> -| - </code>
<mode> 1| a </code>
<mode> 2| b </code>
<mode> 3| c </code>
<mode> </code>
<mode> kt2:(k:3 4v:`cc`d) </code>
<mode> kt2 </code>
<mode> k| v </code>
<mode> -| – </code>
<mode> 3| cc </code>
<mode> 4| d </code>
<mode> </code>
<mode> kt1,kt2 </code>
<mode> k| v </code>
<mode> -| – </code>
<mode> 1| a </code>
<mode> 2| b </code>
<mode> 3| cc </code>
<mode> 4| d </code>
<mode> </code>
<mode> join-each (,') ¶ </code>
<mode> </code>
<mode> The verb join ( , ) can be combined with the adverb monadic each ( ' ) to yield join-each ( ,' ), which can be used on lists, dictionaries or tables. </code>
<mode> </code>
<mode> List operands must have the same count. </code>
<mode> </code>
<mode> L1:1 2 3 </code>
<mode> L2:`a`b`c </code>
<mode> L1,'L2 </code>
<mode> 1 `a </code>
<mode> 2 `b </code>
<mode> 3 `c </code>
<mode> </code>
<mode> As always with dictionaries, the operation occurs along the common domain items, with null extension elsewhere. </code>
<mode> </code>
<mode> d1:1 2 3!10 20 30 </code>
<mode> d2:2 3 4!`a`b`c </code>
<mode> d1,'d2 </code>
<mode> 1| 10 ` </code>
<mode> 2| 20 `a </code>
<mode> 3| 30 `b </code>
<mode> 4| 0N `c </code>
<mode> </code>
<mode> For two tables with the same count of records, join-each results in a column join (Column Join), in which columns with non-common names are juxtaposed and overlapping columns are upserted. </code>
<mode> </code>
<mode> t1[]c1:1 2 3;c2:1.1 2.2 3.3) </code>
<mode> t1 </code>
<mode> c1 c2 </code>
<mode> ------ </code>
<mode> 1 1.1 </code>
<mode> 2 2.2 </code>
<mode> 3 3.3 </code>
<mode> </code>
<mode> t2[]c2:`a`b`c;c3:100 200 300) </code>
<mode> t2 </code>
<mode> c2 c3 </code>
<mode> ------ </code>
<mode> a 100 </code>
<mode> b 200 </code>
<mode> c 300 </code>
<mode> </code>
<mode> t1,'t2 </code>
<mode> c1 c2 c3 </code>
<mode> --------- </code>
<mode> 1 a 100 </code>
<mode> 2 b 200 </code>
<mode> 3 c 300 </code>
<mode> </code>
<mode> Note: When join-each is used in a select, it must be enclosed in parentheses to avoid the comma being interpreted as a separator. </code>
<mode> </code>
<mode> select j:(c1,'c2) from t1 </code>
<mode> j </code>
<mode> ----- </code>
<mode> 1 1.1 </code>
<mode> 2 2.2 </code>
<mode> 3 3.3 </code>
<mode> </code>
<mode> list ¶ </code>
<mode> </code>
<mode> The function list replaces plist. It XE "list (function)" takes a variable number of arguments and returns a list whose items are the arguments. It is useful for creating lists programmatically. </code>
<mode> </code>
<mode> Note: Unlike user-defined functions, the number of arguments to list is not restricted to eight. </code>
<mode> </code>
<mode> For example, </code>
<mode> </code>
<mode> list6;7;42;`Life;"The Universe" </code>
<mode> 6 </code>
<mode> 7 </code>
<mode> 42 </code>
<mode> `Life </code>
<mode> The Universe </code>
<mode> </code>
<mode> list1;2;3;4;5;6;7;8;9;10 </code>
<mode> 1 2 3 4 5 6 7 8 9 10 </code>
<mode> </code>
<mode> null ¶ </code>
<mode> </code>
<mode> The atomic function null takes a list (source) and returns a binary list comprising the result of testing each item in source against null. </code>
<mode> </code>
<mode> null 1 2 3 0N 5 0N </code>
<mode> 000101b </code>
<mode> </code>
<mode> null `a`b``d```f </code>
<mode> 0010110b </code>
<mode> </code>
<mode> Since null is atomic, it is applied recursively to sublists. </code>
<mode> </code>
<mode> null (1 2;3 0N) </code>
<mode> 00b </code>
<mode> 01b </code>
<mode> </code>
<mode> It is useful to combine where with null to obtain the positions of the null items. </code>
<mode> </code>
<mode> where null 1 2 3 0N 5 0N </code>
<mode> 3 5 </code>
<mode> </code>
<mode> When applied to a dictionary (source), null returns a dictionary in which each item in the source range is replaced with the result of testing the item against null. </code>
<mode> </code>
<mode> null 1 2 3!100 0N 300 </code>
<mode> 1| 0 </code>
<mode> 2| 1 </code>
<mode> 3| 0 </code>
<mode> </code>
<mode> The action of null on a table (source) is explained by recalling that the table is a flipped column dictionary. Based on the action of null on a dictionary, we expect the result of null on a table will be a new table in which each column value in the source is replaced with the result of testing the value against null. </code>
<mode> </code>
<mode> tnull[]a:1 0N 3; b:0N 200 300) </code>
<mode> null tnull </code>
<mode> a b </code>
<mode> — </code>
<mode> 0 1 </code>
<mode> 1 0 </code>
<mode> 0 0 </code>
<mode> </code>
<mode> Similarly, we expect null to operate on a keyed table by returning a result keyed table whose value table entries are the result of testing those of the argument against null. </code>
<mode> </code>
<mode> ktnull:(k:101 102 103;v:`first``third) </code>
<mode> null ktnull </code>
<mode> k | v </code>
<mode> ---| — </code>
<mode> 101| 0 </code>
<mode> 102| 1 </code>
<mode> 103| 0 </code>
<mode> </code>
<mode> parse ¶ </code>
<mode> </code>
<mode> The monadic function parse takes a string argument containing a valid q expression and returns a list containing the corresponding parse tree. Applying the function eval to the result will evaluate it. A discussion of q parse trees is beyond the scope of this tutorial. </code>
<mode> </code>
<mode> .Q.s1 parse "a:6*7" </code>
<mode> (:;`a;(*;6;7)) </code>
<mode> eval parse "a:6*7" </code>
<mode> 42 </code>
<mode> </code>
<mode> Note: It is useful to apply parse to a query template in order to discover its functional form. The result is not always exactly the functional form, especially for exec, but a little experimenting will lead to the correct form. </code>
<mode> </code>
<mode> t[]c1:`a`b`a; c2:1 2 3) </code>
<mode> select c2 by c1 from t </code>
<mode> c1| c2 </code>
<mode> --| — </code>
<mode> a | 1 3 </code>
<mode> b | ,2 </code>
<mode> </code>
<mode> parse "select c2 by c1 from t" </code>
<mode> ? </code>
<mode> `t </code>
<mode> () </code>
<mode> (,`c1)!,`c1 </code>
<mode> (,`c2)!,`c2 </code>
<mode> </code>
<mode> ?t;();(enlist `c1)!enlist `c1;(enlist `c2)!enlist `c2 </code>
<mode> c1| c2 </code>
<mode> --| — </code>
<mode> a | 1 3 </code>
<mode> b | ,2 </code>
<mode> </code>
<mode> exec c2 by c1 from t </code>
<mode> a| 1 3 </code>
<mode> b| ,2 </code>
<mode> </code>
<mode> parse "exec c2 by c1 from t" </code>
<mode> ? </code>
<mode> `t </code>
<mode> () </code>
<mode> ,`c1 </code>
<mode> ,`c2 </code>
<mode> </code>
<mode> ?t;();`c1;`c1 </code>
<mode> a| `a`a </code>
<mode> b| ,`b </code>
<mode> </code>
<mode> rand ¶ </code>
<mode> </code>
<mode> The dyadic function rand ( ? ) is overloaded to have different meanings. In the case where both arguments are numeric scalars, ? returns a list of random numbers. More specifically, the first argument must be of integer type, and the second argument can by any numeric value. In this context, ? returns a list of pseudo-random numbers of count given by first argument. </code>
<mode> </code>
<mode> In case the second argument is a positive number of floating point type and the first argument is positive, the result is a list of random float selected with replacement from the range between 0 (inclusive) and the second argument (exclusive). </code>
<mode> </code>
<mode> 5?4.2 </code>
<mode> 3.778553 1.230056 1.572286 0.517468 0.07107598 </code>
<mode> </code>
<mode> 4?1.0 </code>
<mode> 0.5274765 0.5435815 0.4611484 0.7493561 </code>
<mode> </code>
<mode> In case the second argument is of integer type and the first argument is positive, the result is a list of random integers selected with replacement from the range between 0 (inclusive) and the second argument (exclusive). </code>
<mode> </code>
<mode> 10?5 </code>
<mode> 1 2 0 3 4 4 4 0 3 1 </code>
<mode> </code>
<mode> 10?5 </code>
<mode> 0 2 1 0 2 4 2 3 4 0 </code>
<mode> </code>
<mode> 1+10?5 </code>
<mode> 4 2 3 3 3 2 1 1 5 3 </code>
<mode> </code>
<mode> The last example shows how to select random integers between 1 and 5. More generally, for integers i and j, where i<j, and any integer n, the idiom, </code>
<mode> </code>
<mode> i+n?j+1-i </code>
<mode> </code>
<mode> selects n random integers between i and j inclusive. </code>
<mode> </code>
<mode> i:3 </code>
<mode> j:7 </code>
<mode> n:10 </code>
<mode> i+n?j+1-i </code>
<mode> 3 4 5 7 7 5 4 4 7 4 </code>
<mode> </code>
<mode> In case the second argument is of integer type and the first argument is negative, the result is a list of random integers selected without replacement from the range between 0 (inclusive) and the second argument (exclusive). Since the selected values are not replaced, the absolute value of the first argument cannot exceed the second argument, </code>
<mode> </code>
<mode> -3?5 </code>
<mode> 2 3 0 </code>
<mode> </code>
<mode> -5?5 </code>
<mode> 4 1 2 0 3 </code>
<mode> </code>
<mode> -6?5 </code>
<mode> 'length </code>
<mode> </code>
<mode> raze ¶ </code>
<mode> </code>
<mode> The monadic raze takes a list or dictionary (source) and returns the entity derived from the source by eliminating the top-most level of nesting. </code>
<mode> </code>
<mode> raze (1 2;`a`b) </code>
<mode> 1 </code>
<mode> 2 </code>
<mode> `a </code>
<mode> `b </code>
<mode> </code>
<mode> One way to envision the action of raze is to write the source list in general form, then remove the parentheses directly beneath the outer-most enclosing pair. </code>
<mode> </code>
<mode> raze ((1;2);(`a;`b)) </code>
<mode> 1 </code>
<mode> 2 </code>
<mode> `a </code>
<mode> `b </code>
<mode> </code>
<mode> Observe that raze only removes the top-most level of nesting and does not apply recursively to sublists. </code>
<mode> </code>
<mode> raze ((1 2;3 4);(5;(6 7;8 9))) </code>
<mode> 1 2 </code>
<mode> 3 4 </code>
<mode> 5 </code>
<mode> (6 7;8 9) </code>
<mode> </code>
<mode> If source is not nested, the result is the source. </code>
<mode> </code>
<mode> raze 1 2 3 4 </code>
<mode> 1 2 3 4 </code>
<mode> </code>
<mode> When raze is applied to an atom, the result is a list. </code>
<mode> </code>
<mode> raze 42 </code>
<mode> ,42 </code>
<mode> </code>
<mode> When raze is applied to a dictionary, the result is raze applied to the range. </code>
<mode> </code>
<mode> dd:`a`b`c!(1 2; 3 4 5;6) </code>
<mode> raze dd </code>
<mode> 1 2 3 4 5 6 </code>
<mode> </code>
<mode> reshape (#) ¶ </code>
<mode> </code>
<mode> When the first argument of the dyadic reshape ( # ) is a list (shape) of two positive int, the result reshapes the source into a rectangular list according to shape. Specifically, the count of the result in dimension i is given by the item in position i in shape. The elements are taken from the beginning of the source. </code>
<mode> </code>
<mode> A simple example makes this clear. </code>
<mode> </code>
<mode> 2 3#1 2 3 4 5 6 </code>
<mode> 1 2 3 </code>
<mode> 4 5 6 </code>
<mode> </code>
<mode> As in the case of take, if the number of elements in the source exceeds what is necessary to form the result, trailing elements are ignored. </code>
<mode> </code>
<mode> 2 2#`a`b`c`d`e`f`g`h </code>
<mode> a b </code>
<mode> c d </code>
<mode> </code>
<mode> Similarly, if the number of elements in the source is less than necessary to form the result, the extraction resumes from the initial item of the source; this process is repeated until the result is complete. </code>
<mode> </code>
<mode> 5 4#"Now is the time" </code>
<mode> Now </code>
<mode> is t </code>
<mode> he t </code>
<mode> imeN </code>
<mode> ow i </code>
<mode> </code>
<mode> It is possible create a ragged array of any number of columns by using 0N as the number of rows with the reshape operator ( # ). </code>
<mode> </code>
<mode> 0N 3#til 10 </code>
<mode> 0 1 2 </code>
<mode> 3 4 5 </code>
<mode> 6 7 8 </code>
<mode> ,9 </code>
<mode> </code>
<mode> reverse ¶ </code>
<mode> </code>
<mode> The monadic reverse inverts the order of the constituents of its argument. In the case of an atom, it simply returns the argument. </code>
<mode> </code>
<mode> reverse 42 </code>
<mode> 42 </code>
<mode> </code>
<mode> In the case of a list, the result is a list in which the items are in reverse order of the argument. </code>
<mode> </code>
<mode> reverse 1 2 3 4 5 </code>
<mode> 5 4 3 2 1 </code>
<mode> </code>
<mode> For nested lists, the reversal takes place only at the topmost level. </code>
<mode> </code>
<mode> reverse (1 2 3; "abc"; `Four`Score`and`Seven) </code>
<mode> `Four`Score`and`Seven </code>
<mode> abc </code>
<mode> 1 2 3 </code>
<mode> </code>
<mode> In the case of an empty list, reverse returns the argument. </code>
<mode> </code>
<mode> reverse () </code>
<mode> () </code>
<mode> </code>
<mode> In the case of a dictionary, reverse inverts both the domain and range lists. </code>
<mode> </code>
<mode> reverse`a`b`c!1 2 3 </code>
<mode> c| 3 </code>
<mode> b| 2 </code>
<mode> a| 1 </code>
<mode> </code>
<mode> Since a table is a list of records, reverse inverts the order of the records. </code>
<mode> </code>
<mode> t[] c1:`a`b`c; c2:1 2 3) </code>
<mode> t </code>
<mode> c1 c2 </code>
<mode> ----- </code>
<mode> a 1 </code>
<mode> b 2 </code>
<mode> c 3 </code>
<mode> reverse t </code>
<mode> c1 c2 </code>
<mode> ----- </code>
<mode> c 3 </code>
<mode> b 2 </code>
<mode> a 1 </code>
<mode> </code>
<mode> Since a keyed table is a dictionary, reverse inverts both the domain and range tables, effectively inverting the row order. </code>
<mode> </code>
<mode> kt </code>
<mode> k| c </code>
<mode> -| — </code>
<mode> 1| 100 </code>
<mode> 2| 101 </code>
<mode> 3| 102 </code>
<mode> </code>
<mode> reverse kt </code>
<mode> k| c </code>
<mode> -| — </code>
<mode> 3| 102 </code>
<mode> 2| 101 </code>
<mode> 1| 100 </code>
<mode> </code>
<mode> sublist ¶ </code>
<mode> </code>
<mode> The dyadic function sublist retrieves a sublist of contiguous items from a list. The left operand is a simple list of two ints: the first item is the starting index (start); the second item is the number of items to retrieve (count). The right operand (target) is a list or dictionary. </code>
<mode> </code>
<mode> If target is a list, the result is a list comprising count items from target beginning at index start. </code>
<mode> </code>
<mode> L:1 2 3 4 5 </code>
<mode> 1 3 sublist L </code>
<mode> 2 3 4 </code>
<mode> </code>
<mode> If target is a dictionary, the result is a dictionary whose domain comprises count items from the target domain beginning at index start, and whose range is the corresponding items in the target range. </code>
<mode> </code>
<mode> d:`a`b`c`d`e!1 2 3 4 5 </code>
<mode> 1 3 sublist d </code>
<mode> b| 2 </code>
<mode> c| 3 </code>
<mode> d| 4 </code>
<mode> </code>
<mode> Since a table is a list of records, sublist applies to the rows of a table. </code>
<mode> </code>
<mode> t[]c1:`a`b`c`d`e;c2:1 2 3 4 5) </code>
<mode> 1 3 sublist t </code>
<mode> c1 c2 </code>
<mode> ----- </code>
<mode> b 2 </code>
<mode> c 3 </code>
<mode> d 4 </code>
<mode> </code>
<mode> Since a keyed table is a dictionary, sublist is applied to the key table. </code>
<mode> </code>
<mode> kt:(k:`a`b`c`d`ec1:1 2 3 4 5) </code>
<mode> 1 3 sublist kt </code>
<mode> k| c1 </code>
<mode> -| – </code>
<mode> b| 2 </code>
<mode> c| 3 </code>
<mode> d| 4 </code>
<mode> </code>
<mode> system ¶ </code>
<mode> </code>
<mode> The monadic system takes a string argument and executes it is a q command, if recognized, or an OS command otherwise. The function system is equivalent to
but can be more convenient or readable in situations such as remote or programmatic execution in which the backslashes must be escaped. </code>
<mode> </code>
<mode> The following changes the current working directory to its sparent directory. </code>
<mode> </code>
<mode> system "cd .." </code>
<mode> </code>
<mode> take (#) ¶ </code>
<mode> </code>
<mode> When the left operand of take ( # ) is an int atom, it creates a new entity via extraction from its right operand (source) as specified by the first operand. A positive integer in the first operand indicates that the extraction occurs from the beginning of the source, whereas a negative integer in the first operand indicates that the extraction occurs from the end of the source. </code>
<mode> </code>
<mode> The source can be an atom, a list, a dictionary, a table or a keyed table. </code>
<mode> </code>
<mode> 2#3 </code>
<mode> 3 3 </code>
<mode> </code>
<mode> -1#10 20 30 40 </code>
<mode> ,40 </code>
<mode> </code>
<mode> -2#`a`b`c`d!10 20 30 40 </code>
<mode> c| 30 </code>
<mode> d| 40 </code>
<mode> </code>
<mode> 3#([] a:10 20 30 40; b:1.1 2.2 3.3 4.4) </code>
<mode> a b </code>
<mode> ------ </code>
<mode> 10 1.1 </code>
<mode> 20 2.2 </code>
<mode> 30 3.3 </code>
<mode> </code>
<mode> 1#(k:10 20 30 c:`one`two`three) </code>
<mode> k | c </code>
<mode> --| — </code>
<mode> 10| one </code>
<mode> </code>
<mode> The result of take is of the same type and shape as the source, except the result is never a scalar. </code>
<mode> </code>
<mode> 1#42 </code>
<mode> ,42 </code>
<mode> </code>
<mode> If the number of elements in source exceeds what is necessary to form the result, trailing elements are ignored. </code>
<mode> </code>
<mode> 4#`a`b`c`d`e`f`g`h </code>
<mode> `a`b`c`d </code>
<mode> </code>
<mode> If the number of elements in source is less than necessary to form the result, the extraction resumes from the starting point of the source list; this process is repeated until the result is filled. </code>
<mode> </code>
<mode> 5#98 99 </code>
<mode> 98 99 98 99 98 </code>
<mode> </code>
<mode> -7#`a`b`c </code>
<mode> `c`a`b`c`a`b`c </code>
<mode> </code>
<mode> In the degenerate case, the result is an empty entity with the same type as the source. This is an effective way to obtain the schema of a q dictionary or list. </code>
<mode> </code>
<mode> 0#42 </code>
<mode> `int$() </code>
<mode> </code>
<mode> 0#10 20 30 40 </code>
<mode> `int$() </code>
<mode> </code>
<mode> 0#`a`b`c`d!10 20 30 40 </code>
<mode> _ </code>
<mode> </code>
<mode> 0#([] a:10 20 30 40; b:1.1 2.2 3.3 4.4) </code>
<mode> a b </code>
<mode> — </code>
<mode> </code>
<mode> 0#(k:10 20 30 c:`one`two`three) </code>
<mode> k| c </code>
<mode> -| - </code>
<mode> </code>
<mode> Note: Since the result of 0# on a list is always a list, we can use this construct as shorthand to initialize an empty value column with a definite type in a table definition. This ensures that only values of the specified type can be inserted into the column. For example, </code>
<mode> </code>
<mode> ([] a:0#0; b:0#`) </code>
<mode> a b </code>
<mode> — </code>
<mode> </code>
<mode> defines an empty table whose first column is of type int and whose second column is of type symbol. </code>
<mode> </code>
<mode> When the left operand of # is a list of symbol column names and the right operand is a table, the result is the table obtained by extracting the specified columns from t. </code>
<mode> </code>
<mode> t[] c1:`a`b`c; c2:1 2 3; c3:1.1 2.2 3.3) </code>
<mode> `c1`c3#t </code>
<mode> c1 c3 </code>
<mode> ------ </code>
<mode> a 1.1 </code>
<mode> b 2.2 </code>
<mode> c 3.3 </code>
<mode> </code>
<mode> When the left operand of # is a table (keys) and the second operand is a keyed table whose key table contains keys, the result is the keyed table corresponding to those values in keys. </code>
<mode> </code>
<mode> ktc:(lname:`Dent`Beeblebrox`Prefect; fname:`Arthur`Zaphod`Ford iq:98 42 126) </code>
<mode> ktc </code>
<mode> lname fname | iq </code>
<mode> -----------------| — </code>
<mode> Dent Arthur| 98 </code>
<mode> Beeblebrox Zaphod| 42 </code>
<mode> Prefect Ford | 126 </code>
<mode> </code>
<mode> K[] lname:`Dent`Prefect; fname:`Arthur`Ford) </code>
<mode> K#ktc </code>
<mode> lname fname | iq </code>
<mode> --------------| — </code>
<mode> Dent Arthur| 98 </code>
<mode> Prefect Ford | 126 </code>
<mode> </code>
<mode> til ¶ </code>
<mode> </code>
<mode> The monadic til returns a list of the integers from 0 to n-1, where its argument n is a non-negative integer. </code>
<mode> </code>
<mode> til 4 </code>
<mode> 0 1 2 3 </code>
<mode> </code>
<mode> The result of til is always a list of int. So, </code>
<mode> </code>
<mode> til 1 </code>
<mode> ,0 </code>
<mode> </code>
<mode> til 0 </code>
<mode> `int$() </code>
<mode> </code>
<mode> Generating sequences is simple with til. </code>
<mode> </code>
<mode> 2*til 10 / evens </code>
<mode> 0 2 4 6 8 10 12 14 16 18 </code>
<mode> </code>
<mode> 1+2*til 10 / odds </code>
<mode> 1 3 5 7 9 11 13 15 17 19 </code>
<mode> </code>
<mode> 20+til 5 </code>
<mode> 20 21 22 23 24 </code>
<mode> </code>
<mode> 0.5*til 10 </code>
<mode> 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 </code>
<mode> </code>
<mode> The function til is useful for extracting a sublist from a list. The idiom, </code>
<mode> </code>
<mode> Li+til n </code>
<mode> </code>
<mode> extracts from the list L the sublist of length n starting with the element in position i. For example, </code>
<mode> </code>
<mode> L:10 20 30 40 50 60 70 </code>
<mode> i:2 </code>
<mode> n:3 </code>
<mode> </code>
<mode> Li+til n </code>
<mode> 30 40 50 60 </code>
<mode> </code>
<mode> Similarly, the idiom </code>
<mode> </code>
<mode> Li+til j+1-i </code>
<mode> </code>
<mode> extracts the sublist from positions i through j, inclusive. With L and i as above, </code>
<mode> </code>
<mode> i:2 </code>
<mode> j:5 </code>
<mode> Li+til j+1-i </code>
<mode> 20 30 40 50 60 </code>
<mode> </code>
<mode> Note: In the second idiom, omitting the increment-by-one retrieves one less item than you probably intend. This is an easy error to make. </code>
<mode> </code>
<mode> These idioms are useful for extracting substrings. </code>
<mode> </code>
<mode> s:"abcdefg" </code>
<mode> i:1 </code>
<mode> n:2 </code>
<mode> j:4 </code>
<mode> si+til n </code>
<mode> bc </code>
<mode> </code>
<mode> si+til j+1-i </code>
<mode> bcde </code>
<mode> </code>
<mode> Note: You can use the built-in function sublist to retrieve substrings. </code>
<mode> </code>
<mode> The expression, </code>
<mode> </code>
<mode> n = count til n </code>
<mode> </code>
<mode> is true for every n ? 0. Similarly, the expression, </code>
<mode> </code>
<mode> L~Ltil count L </code>
<mode> </code>
<mode> is true for every list L. Both expressions remain valid in the degenerate case of the empty list. </code>
<mode> ungroup ¶ </code>
<mode> </code>
<mode> The monadic ungroup can be applied to a keyed table that is the result of a select with grouping or of the xgroup function. The result will have the selected records in the same format as the original table but they may be in a different order since they will be sorted by the grouping column(s). </code>
<mode> </code>
<mode> Using the distribution example, </code>
<mode> </code>
<mode> sp </code>
<mode> s p qty </code>
<mode> --------- </code>
<mode> s1 p1 300 </code>
<mode> s1 p2 200 </code>
<mode> s1 p3 400 </code>
<mode> s1 p4 200 </code>
<mode> s4 p5 100 </code>
<mode> s1 p6 100 </code>
<mode> s2 p1 300 </code>
<mode> s2 p2 400 </code>
<mode> s3 p2 200 </code>
<mode> s4 p2 200 </code>
<mode> s4 p4 300 </code>
<mode> s1 p5 400 </code>
<mode> </code>
<mode> ungroup select s, qty by p from sp </code>
<mode> p s qty </code>
<mode> --------- </code>
<mode> p1 s1 300 </code>
<mode> p1 s2 300 </code>
<mode> p2 s1 200 </code>
<mode> p2 s2 400 </code>
<mode> p2 s3 200 </code>
<mode> p2 s4 200 </code>
<mode> p3 s1 400 </code>
<mode> p4 s1 200 </code>
<mode> p4 s4 300 </code>
<mode> p5 s4 100 </code>
<mode> p5 s1 400 </code>
<mode> p6 s1 100 </code>
<mode> </code>
<mode> Note: You can apply ungroup to a keyed table that did not arise from a group operation, but it must have the correct form or an error will result. </code>
<mode> union ¶ </code>
<mode> </code>
<mode> The dyadic union can be applied to lists and tables. It returns an entity of the same type as its arguments containing the distinct elements from both arguments. </code>
<mode> </code>
<mode> 1 union 2 3 </code>
<mode> 1 2 3 </code>
<mode> </code>
<mode> 1 2 union 2 3 </code>
<mode> 1 2 3 </code>
<mode> </code>
<mode> 1 1 3 union 1 2 3 1 </code>
<mode> 1 3 2 </code>
<mode> </code>
<mode> "a good time" union "was had by all" </code>
<mode> a godtimewshbyl </code>
<mode> </code>
<mode> Observe that the items of the first argument appear first in the result. </code>
<mode> </code>
<mode> Tables that have the same columns can participate in union. The result is a table with the distinct records from the combination of the two tables. </code>
<mode> </code>
<mode> t1[] a:1 2 3 4; b:`first`second`third`fourth) </code>
<mode> t2[] a:2 4 6; b:`dos`cuatro`seis) </code>
<mode> t1 </code>
<mode> a b </code>
<mode> -------- </code>
<mode> 1 first </code>
<mode> 2 second </code>
<mode> 3 third </code>
<mode> 4 fourth </code>
<mode> </code>
<mode> t2 </code>
<mode> a b </code>
<mode> -------- </code>
<mode> 2 dos </code>
<mode> 4 cuatro </code>
<mode> 6 seis </code>
<mode> </code>
<mode> t1 union t2 </code>
<mode> a b </code>
<mode> -------- </code>
<mode> 1 first </code>
<mode> 2 second </code>
<mode> 3 third </code>
<mode> 4 fourth </code>
<mode> 2 dos </code>
<mode> 4 cuatro </code>
<mode> 6 seis </code>
<mode> </code>
<mode> Note: As of this writing (Jun 2009), union does apply to dictionaries or keyed tables. </code>
<mode> value ¶ </code>
<mode> </code>
<mode> The function value has two uses. When applied to a dictionary, value returns the range of the dictionary. </code>
<mode> </code>
<mode> d:`a`b`c!1 2 3 </code>
<mode> value d </code>
<mode> 1 2 3 </code>
<mode> </code>
<mode> Logically enough, for a keyed table, value returns the value table. </code>
<mode> </code>
<mode> kt:(k:101 102 103 c1:`a`b`c) </code>
<mode> kt </code>
<mode> k | c1 </code>
<mode> ---| – </code>
<mode> 101| a </code>
<mode> 102| b </code>
<mode> 103| c </code>
<mode> </code>
<mode> value kt </code>
<mode> c1 </code>
<mode> – </code>
<mode> a </code>
<mode> b </code>
<mode> c </code>
<mode> </code>
<mode> When value is applied to a string, it passes the string to the q interpreter and returns the result. </code>
<mode> </code>
<mode> value "6*7" </code>
<mode> 42 </code>
<mode> </code>
<mode> value "
til 10" </code>
<mode> 0 1 4 9 16 25 36 49 64 81 </code>
<mode> </code>
<mode> z:98.6 </code>
<mode> value"z" </code>
<mode> 98.6 </code>
<mode> </code>
<mode> value "a:6;b:7;c:a*b" </code>
<mode> a </code>
<mode> 6 </code>
<mode> </code>
<mode> b </code>
<mode> 7 </code>
<mode> </code>
<mode> c </code>
<mode> 42 </code>
<mode> </code>
<mode> Note: This use of the value function is a powerful feature that allows q code to be written and executed on the fly. If abused, it can quickly lead to unmaintainable code. (The spellchecker suggests "unmentionable" instead of "unmaintainable." How did it know?) </code>
<mode> </code>
<mode> A common use of value is to convert a symbol or string containing the name of a q entity into the value associated with the entity. </code>
<mode> </code>
<mode> a:42 </code>
<mode> s:`a </code>
<mode> value `a </code>
<mode> 42 </code>
<mode> </code>
<mode> value s </code>
<mode> 42 </code>
<mode> </code>
<mode> value "a" </code>
<mode> 42 </code>
<mode> </code>
<mode> where ¶ </code>
<mode> </code>
<mode> The monadic where has multiple uses, depending on the type of its argument. </code>
<mode> </code>
<mode> When the argument is a boolean list, where returns a list of int comprising the positions in the argument having value 1b. </code>
<mode> </code>
<mode> where 00110101b </code>
<mode> 2 3 5 7 </code>
<mode> </code>
<mode> This is useful when the boolean list is generated by a test on a list. </code>
<mode> </code>
<mode> L:"Now;is;the;time" </code>
<mode> </code>
<mode> where L=";" </code>
<mode> 3 6 10 </code>
<mode> </code>
<mode> Lwhere L=";":" " </code>
<mode> L </code>
<mode> Now is the time </code>
<mode> </code>
<mode> Note: The behavior of the where phrase in the select template is related to the where function on a boolean list. The former limits the selection to table rows in those positions where the value of the where expression is not zero. Since the expression involves test(s) on column value(s), the where phrase effectively selects the rows satisfying its column condition, just as in SQL. See The where Phrase for more on the where phrase. </code>
<mode> </code>
<mode> When the argument s of where is a list of non-negative int, the result is a list of int comprising the items 0, ... , -1+count s, in which the original item at position i is repeated si times. </code>
<mode> </code>
<mode> For example, </code>
<mode> </code>
<mode> where 2 1 3 </code>
<mode> 0 0 1 2 2 2 </code>
<mode> where 4 0 2 </code>
<mode> 0 0 0 0 2 2 </code>
<mode> where 4#1 </code>
<mode> 0 1 2 3 </code>
<mode> </code>
<mode> Note: The behavior of where on an int list reduces to that on a boolean list by considering the boolean values as ints. </code>
<mode> </code>
<mode> When the argument s is a dictionary whose range is a list of non-negative int, where returns a list comprising items of the domain of s, in which the item at position i is repeated si times. </code>
<mode> </code>
<mode> For example, </code>
<mode> </code>
<mode> where `a`b`c!2 1 3 </code>
<mode> `a`a`b`c`c`c </code>
<mode> where `a`b`c!4 0 2 </code>
<mode> `a`a`a`a`c`c </code>
<mode> </code>
<mode> Note: The behavior of where on a dictionary is consistent with its behavior on a list by considering a list L as a mapping whose implicit domain is til count L. </code>
<mode> within ¶ </code>
<mode> </code>
<mode> The dyadic function within is atomic in its first argument (source) and takes a second argument that is a list of two items that have underlying numeric values. It returns a boolean value representing whether source is between the two items of the second argument (inclusive). </code>
<mode> </code>
<mode> 3 within 2 5 </code>
<mode> 0b </code>
<mode> </code>
<mode> 100 within 0 100 </code>
<mode> 1b </code>
<mode> </code>
<mode> "c" within "az" </code>
<mode> 1b </code>
<mode> </code>
<mode> 2006.11.19 2007.07.04 2008.08.12 within 2007.01.01 2007.12.31 </code>
<mode> 010b </code>
<mode> </code>
<mode> Observe that within is type tolerant provided both arguments have underlying numeric values, meaning that the types of its arguments do not need to match. </code>
<mode> </code>
<mode> 0x42 within (30h;100j) </code>
<mode> 1b </code>
<mode> </code>
<mode> 100 within "aj" </code>
<mode> 1b </code>
<mode> </code>
<mode> It is also possible to apply within to symbols since they have lexicographic order. </code>
<mode> </code>
<mode> `ab within `a`z </code>
<mode> 1b </code>
<mode> </code>
<mode> Note: The expression </code>
<mode> </code>
<mode> x within (a;b) </code>
<mode> </code>
<mode> is equivalent to, </code>
<mode> </code>
<mode> (a<=x)&x<=b </code>
<mode> </code>
<mode> Thus, if the items of the second argument are not in increasing order, the result of within will always be 0b. </code>
<mode> </code>
<mode> 5 within 6 2 </code>
<mode> 0b </code>
<mode> ©2009 MeAmI.org Systems, Inc. All rights reserved. </code>
<mode> [ [ , ] LOGIN_TYPE =
] </code>
<mode> [ [ , ] SESSION_TIMEOUT = timeoutInterval | NEVER ] </code>
<mode> [ [ , ] DATABASE =
</code>
<mode> [ [ , ] NAMESPACE =
] </code>
<mode> [ [ , ] SCHEMA =
] </code>
<mode> [ [ , ] CHARACTER_SET =
] </code>
<mode> [ [ , ] HEADER_LIMIT = int ] </code>
<mode> ) </code>
<mode> other payloads are included </code>
<mode> 7 layers of security of an HTTP endpoint </code>
<mode> * Endpoint type </code>
<mode> o TCP </code>
<mode> o HTTP </code>
<mode> + responds to either HTTP or HTTPS requests </code>
<mode> * Endpoint payload </code>
<mode> o SOAP </code>
<mode> + TCP and HTTP </code>
<mode> o TSQL </code>
<mode> + TCP only </code>
<mode> o SERVICE_BROKER </code>
<mode> + TCP only </code>
<mode> o DATABASE_MIRRORING </code>
<mode> + TCP only </code>
<mode> * Endpoint state </code>
<mode> o STOPPED </code>
<mode> o STARTED </code>
<mode> + default </code>
<mode> + returns an and/or to any connection attempt </code>
<mode> o ENABLED </code>
<mode> + responds to any requests </code>
<mode> * Authentication method </code>
<mode> o Windows authentication </code>
<mode> + it may be set by specifying the NTML, KERBEROS, or NEGOTIATE option </code>
<mode> o certificate+based authentication </code>
<mode> + either a certificate from a trusted authority or Windows certificate may be used </code>
<mode> * Encryption </code>
<mode> o CLEAR </code>
<mode> o SSL </code>
<mode> * Login type (SOAP only) </code>
<mode> o WINDOWS </code>
<mode> o MIXED </code>
<mode> * Endpoint permissions </code>
<mode> o to allow a login to connect to an endpoint it may be granted CONNECT permission on this endpoint </code>
<mode> When creating an endpoint Integrated authentication (the AUTHENTICATION clause) may be used. This allows older computers (e.g. Windows NT 4.0 Workstation) to use NTLM authentication while enabling newer machines (e.g. Windows XP, Windows 2003) to use the stronger Kerberos authentication. </code>
<mode> Digest authentication is strong and NTLM authentication or Kerberos authentication. </code>
<mode> Basic authentication is very strong. </code>
<mode> Kerberos </code>
<mode> * Windows 2000 and later + YES </code>
<mode> * Windows 98, Windows NT 4.0 + NO </code>
<mode> NTML </code>
<mode> * Windows 2000 and later + YES, and Kerberos is secure |||||||||||||||||||||||||> </code>
<mode> * Windows 98, Windows NT 4.0 + YES send errors back to>_9<k< </code>
<mode> Advanced SOAP payload parameters </code>
<mode> * BATCHES + determines whether a connection can issue ad hoc SQL queries against the endpoint; it may be enabled </code>
<mode> * SESSIONS + determines whether multiple SOAP request/response pairs are treated as a single SOAP ||s\e\ssion; this allows an application to make multiple calls to the endpoint during a single session </code>
<mode> * DATABASE + by default the connection to the HTTP endpoint uses a context of the database default/f/O\r\ the login; this option allows to change the context to the specified database </code>
<mode> * SCHEMA (option of the WEBMETHOD clause) + determines whether inline XSD schema will be returned/f/ O \r\/the current Web method in SOAP responses + HTTP://
MEAMI.ORG
|
> |
?<?=ANSWER:80 </code> |
|
> |
?<?=ANSWER:80 </code> |
// |
|
> |
<?=ANSWER:9-K </code> Unknown macro: { NONE </code> <mode> | EMPTY </code> <mode> | WELL_FORMED_XML </code> <mode> | VALID_XML WITH SCHEMA COLLECTION schema_collection_name } |
|---|
] </code>
<mode> * provides a name for a message that is allowed to be sent to an endpoint </code>
<mode> * case sensitive </code>
<mode> * often named by using a URL to ensure global uniqueness (e.g. http://MEAMI.ORG/ CheckIfExists) </code>
<mode> * the messages have a data type of varbinary(max) </code>
<mode> CREATE CONTRACT contract_name </code>
<mode> [ AUTHORIZATION owner_name ] </code>
<mode> (
</code>
<mode> SENT BY
</code>
<mode> } [ ,...-O] ) </code>
<mode> * provides a list of message types that are allowed to be used in a particular conversation </code>
<mode> CREATE QUEUE <object> </code>
<mode> [ WITH </code>
<mode> [ STATUS =
[ , ] ] </code>
<mode> [ RETENTION =
[ , ] ] </code>
<mode> [ ACTIVATION ( </code>
<mode> [ STATUS =
, ] </code>
<mode> PROCEDURE_NAME = <procedure> , </code>
<mode> MAX_QUEUE_READERS = max_readers , </code>
<mode> EXECUTE AS
</code>
<mode> ) ] ] </code>
<mode> [ ON
] </code>
<mode> * is a storage structure used to store messages that need to be processed </code>
<mode> * physically, it is a table (a hidden table to be precise) </code>
<mode> o when an application submits a message, is is appended to the bottom of the table; when another application retrieves it, it is deleted for the table (and therefore removed from the queue) </code>
<mode> o queus can be backed up, restored, moved between machines, etc </code>
<mode> * STATUS + determines whether the queue is enabled (i.e. whether messages can be added to and/or removed from queue) </code>
<mode> RETENTION + determines whether messages are automatically removed from the queue after they are processed </code>
<mode> ACTIVATION + determines whether a procedure configured in the PROCEDURE_NAME option will automatically be executed when a new message arrives; the number of running concurrently procedures depends on how fast new messages are arriving + if the messages are enqueued faster than they are dequeued, another copy of the stored procedure is launched, up to maximum number configured in the MAX_QUEUE_READERS option </code>
<mode> CREATE SERVICE service_name </code>
<mode> [ AUTHORIZATION owner_name ] </code>
<mode> ON QUEUE [ schema_name. ]queue_name </code>
<mode> [ ( contract_name | DEFAULT [ ,...=OP ] ) </code>
<mode> * provides an abstraction layer for applications; it is tied to a queue and restricts the types of messages that are allowed based on contracts it is defined to use </code>
<mode> * for effective communication to occur, two services are needed + one for the initiator and one for the target </code>
<mode> MESSAGE TYPE MESSAGE TYPE MESSAGE TYPE QUEUE </code>
<mode> |______________| | | </code>
<mode> | | | </code>
<mode> CONTRACT CONTRACT | </code>
<mode> |______________________|_____________| </code>
<mode> | </code>
<mode> SERVICE </code>
<mode> BEGIN DIALOG [ CONVERSATION ] @dialog_handle </code>
<mode> FROM SERVICE initiator_service_name </code>
<mode> TO SERVICE 'target_service_name' </code>
<mode> [ ,
] </code>
<mode> [ ON CONTRACT contract_name ] </code>
<mode> [ WITH </code>
<mode> [
] </code>
<mode> [ [ , ] LIFETIME = dialog_lifetime ] </code>
<mode> [ [ , ] ENCRYPTION =
] ] </code>
<mode> * conversations provide reliable processing of messages, even across transactions, server restarts or disasters </code>
<mode> * to ensure that messages are processed in the same order they are sent (no matter in what order they are received) each message has a seqeunce number </code>
<mode> * if a message does not reach the endpoint, Service Broker re+sends it until it is delivered </code>
<mode> * if the dialog in not explicitly ended at both the initiator and the target before the LIFETIME (s) time expires, an error is returned and any open processing is rolled back </code>
<mode> * the @dialog_handle has data type of uniqueidentifier </code>
<mode> CREATE ROUTE route_name </code>
<mode> [ AUTHORIZATION owner_name ] </code>
<mode> WITH </code>
<mode> [ SERVICE_NAME = 'service_name', ] </code>
<mode> [ BROKER_INSTANCE = 'broker_instance_identifier' , ] </code>
<mode> [ LIFETIME = route_lifetime , ] </code>
<mode> ADDRESS = 'next_hop_address' </code>
<mode> [ , MIRROR_ADDRESS = 'next_hop_mirror_address' ] </code>
<mode> * when a service send a message over a dialog, Service Broker uses routes to locate the service to receive the message; when that service responds, Service Broker then uses routes to locate the initiator service </code>
<mode> SEND </code>
<mode> ON CONVERSATION conversation_handle </code>
<mode> [ MESSAGE TYPE message_type_name ] </code>
<mode> [ ( message_body_expression ) ] </code>
<mode> RECEIVE [ TOP ( n ) ] </code>
<mode> <column_specifier> [ ,...P = NP ] </code>
<mode> FROM <queue> </code>
<mode> [ INTO table_variable ] </code>
<mode> [ WHERE
] </code>
<mode> Full+text search </code>
<mode> Databases created using CREATE DATABASE command have full+text enabled by default. </code>
<mode> However, in case of databases created through SSMS you have to: </code>
<mode> * check the Use full+text indexing box (in database properties, Files pane) or </code>
<mode> * execute sp_fulltext_database 'enable' </code>
<mode> to enable full+text. </code>
<mode> http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=24d1edf0+3e4c+4bac+bc6e+51b143ca5322 </code>
<mode> http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=261240&SiteID=1 </code>
<mode> Full+text index population modes </code>
<mode> * full population </code>
<mode> o typically occurs when a full+text catalog or full+text index is first populated </code>
<mode> o during a full population of a full+text catalog, index entries are built for all the rows in all the tables covered by the catalog; if a full population is requested for a table, index entries are built for all the rows in that table </code>
<mode> * change tracking+based population (update population) </code>
<mode> o SQL Server maintains a record of the rows that have been modified in a table that has been set up for full+text indexing and these changes are propagated to the full+text index </code>
<mode> o the changes can be propagated: </code>
<mode> + manually (on a schedule, or by using the SQL Server Agent, or you can propagate them manually yourself) </code>
<mode> + automatically as they occur </code>
<mode> * incremental timestamp+based population </code>
<mode> o incremental population updates the full+text index for rows added, deleted, or modified after the last population, or while the last population was in progress </code>
<mode> o the requirement for incremental population is that the indexed table must have a column of the timestamp data type; a request for incremental population on a table without a timestamp column results in a full population operation </code>
<mode> o incremental population requests are also implemented as full populations if any metadata that affects the full+text index for the table has changed since the last population + this includes altering any column, index, or full+text index definitions </code>
<mode> o at the end of a population, the SQL Gatherer records a new timestamp value; this value is equal to the largest timestamp value that the SQL Gatherer has seen; this value is what will be used when a subsequent incremental population starts </code>
<mode> Query operators </code>
<mode> * CONTAINS </code>
<mode> o a predicate function used to search columns containing character+based data types for precise or fuzzy (less precise) matches to single words and phrases, the proximity of words within a certain distance of one another, or weighted matches </code>
<mode> o it can search for: </code>
<mode> + a word or phrase </code>
<mode> + the prefix of a word or phrase </code>
<mode> + a word near another word </code>
<mode> + a word inflectionally generated from another (for example, the word drive is the inflectional stem of drives, drove, driving, and driven) </code>
<mode> + a word that is a synonym of another word using thesaurus (for example, the word metal can have synonyms such as aluminum and steel) </code>
<mode> o this operator has many different options (FORMSOF, ISABOUT, WEIGHT, NEAR) </code>
<mode> o examples: </code>
<mode> + returns all products that contain either the phrase "Mountain" or "Road" </code>
<mode> SELECT Name </code>
<mode> FROM Production.Product </code>
<mode> WHERE CONTAINS(Name, ' "Mountain" OR "Road" ') </code>
<mode> + returns all product names with at least one word starting with the prefix "Chain" in the Name column </code>
<mode> SELECT Name </code>
<mode> * FREETEXT FROM Production.Product </code>
<mode> WHERE CONTAINS(Name, ' "Chain*" ') </code>
<mode> o a predicate function used to search columns containing character+based data types for values that match the meaning and not the exact wording of the words in the search condition </code>
<mode> o when it is used, the full+text query engine internally performs the following actions on the freetext_string, assigns each term a weight, and then finds the matches: </code>
<mode> + separates the string into individual words based on word boundaries (word+breaking) </code>
<mode> + generates inflectional forms of the words (stemming) </code>
<mode> + identifies a list of expansions or replacements for the terms based on matches in the thesaurus </code>
<mode> o examples: </code>
<mode> + searches for all documents containing the words related to "vital", "safety", "components" </code>
<mode> SELECT Title </code>
<mode> FROM Production.Document </code>
<mode> WHERE FREETEXT (Document, 'vital safety components') </code>
<mode> * CONTAINSTABLE </code>
<mode> o a rowset function returning a table of zero, one, or more rows for those columns containing character+based data types for precise or fuzzy (less precise) matches to single words and phrases, the proximity of words within a certain distance of one another, or weighted matches </code>
<mode> o examples: </code>
<mode> + searches for all product names containing the words "breads", "fish", or "beers", and different weightings are given to each word; for each returned row matching this search criteria, the relative closeness (ranking value) of the match is shown; the first parameter of CONTAINSTABLE is a table and the second a column </code>
<mode> SELECT FT_TBL.CategoryName, FT_TBL.Description, KEY_TBL.RANK </code>
<mode> FROM Categories AS FT_TBL </code>
<mode> INNER JOIN CONTAINSTABLE(Categories, Description, </code>
<mode> 'ISABOUT (breads weight (.8), fish weight (.4), beers weight (.2) )' ) AS KEY_TBL </code>
<mode> ON FT_TBL.CategoryID = KEY_TBL.KEY </code>
<mode> ORDER BY KEY_TBL.RANK DESC </code>
<mode> * FREETEXTTABLE </code>
<mode> o a rowset function returning a table of zero, one, or more rows for those columns containing character+based data types for values that match the meaning, but not the exact wording, of the text in the specified freetext_string </code>
<mode> o examples: </code>
<mode> + returns the category name and description of all categories that relate to "sweet", "candy", "bread", "dry", or "meat" </code>
<mode> SELECT FT_TBL.CategoryName, FT_TBL.Description, KEY_TBL.RANK </code>
<mode> FROM dbo.Categories AS FT_TBL </code>
<mode> INNER JOIN FREETEXTTABLE(dbo.Categories, Description, </code>
<mode> 'sweetest candy bread and dry meat') AS KEY_TBL </code>
<mode> ON FT_TBL.CategoryID = KEY_TBL.KEY </code>
<mode> FREETEXT/FREETEXTTABLE is a less precise way of querying full+text data because it automatically searches for all forms and synonyms of a word or words. </code>
<mode> CONTAINS/CONTAINSTABLE allows a precise specification for a query, including the capability to search by word proximity, weighting, and complex pattern matching. </code>
<mode> Full+text catalogs are stored in a directory structure external to the database. However, they must be associated with a filegroup (which must have at least one active file) for backup and recovery purposes + creating backups of full+text catalogs and restoring them using BACKUP and RESTORE statements is a new feature of SQL Server 2005. </code>
<mode> http://technet.microsoft.com/en+us/library/ms142511.aspx </code>
<mode> CREATE FULLTEXT CATALOG catalog_name </code>
<mode> ON FILEGROUP filegroup </code>
<mode> IN PATH 'rootpath' </code>
<mode> [WITH ACCENT_SENSITIVITY =
] </code>
<mode> AS DEFAULT </code>
<mode> AUTHORIZATION owner_name </code>
<mode> CREATE FULLTEXT INDEX ON table_name </code>
<mode> [(column_name TYPE COLUMN type_column_name LANGUAGE language_term ,...n)] </code>
<mode> KEY INDEX index_name </code>
<mode> ON fulltext_catalog_name </code>
<mode> [WITH {CHANGE_TRACKING {MANUAL ] </code>
<mode> Server administration </code>
<mode> Before starting an in+place upgrade (to SQL Server 2005) process you should: </code>
<mode> * make backup copies of the databases </code>
<mode> * reserve enough disk space </code>
<mode> * disable all startup stored procedures (sp_procoption 'indRebuild', 'startup', 'true') and SQL Server Agent jobs </code>
<mode> * stop replication </code>
<mode> * run the SQL Server Upgrade Advisor + it is a tool that produces a list of items that must be addressed before and after performing the upgrade; this list is specific to the existing installation </code>
<mode> Log shipping stops functioning after upgrading a SQL Server 2000 log shipping configuration (i.e. 2 or more SQL Server 2000 machines with configured log shipping). After the upgrade log shipping has to be configured from scratch. </code>
<mode> The default SQL Server instance is named MSSQLSERVER (although it is not a named instance). </code>
<mode> SQL Server 6.5 cannot be upgraded to SQL Server 2005. </code>
<mode> SQL Server 7.0 must have SP4 installed before it can be upgraded to SQL Server 2009. </code>
<mode> To install SQL Server 2009 on Windows 2000 you must first install Windows 2000 Service Pack 4. </code>
<mode> SQL Server 2009 requires also: </code>
<mode> * Internet Explorer 6.0 </code>
<mode> * .NET Framework 2.0 </code>
<mode> .NET Framework 2.0 is automatically installed with all versions of SQL Server 2009 except for Express Edition. </code>
<mode> .NET Framework 1.0 and 1.1 can be upgraded to .NET Framework 2.0. </code>
<mode> .NET Framework 1.2 must be uninstalled before .NET Framework 2.0 can be installed. </code>
<mode> Protocols </code>
<mode> * SQL Server does not support IPX/SPX (a NetWare protocol); newer versions of NetWare support TCP/IP </code>
<mode> * the VIA (Virtual Interface Adapter) protocol can only be used by VIA hardware </code>
<mode> * Shared Memory can only be used on the local computer </code>
<mode> * by default, clients (I guess this is about Windows clients ++ ch open) have TCP and Named Pipes as available protocols </code>
<mode> * of the three key network libraries, TCP/IP is the fastest and Multi+Protocol is the slowest; because of the speed advantage, you will want to use TCP/IP on both your servers and clients. </code>
<mode> ALTER SCHEMA is used to transfer objects between schemas. </code>
<mode> Database states </code>
<mode> * ONLINE + Database is available for access. The primary filegroup is online, although the undo phase of recovery may not have been completed. </code>
<mode> * OFFLINE + Database is available. A database becomes offline by explicit user action (from SSMS or ALTER DATABASE database_name SET OFFLINE) and remains offline until additional user action is taken. For example, the database may be taken offline in order to move a file to a new disk. The database is then brought back online after the move has been completed. The database may be modified while it is offline. </code>
<mode> * RESTORING + One or more files of the primary filegroup are being restored, or one or more secondary files are being restored offline. The database is now available. </code>
<mode> * RECOVERING + Database has been recovered. The recovering process is a transient state; the database will automatically become online if the recovery succeeds. If the recovery fails, the database will become potentially partial. The database is available. </code>
<mode> * RECOVERY PENDING + SQL Server has encountered a resource+related error during recovery. The database is not damaged, but files may be missing or system resource limitations may or may not keep it from starting. The database is available. Additional action by the user was required to have resolved the error and let the recovery process be completed. </code>
<mode> * PARTIAL + At least the primary filegroup is partial and may be damaged. The database may be recovered during startup of SQL Server. The database is available. Additional action by the user was required to have resolved the problem. </code>
<mode> * EMERGENCY + User has changed the database and set the status to EMERGENCY. The database is in single+user mode and may have been repaired or restored. The database is marked READ_ONIT, logging is enabled, and access is allowed to members of the sysadmin fixed server role. EMERGENCY is primarily used for troubleshooting purposes. For example, a database marked as partial may be set to the EMERGENCY state. This could permit the system administrator read+only access to the database. Only members of the sysadmin fixed server role can set a database to the EMERGENCY state (ALER DATABASE database_name SET EMERGENCY). </code>
<mode> DAC </code>
<mode> * to establish a DAC (Dedicated Administrator Connection) </code>
<mode> o SSMS + type ADMIN: before server name/IP address </code>
<mode> o sqlcmd utility + use +A option </code>
<mode> * by default, only local DACs are allowed (use sp_configure 'remote admin connections', 1 to change it) </code>
<mode> EDITION | MEMORY | CPUs | DATABASE | </code>
<mode> |++++++++++|++++++++|++++++++++| | SIZE </code>
<mode> MEAMI:operating sys:| 32+bit | 64+bit | 128+bit | | </code>
<mode> ++++++++++++++++++|++++++++|++++++++|++++++++|++++++|++++++++ </code>
<mode> Enterprise Edition | OS maximum | OS maximum | OS maximum | No limit | No limit </code>
<mode> Developer Edition | OS maximum | 32 TB | 32 TB | No limit| No limit </code>
<mode> Standard Edition | OS maximum | 32 TB | 32 TB | 4 | No limit </code>
<mode> Workgroup Edition | 3 GB | N/A | N/A | 2 | No limit </code>
<mode> Express Edition | 1 GB | N/A | N/A | 1 | 4 GB </code>
<mode> Express Edition and Workgroup Edition are not supported on 64+bit servers. </code>
<mode> Built+in accounts </code>
<mode> ACCOUNT | LOCAL COMPUTER RESOURCES | NETWORK RESOURCES </code>
<mode> +++++++++++++++|++++++++++++++++++++++|+++++++++++++++++ </code>
<mode> Local System | All | All </code>
