MediaWiki API result

This is the HTML representation of the JSON format. HTML is good for debugging, but is unsuitable for application use.

Specify the format parameter to change the output format. To see the non-HTML representation of the JSON format, set format=json.

See the complete documentation, or the API help for more information.

{
    "batchcomplete": "",
    "continue": {
        "gapcontinue": "Reduce",
        "continue": "gapcontinue||"
    },
    "warnings": {
        "main": {
            "*": "Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/postorius/lists/mediawiki-api-announce.lists.wikimedia.org/> for notice of API deprecations and breaking changes."
        },
        "revisions": {
            "*": "Because \"rvslots\" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used."
        }
    },
    "query": {
        "pages": {
            "1161": {
                "pageid": 1161,
                "ns": 0,
                "title": "Readability",
                "revisions": [
                    {
                        "contentformat": "text/x-wiki",
                        "contentmodel": "wikitext",
                        "*": "Maintaining readability of APL can take a special effort. It is easy to write very dense code, and the mathematical look of APL can encourage usage of single-letter names. Since [[Phil Abrams]] used the term at the [[APL '73]] conference,<ref>Abrams, Phil. ''Program Writing, Rewriting and Style''. APL Conference 73. Canadian Printco Limited. 1973.</ref> APLers have traditionally used ''pornography'' to describe code that is hard to read, or uses unusual constructs. [[Alan Perlis]] countered that ''But as we all know, being people of the world, pornography thrives!''<ref>Perlis, Alan. [https://www.jsoftware.com/papers/perlis78.htm Almost Perfect Artifacts Improve only in Small Ways: APL is more French than English]. [[APL '78]].</ref>\n\n== Causes and mitigation ==\n[[Code golf]] often results in pornographic code, as does the practice of cramming a whole algorithm into a single line, forming a [[one-liner]]. When computer memory was very limited, such code golf was often a necessary evil.\n\nWith the advent of [[dfn]]s, it became possible to define a full function or operator on a single line. Since APL [[comment]]s begin at the comment symbol (<syntaxhighlight lang=apl inline>\u235d</syntaxhighlight>) and continue until the end of the line, it is impossible to comment a one-liner dfn except outside the source. This, coupled with the inability of a [[wikipedia:debugger|debugger]] to meaningfully trace through a one-liner (unless it is capable of [[primitive]]-by-primitive tracing), constitute hardships for a human reader that attempts to read such code.\n\nAPL containing user defined names is generally not statically parseable, as the [[name class]], and thus the syntactic role, of such names isn't known until runtime.<ref>[[John Scholes|Scholes, John]]. [https://dfns.dyalog.com/n_kk.htm Kind Koloring of d-fnop named \u2375.] Dfns workspace. [[Dyalog Ltd.]]</ref>\n\nMuch can be done to improve readability of code, and of APL in particular. Breaking code up into meaningful statements, avoiding one-liners, using descriptive names, and supplying plentiful comments are a good start. Adherence to a well-defined style guide can also help. [[Ad\u00e1m Brudzewsky#Publications|Ad\u00e1m Brudzewsky's style guide]] is an example of such a style guide.\n\n== Examples ==\n=== Gilman & Rose ===\nIn [[Books#APL_.E2.80.95_An_Interactive_Approach|APL \u2015 An Interactive Approach]], the authors describe the following code, which computes the correlation coefficient, as \u201calmost pornographic\u201d:\n:<syntaxhighlight lang=apl inline>r\u2190(+/x\u00d7y)\u00f7((+/(x\u2190x-(+/x)\u00f7\u2374x)*2)\u00d7+/(y\u2190y-(+/y)\u00f7\u2374y)*2)\u00d7.5</syntaxhighlight>\nBy splitting the expression intro even a moderate number of pieces, a symmetry is revealed:\n<syntaxhighlight lang=apl>yVar\u2190+/(y-(+/y)\u00f7\u2374y)*2\nxVar\u2190+/(x-(+/x)\u00f7\u2374x)*2\nr\u2190(+/x\u00d7y)\u00f7(xVar\u00d7yVar)\u00d70.5</syntaxhighlight>\nThis also avoids reusing variable names, and thus ensures that the code can be rerun from any point. The chosen additional variable names are still short, but quite indicative of what they signify ([[wikipedia:variance|variance]]). Finally, the <syntaxhighlight lang=apl inline>.5</syntaxhighlight> is expanded to <syntaxhighlight lang=apl inline>0.5</syntaxhighlight> which helps to clarify that this is a decimal number and not an [[inner product]].\n\nA more modern approach breaks out the symmetry into a utility function [[train]], and uses [[leading axis theory]] combined with [[operator]]s and reordering of terms to avoid parentheses (which would otherwise require a mental stack to understand). Finally, the correlation coefficient is defined as a stand-alone function, using [[inner product]] to combine [[sum]]mation with [[multiply|multiplication]]\n<syntaxhighlight lang=apl>Var\u2190+/2*\u2368\u22a2-+\u233f\u00f7\u2262\nR\u21902\u00d7+.\u00d7\u00f7\u00d7\u2365Var\nr\u2190x R y</syntaxhighlight>\nNote that <syntaxhighlight lang=apl inline>+\u233f\u00f7\u2262</syntaxhighlight> is an [[idiom]] (common phrase) and is read as ''average'' by even moderately experienced APL programmers.\n\n=== IBM ===\nThe [[idiom]] list included with [[APL2]] includes the following entry:<ref>Cason, Stan. [ftp://ftp.software.ibm.com/ps/products/apl2/info/APL2IDIOMS.pdf#page=3 APL2 IDIOMS Library], Assignment Algorithms. IBM.</ref>\n:{| style=width:100%\n|<syntaxhighlight lang=apl inline>X\u2190'line1',0\u2374Y\u2190'line2'</syntaxhighlight>||<syntaxhighlight lang=apl inline>\u235d Pornography. Combining two lines into one.</syntaxhighlight>\n|}\nThis was once a common technique before, even though it is prone to fail in where the value to the left of <syntaxhighlight lang=apl inline>,0\u2374</syntaxhighlight> isn't a vector, for example in the following example where <syntaxhighlight lang=apl inline>X</syntaxhighlight> becomes a 1-element [[vector]] instead of the intended [[scalar]]:\n<syntaxhighlight lang=apl>\n      X\u2190'l',0\u2374Y\u2190'line2'\n      Y\u2218.=X\n1\n0\n0\n0\n0\n</syntaxhighlight>\nWith the addition of [[Left]] (<syntaxhighlight lang=apl inline>\u22a3</syntaxhighlight>) to the language, this type of hack became became entirely obsolete:\n:<syntaxhighlight lang=apl inline>X\u2190'line1' \u22a3 Y\u2190'line2'</syntaxhighlight>\nThe primitive leaves its left argument unmodified:\n<syntaxhighlight lang=apl>\n      X\u2190'l' \u22a3 Y\u2190'line2'\n      Y\u2218.=X\n1 0 0 0 0\n</syntaxhighlight>\nThe Diamond [[statement separator]] (<syntaxhighlight lang=apl inline>\u22c4</syntaxhighlight>) provides an alternative means of inlining multiple statements:\n:<syntaxhighlight lang=apl inline>Y\u2190'line2' \u22c4 X\u2190'line1'</syntaxhighlight>\nNote that in all the above, <syntaxhighlight lang=apl inline>Y</syntaxhighlight> is assigned first.\n\n=== Morten Kromberg ===\n[[Morten Kromberg]] asked one of his colleagues to \u201cPlease avoid this kind of pornography:\u201d\n:<syntaxhighlight lang=apl inline>\nns(\u234econtainer.\u2395NS)\u2190\u236c\n</syntaxhighlight>\nAvoiding the unusual [[modified assignment]] (using the 2-[[train]] <syntaxhighlight lang=apl inline>\u234e\u2395NS</syntaxhighlight> as modifying function) helps:\n:<syntaxhighlight lang=apl inline>\nns\u2190ns container.(\u234e\u2395NS) \u236c\n</syntaxhighlight>\nFinally, splitting the 2-train apart makes it even clearer:\n:<syntaxhighlight lang=apl inline>\nns\u2190\u234ens container.\u2395NS \u236c\n</syntaxhighlight>\nA new [[namespace]], with the original value of <syntaxhighlight lang=apl inline>ns</syntaxhighlight> as name, is created inside <syntaxhighlight lang=apl inline>container</syntaxhighlight> and the character representation <syntaxhighlight lang=apl inline>'#.container.ns'</syntaxhighlight> is returned from <syntaxhighlight lang=apl inline>\u2395NS</syntaxhighlight> to <syntaxhighlight lang=apl inline>\u234e</syntaxhighlight> which evaluates the name to a reference, that in turn replaces the previous value of <syntaxhighlight lang=apl inline>ns</syntaxhighlight>. Note that <syntaxhighlight lang=apl inline>\u2395NS</syntaxhighlight> returns fully qualified namespace path to the newly created namespace, and thus it doesn't matter in which namespace <syntaxhighlight lang=apl inline>\u234e</syntaxhighlight> is called.\n=== Honeywell ===\n[[Honeywell]] <ref>Honeywell. [http://www.softwarepreservation.org/projects/apl/Books/198512_Multics%20APL%20Users%20Guide_AK95-02.pdf#page=106 Multics APL User's Guide] (AK95-02), 3-16. December 1985.</ref> used a more specific definition:\n:In APL, <u>pornography</u> is defined informally as the dependence upon undefined evaluation order for the successful or correct evaluation of an APL statement.\nThis refers to things like\n<syntaxhighlight lang=apl>\na\u21904\n(a\u21903)\u00d7a\n</syntaxhighlight>\nwhere it is undefined whether the initial value for <syntaxhighlight lang=apl inline>a</syntaxhighlight> is used at all in the second line, yielding 12, or whether the second assignment is done before [[times]] gets its right argument, and thus the result is 9.\n\nSimilarly, in\n<syntaxhighlight lang=apl>\ni\u21902\n(2 1\u237410 20)[i;i\u21901]\n</syntaxhighlight>\nthe evaluation order of the statements in the [[bracket indexing]] is undefined. If <syntaxhighlight lang=apl inline>i</syntaxhighlight> is evaluated before <syntaxhighlight lang=apl inline>i\u21901</syntaxhighlight> then the result is 20, otherwise it is 10.\n\nThe Multics APL manual goes on to use the terms ''monstrosity'' and ''eyesore'' for code published in an APL newsletter, such as\n:<syntaxhighlight lang=apl inline>Z[B+(C\u2227X\u220aD)/\u2373\u2374X;]+(24p' Y9  X9 ')[(C\u2190(-\u2260\\''''=X)\u2227A\u2264\u2374D)/A\u2190(D\u2190'\u2375\u237a')\u2373X;]</syntaxhighlight>\nThe manual suggests that this code should be split into the following expressions:\n<syntaxhighlight lang=apl>\nD\u2190'\u2375\u237a'\nA\u2190D\u2373X\nC\u2190(-\u2260\\''''=X)\u2227A\u2264\u2374D\nB\u2190(C\u2227X\u220aD)/\u2373\u2374X\nZ[B;]\u2190(24p' Y9  X9 ')[C/A;]\n</syntaxhighlight>\n\n== See also ==\n* [[Semantic density]]\n* [[Function-operator overloading]]\n== References ==\n<references/>\n{{APL syntax}}[[Category:Culture]]"
                    }
                ]
            },
            "962": {
                "pageid": 962,
                "ns": 0,
                "title": "Reciprocal",
                "revisions": [
                    {
                        "contentformat": "text/x-wiki",
                        "contentmodel": "wikitext",
                        "*": "{{Built-in|Reciprocal|\u00f7}} is a [[monadic]] [[scalar function]] which gives the [[wikipedia:Multiplicative inverse|multiplicative inverse]] of a real or [[complex]] number. Reciprocal shares the [[glyph]] <syntaxhighlight lang=apl inline>\u00f7</syntaxhighlight> with the dyadic arithmetic function [[Divide]].\n\n== Examples ==\n<syntaxhighlight lang=apl>\n      \u00f71 2 3 4 5\n1 0.5 0.3333333333 0.25 0.2\n \n      \u00f7\u00af2 0.5 1J2\n\u00af0.5 2 0.2J\u00af0.4\n\n      \u00f70\nDOMAIN ERROR: Divide by zero\n \u00f70                         \n \u2227\n \n      \u2395DIV\u21901  \u235d this sets division by 0 to always return 0\n      \u00f70\n0\n</syntaxhighlight>\n\n== Properties ==\n\nThe reciprocal of any real or complex number is equal to 1 [[divide]]d by that number. Therefore the monadic <syntaxhighlight lang=apl inline>\u00f7</syntaxhighlight> can be seen as dyadic <syntaxhighlight lang=apl inline>\u00f7</syntaxhighlight> with default left argument of 1. This applies even to the reciprocal of 0; <syntaxhighlight lang=apl inline>\u00f70</syntaxhighlight> and <syntaxhighlight lang=apl inline>1\u00f70</syntaxhighlight> show identical behavior for both <syntaxhighlight lang=apl inline>\u2395DIV\u21900</syntaxhighlight> (raising [[DOMAIN ERROR]]) and <syntaxhighlight lang=apl inline>\u2395DIV\u21901</syntaxhighlight> (returning 0).\n\n<syntaxhighlight lang=apl>\n      \u00f71 2 3 4 5\n1 0.5 0.3333333333 0.25 0.2\n\n      1\u00f71 2 3 4 5\n1 0.5 0.3333333333 0.25 0.2\n</syntaxhighlight>\n\nFor any non-zero real or complex numbers, the [[signum]] of reciprocal is equal to the [[conjugate]] of signum, and the [[magnitude]] of reciprocal is equal to the reciprocal of magnitude.\n\n<syntaxhighlight lang=apl>\n      (\u00d7\u2218\u00f7 \u2261 +\u2218\u00d7)1 2 3 \u00af2 0.5 1J2\n1\n\n      (|\u2218\u00f7 \u2261 \u00f7\u2218|)1 2 3 \u00af2 0.5 1J2\n1\n</syntaxhighlight>{{Works in|[[Dyalog APL]]}}\n\n== See also ==\n* [[Times]]\n* [[Negate]]\n* [[Root]]\n== External links ==\n\n=== Documentation ===\n\n* [https://help.dyalog.com/17.1/#Language/Primitive%20Functions/Reciprocal.htm Dyalog]\n* [https://www.jsoftware.com/help/dictionary/d130.htm J Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/percent NuVoc]\n* [https://mlochbaum.github.io/BQN/doc/arithmetic.html#basic-arithmetic BQN]\n{{APL built-ins}}[[Category:Primitive functions]][[Category:Scalar monadic functions]]"
                    }
                ]
            }
        }
    }
}