comparison website/src/manual.html.luan @ 1812:f44dcb3fedf7

docs - add code block
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 10 Jun 2024 14:41:48 -0600
parents ba43135bb98d
children fa0e73119b7c
comparison
equal deleted inserted replaced
1811:55d89a183c82 1812:f44dcb3fedf7
244 the access to a metamethod does not invoke other metamethods. 244 the access to a metamethod does not invoke other metamethods.
245 You can emulate how Luan queries a metamethod for an object <code>obj</code> 245 You can emulate how Luan queries a metamethod for an object <code>obj</code>
246 with the following code: 246 with the following code:
247 </p> 247 </p>
248 248
249 <pre> 249 <code block>
250 raw_get(get_metatable(obj) or {}, "__" .. event_name) 250 raw_get(get_metatable(obj) or {}, "__" .. event_name)
251 </pre> 251 </code>
252 252
253 <p> 253 <p>
254 Here are the events: 254 Here are the events:
255 </p> 255 </p>
256 256
487 <p> 487 <p>
488 The following <em>keywords</em> are reserved 488 The following <em>keywords</em> are reserved
489 and cannot be used as names: 489 and cannot be used as names:
490 </p> 490 </p>
491 491
492 <p keywords> 492 <p list=keywords>
493 <span>and</span> 493 <span>and</span>
494 <span>break</span> 494 <span>break</span>
495 <span>catch</span> 495 <span>catch</span>
496 <span>continue</span> 496 <span>continue</span>
497 <span>do</span> 497 <span>do</span>
530 530
531 <p> 531 <p>
532 The following strings denote other tokens: 532 The following strings denote other tokens:
533 </p> 533 </p>
534 534
535 <pre> 535 <p list=tokens>
536 + - * / % ^ # 536 <span>+</span>
537 &amp; ~ | &lt;&lt; &gt;&gt; // 537 <span>-</span>
538 == ~= &lt;= &gt;= &lt; &gt; = 538 <span>*</span>
539 ( ) { } [ ] :: 539 <span>/</span>
540 ; : , . .. ... 540 <span>//</span>
541 </pre> 541 <span>%</span>
542 <span>^</span>
543 <span>#</span>
544 <span>&amp;</span>
545 <span>~</span>
546 <span>|</span>
547 <span>==</span>
548 <span>~=</span>
549 <span>&lt;=</span>
550 <span>&gt;=</span>
551 <span>&lt;</span>
552 <span>&gt;</span>
553 <span>=</span>
554 <span>(</span>
555 <span>)</span>
556 <span>{</span>
557 <span>}</span>
558 <span>[</span>
559 <span>]</span>
560 <span>;</span>
561 <span>,</span>
562 <span>.</span>
563 <span>..</span>
564 <span>...</span>
565 <span>%&gt;</span>
566 <span>&lt;%</span>
567 <span>&lt;%=</span>
568 </p>
542 569
543 <p> 570 <p>
544 <em>Literal strings</em> 571 <em>Literal strings</em>
545 can be delimited by matching single or double quotes, 572 can be delimited by matching single or double quotes,
546 and can contain the following C-like escape sequences: 573 and can contain the following C-like escape sequences:
618 the newline is not included in the string. 645 the newline is not included in the string.
619 As an example 646 As an example
620 the five literal strings below denote the same string: 647 the five literal strings below denote the same string:
621 </p> 648 </p>
622 649
623 <pre> 650 <code block>
624 a = 'alo\n123"' 651 a = 'alo\n123"'
625 a = "alo\n123\"" 652 a = "alo\n123\""
626 a = '\97lo\10\04923"' 653 a = '\97lo\10\04923"'
627 a = [[alo 654 a = [[alo
628 123"]] 655 123"]]
629 a = [==[ 656 a = [==[
630 alo 657 alo
631 123"]==] 658 123"]==]
632 </pre> 659 </code>
633 660
634 <p> 661 <p>
635 A <em>numerical constant</em> (or <em>numeral</em>) 662 A <em>numerical constant</em> (or <em>numeral</em>)
636 can be written with an optional fractional part 663 can be written with an optional fractional part
637 and an optional decimal exponent, 664 and an optional decimal exponent,
872 The assignment statement first evaluates all its expressions 899 The assignment statement first evaluates all its expressions
873 and only then the assignments are performed. 900 and only then the assignments are performed.
874 Thus the code 901 Thus the code
875 </p> 902 </p>
876 903
877 <pre> 904 <code block>
878 i = 3 905 i = 3
879 i, a[i] = i+1, 20 906 i, a[i] = i+1, 20
880 </pre> 907 </code>
881 908
882 <p> 909 <p>
883 sets <code>a[3]</code> to 20, without affecting <code>a[4]</code> 910 sets <code>a[3]</code> to 20, without affecting <code>a[4]</code>
884 because the <code>i</code> in <code>a[i]</code> is evaluated (to 3) 911 because the <code>i</code> in <code>a[i]</code> is evaluated (to 3)
885 before it is assigned&nbsp;4. 912 before it is assigned&nbsp;4.
886 Similarly, the line 913 Similarly, the line
887 </p> 914 </p>
888 915
889 <pre> 916 <code block>
890 x, y = y, x 917 x, y = y, x
891 </pre> 918 </code>
892 919
893 <p> 920 <p>
894 exchanges the values of <code>x</code> and <code>y</code>, 921 exchanges the values of <code>x</code> and <code>y</code>,
895 and 922 and
896 </p> 923 </p>
897 924
898 <pre> 925 <code block>
899 x, y, z = y, z, x 926 x, y, z = y, z, x
900 </pre> 927 </code>
901 928
902 <p> 929 <p>
903 cyclically permutes the values of <code>x</code>, <code>y</code>, and <code>z</code>. 930 cyclically permutes the values of <code>x</code>, <code>y</code>, and <code>z</code>.
904 </p> 931 </p>
905 932
1018 1045
1019 <p> 1046 <p>
1020 A <b>for</b> statement like 1047 A <b>for</b> statement like
1021 </p> 1048 </p>
1022 1049
1023 <pre> 1050 <code block>
1024 for <em>var_1</em>, &middot;&middot;&middot;, <em>var_n</em> in <em>exp</em> do <em>block</em> end 1051 for <em>var_1</em>, &middot;&middot;&middot;, <em>var_n</em> in <em>exp</em> do <em>block</em> end
1025 </pre> 1052 </code>
1026 1053
1027 <p> 1054 <p>
1028 is equivalent to the code: 1055 is equivalent to the code:
1029 </p> 1056 </p>
1030 1057
1031 <pre> 1058 <code block>
1032 do 1059 do
1033 local <em>f</em> = <em>exp</em> 1060 local <em>f</em> = <em>exp</em>
1034 while true do 1061 while true do
1035 local <em>var_1</em>, &middot;&middot;&middot;, <em>var_n</em> = <em>f</em>() 1062 local <em>var_1</em>, &middot;&middot;&middot;, <em>var_n</em> = <em>f</em>()
1036 if <em>var_1</em> == nil then break end 1063 if <em>var_1</em> == nil then break end
1037 <em>block</em> 1064 <em>block</em>
1038 end 1065 end
1039 end 1066 end
1040 </pre> 1067 </code>
1041 1068
1042 <p> 1069 <p>
1043 Note the following: 1070 Note the following:
1044 </p> 1071 </p>
1045 1072
1107 <p> 1134 <p>
1108 <a href="#logical_ops">Logical expressions</a> can be statements. 1135 <a href="#logical_ops">Logical expressions</a> can be statements.
1109 This is useful in cases like this: 1136 This is useful in cases like this:
1110 </p> 1137 </p>
1111 1138
1112 <pre> 1139 <code block>
1113 x==5 or error "x should be 5" 1140 x==5 or error "x should be 5"
1114 </pre> 1141 </code>
1115 <% 1142 <%
1116 end 1143 end
1117 } 1144 }
1118 local_stmt = { 1145 local_stmt = {
1119 title = "Local Declarations" 1146 title = "Local Declarations"
1150 content = function() 1177 content = function()
1151 %> 1178 %>
1152 <p>Template statements provide the full equivalent of <a href="http://en.wikipedia.org/wiki/JavaServer_Pages">JSP</a> but in a general way. Template statements write to standard output. For example:</p> 1179 <p>Template statements provide the full equivalent of <a href="http://en.wikipedia.org/wiki/JavaServer_Pages">JSP</a> but in a general way. Template statements write to standard output. For example:</p>
1153 </p> 1180 </p>
1154 1181
1155 <pre> 1182 <code block>
1156 local name = "Bob" 1183 local name = "Bob"
1157 %&gt; 1184 %&gt;
1158 Hello &lt;%= name %&gt;! 1185 Hello &lt;%= name %&gt;!
1159 Bye &lt;%= name %&gt;. 1186 Bye &lt;%= name %&gt;.
1160 &lt;% 1187 &lt;%
1161 </pre> 1188 </code>
1162 1189
1163 <p> 1190 <p>
1164 is equivalent to the code: 1191 is equivalent to the code:
1165 </p> 1192 </p>
1166 1193
1167 <pre> 1194 <code block>
1168 local name = "Bob" 1195 local name = "Bob"
1169 require("luan:Io.luan").stdout.write( "Hello ", name , "!\nBye ", name , ".\n" ) 1196 require("luan:Io.luan").stdout.write( "Hello ", name , "!\nBye ", name , ".\n" )
1170 </pre> 1197 </code>
1171 <% 1198 <%
1172 end 1199 end
1173 } 1200 }
1174 } 1201 }
1175 } 1202 }
1539 starting with 1. 1566 starting with 1.
1540 Fields in the other formats do not affect this counting. 1567 Fields in the other formats do not affect this counting.
1541 For example, 1568 For example,
1542 </p> 1569 </p>
1543 1570
1544 <pre> 1571 <code block>
1545 a = { [f(1)] = g; "x", "y"; x = 1, f(x), [30] = 23; 45 } 1572 a = { [f(1)] = g; "x", "y"; x = 1, f(x), [30] = 23; 45 }
1546 </pre> 1573 </code>
1547 1574
1548 <p> 1575 <p>
1549 is equivalent to 1576 is equivalent to
1550 </p> 1577 </p>
1551 1578
1552 <pre> 1579 <code block>
1553 do 1580 do
1554 local t = {} 1581 local t = {}
1555 t[f(1)] = g 1582 t[f(1)] = g
1556 t[1] = "x" -- 1st exp 1583 t[1] = "x" -- 1st exp
1557 t[2] = "y" -- 2nd exp 1584 t[2] = "y" -- 2nd exp
1558 t.x = 1 -- t["x"] = 1 1585 t.x = 1 -- t["x"] = 1
1559 t[3] = f(x) -- 3rd exp 1586 t[3] = f(x) -- 3rd exp
1560 t[30] = 23 1587 t[30] = 23
1561 t[4] = 45 -- 4th exp 1588 t[4] = 45 -- 4th exp
1562 a = t 1589 a = t
1563 end 1590 end
1564 </pre> 1591 </code>
1565 1592
1566 <p> 1593 <p>
1567 The order of the assignments in a constructor is undefined. 1594 The order of the assignments in a constructor is undefined.
1568 (This order would be relevant only when there are repeated keys.) 1595 (This order would be relevant only when there are repeated keys.)
1569 </p> 1596 </p>
1763 <p> 1790 <p>
1764 Then, we have the following mapping from arguments to parameters and 1791 Then, we have the following mapping from arguments to parameters and
1765 to the vararg expression: 1792 to the vararg expression:
1766 </p> 1793 </p>
1767 <pre> 1794 <pre>
1768 CALL PARAMETERS 1795 CALL PARAMETERS
1769 1796
1770 f(3) a=3, b=nil 1797 f(3) a=3, b=nil
1771 f(3, 4) a=3, b=4 1798 f(3, 4) a=3, b=4
1772 f(3, 4, 5) runtime error 1799 f(3, 4, 5) runtime error
1773 f(r(), 10) runtime error 1800 f(r(), 10) runtime error
1793 content = function() 1820 content = function()
1794 %> 1821 %>
1795 <p> 1822 <p>
1796 A block between backticks is run and then whatever was sent to standard output is returned as a string. Examples: 1823 A block between backticks is run and then whatever was sent to standard output is returned as a string. Examples:
1797 </p> 1824 </p>
1798 <pre> 1825 <code block>
1799 local s = `%&gt;1 + 1 = &lt;%=1+1%&gt;&lt;%` 1826 local s = `%&gt;1 + 1 = &lt;%=1+1%&gt;&lt;%`
1800 1827
1801 local s = ` fn(whatever) ` 1828 local s = ` fn(whatever) `
1802 1829
1803 local s = `%&gt; 1830 local s = `%&gt;
1804 ... 1831 ...
1805 &lt;%` 1832 &lt;%`
1806 </pre> 1833 </code>
1807 <p> 1834 <p>
1808 Backticks complement <a href="#template_stmt">template statements</a>. 1835 Backticks complement <a href="#template_stmt">template statements</a>.
1809 </p> 1836 </p>
1810 <% 1837 <%
1811 end 1838 end
1821 The scope of a local variable begins at the first statement after 1848 The scope of a local variable begins at the first statement after
1822 its declaration and lasts until the last non-void statement 1849 its declaration and lasts until the last non-void statement
1823 of the innermost block that includes the declaration. 1850 of the innermost block that includes the declaration.
1824 Consider the following example: 1851 Consider the following example:
1825 </p> 1852 </p>
1826 <pre> 1853 <code block>
1827 x = 10 -- global variable 1854 local x = 10 -- global to module
1828 do -- new block 1855 do -- new block
1829 local x = x -- new 'x', with value 10 1856 local x = x -- new 'x', with value 10
1830 print(x) --&gt; 10 1857 print(x) --&gt; 10
1831 x = x+1 1858 x = x+1
1832 do -- another block 1859 do -- another block
1833 local x = x+1 -- another 'x' 1860 local x = x+1 -- another 'x'
1834 print(x) --&gt; 12 1861 print(x) --&gt; 12
1835 end 1862 end
1836 print(x) --&gt; 11 1863 print(x) --&gt; 11
1837 end 1864 end
1838 print(x) --&gt; 10 (the global one) 1865 print(x) --&gt; 10 (the global one)
1839 </pre> 1866 </code>
1840 1867
1841 <p> 1868 <p>
1842 Notice that, in a declaration like <code>local x = x</code>, 1869 Notice that, in a declaration like <code>local x = x</code>,
1843 the new <code>x</code> being declared is not in scope yet, 1870 the new <code>x</code> being declared is not in scope yet,
1844 and so the second <code>x</code> refers to the outside variable. 1871 and so the second <code>x</code> refers to the outside variable.
1856 <p> 1883 <p>
1857 Notice that each execution of a <b>local</b> statement 1884 Notice that each execution of a <b>local</b> statement
1858 defines new local variables. 1885 defines new local variables.
1859 Consider the following example: 1886 Consider the following example:
1860 </p> 1887 </p>
1861 <pre> 1888
1862 a = {} 1889 <code block>
1863 local x = 20 1890 local a = {}
1864 for i=1,10 do 1891 local x = 20
1865 local y = 0 1892 for i=1,10 do
1866 a[i] = function () y=y+1; return x+y end 1893 local y = 0
1867 end 1894 a[i] = function () y=y+1; return x+y end
1868 </pre> 1895 end
1896 </code>
1869 1897
1870 <p> 1898 <p>
1871 The loop creates ten closures 1899 The loop creates ten closures
1872 (that is, ten instances of the anonymous function). 1900 (that is, ten instances of the anonymous function).
1873 Each of these closures uses a different <code>y</code> variable, 1901 Each of these closures uses a different <code>y</code> variable,
1902 </p> 1930 </p>
1903 <% 1931 <%
1904 end 1932 end
1905 subs = { 1933 subs = {
1906 require = { 1934 require = {
1907 title = "<code>require (mod_uri)</code>" 1935 title = "require (mod_uri)"
1908 content = function() 1936 content = function()
1909 %> 1937 %>
1910 <p> 1938 <p>
1911 Example use: 1939 Example use:
1912 </p> 1940 </p>
1913 <pre> 1941 <code block>
1914 local Table = require "luan:Table.luan" 1942 local Table = require "luan:Table.luan"
1915 </pre> 1943 </code>
1916 1944
1917 <p> 1945 <p>
1918 Could be defined as: 1946 Could be defined as:
1919 </p> 1947 </p>
1920 <pre> 1948 <code block>
1921 local function require(mod_name) 1949 local function require(mod_name)
1922 return <a href="#Package.load">Package.load</a>(mod_name) or <a href="#Luan.error">Luan.error</a>("module '"..mod_name.."' not found") 1950 return <a href="#Package.load">Package.load</a>(mod_name) or <a href="#Luan.error">Luan.error</a>("module '"..mod_name.."' not found")
1923 end 1951 end
1924 </pre> 1952 </code>
1925 1953
1926 <p> 1954 <p>
1927 A special case is: 1955 A special case is:
1928 </p> 1956 </p>
1929 <pre> 1957 <code block>
1930 require "java" 1958 require "java"
1931 </pre> 1959 </code>
1932 1960
1933 <p> 1961 <p>
1934 This enables Java in the current chunk if that chunk has permission to use Java. If the chunk doesn't have permission to use Java, then an error is thrown. 1962 This enables Java in the current chunk if that chunk has permission to use Java. If the chunk doesn't have permission to use Java, then an error is thrown.
1935 </p> 1963 </p>
1936 <% 1964 <%
1943 content = function() 1971 content = function()
1944 %> 1972 %>
1945 <p> 1973 <p>
1946 Include this library by: 1974 Include this library by:
1947 </p> 1975 </p>
1948 <pre> 1976
1949 local Luan = require "luan:Luan.luan" 1977 <code block>
1950 </pre> 1978 local Luan = require "luan:Luan.luan"
1979 </code>
1951 1980
1952 <p> 1981 <p>
1953 The basic library provides basic functions to Luan that don't depend on other libaries. 1982 The basic library provides basic functions to Luan that don't depend on other libaries.
1954 </p> 1983 </p>
1955 <% 1984 <%
1956 end 1985 end
1957 subs = { 1986 subs = {
1958 ["Luan.do_file"] = { 1987 ["Luan.do_file"] = {
1959 title = "<code>Luan.do_file ([uri])</code>" 1988 title = "Luan.do_file ([uri])"
1960 content = function() 1989 content = function()
1961 %> 1990 %>
1962 <p> 1991 <p>
1963 Could be defined as: 1992 Could be defined as:
1964 </p> 1993 </p>
1965 <pre> 1994 <code block>
1966 function Luan.do_file(uri) 1995 function Luan.do_file(uri)
1967 local fn = <a href="#Luan.load_file">Luan.load_file</a>(uri) or <a href="#Luan.error">Luan.error</a>("file '"..uri.."' not found") 1996 local fn = <a href="#Luan.load_file">Luan.load_file</a>(uri) or <a href="#Luan.error">Luan.error</a>("file '"..uri.."' not found")
1968 return fn() 1997 return fn()
1969 end 1998 end
1970 </pre> 1999 </code>
1971 <% 2000 <%
1972 end 2001 end
1973 } 2002 }
1974 ["Luan.error"] = { 2003 ["Luan.error"] = {
1975 title = "<code>Luan.error (message)</code>" 2004 title = "Luan.error (message)"
1976 content = function() 2005 content = function()
1977 %> 2006 %>
1978 <p> 2007 <p>
1979 Throws an error containing the message. 2008 Throws an error containing the message.
1980 </p> 2009 </p>
1981 2010
1982 <p> 2011 <p>
1983 Could be defined as: 2012 Could be defined as:
1984 </p> 2013 </p>
1985 <pre> 2014 <code block>
1986 function Luan.error(message) 2015 function Luan.error(message)
1987 <a href="#Luan.new_error">Luan.new_error</a>(message).throw() 2016 <a href="#Luan.new_error">Luan.new_error</a>(message).throw()
1988 end 2017 end
1989 </pre> 2018 </code>
1990 <% 2019 <%
1991 end 2020 end
1992 } 2021 }
1993 ["Luan.eval"] = { 2022 ["Luan.eval"] = {
1994 title = "<code>Luan.eval (text [, source_name [, env]])</code>" 2023 title = "Luan.eval (text [, source_name [, env]])"
1995 content = function() 2024 content = function()
1996 %> 2025 %>
1997 <p> 2026 <p>
1998 Evaluates <code>text</code> as a Luan expression. 2027 Evaluates <code>text</code> as a Luan expression.
1999 </p> 2028 </p>
2000 2029
2001 <p> 2030 <p>
2002 Could be defined as: 2031 Could be defined as:
2003 </p> 2032 </p>
2004 <pre> 2033 <code block>
2005 function Luan.eval(text,source_name, env) 2034 function Luan.eval(text,source_name, env)
2006 return <a href="#Luan.load">Luan.load</a>( "return "..text, source_name or "eval", env )() 2035 return <a href="#Luan.load">Luan.load</a>( "return "..text, source_name or "eval", env )()
2007 end 2036 end
2008 </pre> 2037 </code>
2009 <% 2038 <%
2010 end 2039 end
2011 } 2040 }
2012 ["Luan.get_metatable"] = { 2041 ["Luan.get_metatable"] = {
2013 title = "<code>Luan.get_metatable (table)</code>" 2042 title = "Luan.get_metatable (table)"
2014 content = function() 2043 content = function()
2015 %> 2044 %>
2016 <p> 2045 <p>
2017 If <code>table</code> does not have a metatable, returns <b>nil</b>. 2046 If <code>table</code> does not have a metatable, returns <b>nil</b>.
2018 Otherwise, 2047 Otherwise,
2022 </p> 2051 </p>
2023 <% 2052 <%
2024 end 2053 end
2025 } 2054 }
2026 ["Luan.hash_code"] = { 2055 ["Luan.hash_code"] = {
2027 title = "<code>Luan.hash_code (v)</code>" 2056 title = "Luan.hash_code (v)"
2028 content = function() 2057 content = function()
2029 %> 2058 %>
2030 <p> 2059 <p>
2031 Returns the hash code of <code>v</code>. 2060 Returns the hash code of <code>v</code>.
2032 </p> 2061 </p>
2033 <% 2062 <%
2034 end 2063 end
2035 } 2064 }
2036 ["Luan.ipairs"] = { 2065 ["Luan.ipairs"] = {
2037 title = "<code>Luan.ipairs (t)</code>" 2066 title = "Luan.ipairs (t)"
2038 content = function() 2067 content = function()
2039 %> 2068 %>
2040 <p> 2069 <p>
2041 Returns an iterator function 2070 Returns an iterator function
2042 so that the construction 2071 so that the construction
2052 </p> 2081 </p>
2053 2082
2054 <p> 2083 <p>
2055 Could be defined as: 2084 Could be defined as:
2056 </p> 2085 </p>
2057 <pre> 2086 <code block>
2058 function Luan.ipairs(t) 2087 function Luan.ipairs(t)
2059 local i = 0 2088 local i = 0
2060 return function() 2089 return function()
2061 if i < #t then 2090 if i < #t then
2062 i = i + 1 2091 i = i + 1
2063 return i, t[i] 2092 return i, t[i]
2064 end
2065 end 2093 end
2066 end 2094 end
2067 </pre> 2095 end
2096 </code>
2068 <% 2097 <%
2069 end 2098 end
2070 } 2099 }
2071 ["Luan.load"] = { 2100 ["Luan.load"] = {
2072 title = "<code>Luan.load (text, [source_name [, env [, persist]]])</code>" 2101 title = "Luan.load (text, [source_name [, env [, persist]]])"
2073 content = function() 2102 content = function()
2074 %> 2103 %>
2075 <p> 2104 <p>
2076 Loads a chunk. 2105 Loads a chunk.
2077 </p> 2106 </p>
2096 </p> 2125 </p>
2097 <% 2126 <%
2098 end 2127 end
2099 } 2128 }
2100 ["Luan.load_file"] = { 2129 ["Luan.load_file"] = {
2101 title = "<code>Luan.load_file (file_uri)</code>" 2130 title = "Luan.load_file (file_uri)"
2102 content = function() 2131 content = function()
2103 %> 2132 %>
2104 <p> 2133 <p>
2105 Similar to <a href="#Luan.load"><code>load</code></a>, 2134 Similar to <a href="#Luan.load"><code>load</code></a>,
2106 but gets the chunk from file <code>file_uri</code>. 2135 but gets the chunk from file <code>file_uri</code>.
2108 </p> 2137 </p>
2109 <% 2138 <%
2110 end 2139 end
2111 } 2140 }
2112 ["Luan.new_error"] = { 2141 ["Luan.new_error"] = {
2113 title = "<code>Luan.new_error (message)</code>" 2142 title = "Luan.new_error (message)"
2114 content = function() 2143 content = function()
2115 %> 2144 %>
2116 <p> 2145 <p>
2117 Creates a new error table containing the message assigned to "<code>message</code>". The error table also contains a <code>throw</code> function which throws the error. The table also contains a list of stack trace elements where each stack trace element is a table containing "<code>source</code>", "<code>line</code>", and possible "<code>call_to</code>". The table also has a metatable containing "<code>__to_string</code>" to render the error. 2146 Creates a new error table containing the message assigned to "<code>message</code>". The error table also contains a <code>throw</code> function which throws the error. The table also contains a list of stack trace elements where each stack trace element is a table containing "<code>source</code>", "<code>line</code>", and possible "<code>call_to</code>". The table also has a metatable containing "<code>__to_string</code>" to render the error.
2118 </p> 2147 </p>
2119 2148
2120 <p> 2149 <p>
2121 To print the current stack trace, you could do: 2150 To print the current stack trace, you could do:
2122 </p> 2151 </p>
2123 <pre> 2152 <code block>
2124 Io.print( Luan.new_error "stack" ) 2153 Io.print( Luan.new_error "stack" )
2125 </pre> 2154 </code>
2126 <% 2155 <%
2127 end 2156 end
2128 } 2157 }
2129 ["Luan.pairs"] = { 2158 ["Luan.pairs"] = {
2130 title = "<code>Luan.pairs (t)</code>" 2159 title = "Luan.pairs (t)"
2131 content = function() 2160 content = function()
2132 %> 2161 %>
2133 <p> 2162 <p>
2134 If <code>t</code> has a metamethod <code>__pairs</code>, 2163 If <code>t</code> has a metamethod <code>__pairs</code>,
2135 calls it with <code>t</code> as argument and returns the 2164 calls it with <code>t</code> as argument and returns the
2150 </p> 2179 </p>
2151 <% 2180 <%
2152 end 2181 end
2153 } 2182 }
2154 ["Luan.range"] = { 2183 ["Luan.range"] = {
2155 title = "<code>Luan.range (start, stop [, step])</code>" 2184 title = "Luan.range (start, stop [, step])"
2156 content = function() 2185 content = function()
2157 %> 2186 %>
2158 <p> 2187 <p>
2159 Based on <a href="https://docs.python.org/2/library/functions.html#range">the Python range() function</a>, this lets one iterate through a sequence of numbers. 2188 Based on <a href="https://docs.python.org/2/library/functions.html#range">the Python range() function</a>, this lets one iterate through a sequence of numbers.
2160 </p> 2189 </p>
2161 2190
2162 <p> 2191 <p>
2163 Example use: 2192 Example use:
2164 </p> 2193 </p>
2165 <pre> 2194 <code block>
2166 for i in range(1,10) do 2195 for i in range(1,10) do
2167 Io.print("count up:",i) 2196 Io.print("count up:",i)
2168 end 2197 end
2169 for i in range(10,0,-1) do 2198 for i in range(10,0,-1) do
2170 Io.print("count down:",i) 2199 Io.print("count down:",i)
2171 end 2200 end
2172 </pre> 2201 </code>
2173 2202
2174 <p> 2203 <p>
2175 Could be defined as: 2204 Could be defined as:
2176 </p> 2205 </p>
2177 <pre> 2206 <code block>
2178 function Luan.range(start, stop, step) 2207 function Luan.range(start, stop, step)
2179 step = step or 1 2208 step = step or 1
2180 step == 0 and <a href="#Luan.error">Luan.error</a> "bad argument #3 (step may not be zero)" 2209 step == 0 and <a href="#Luan.error">Luan.error</a> "bad argument #3 (step may not be zero)"
2181 local i = start 2210 local i = start
2182 return function() 2211 return function()
2183 if step > 0 and i <= stop or step < 0 and i >= stop then 2212 if step > 0 and i <= stop or step < 0 and i >= stop then
2184 local rtn = i 2213 local rtn = i
2185 i = i + step 2214 i = i + step
2186 return rtn 2215 return rtn
2187 end
2188 end 2216 end
2189 end 2217 end
2190 </pre> 2218 end
2219 </code>
2191 <% 2220 <%
2192 end 2221 end
2193 } 2222 }
2194 ["Luan.raw_equal"] = { 2223 ["Luan.raw_equal"] = {
2195 title = "<code>Luan.raw_equal (v1, v2)</code>" 2224 title = "Luan.raw_equal (v1, v2)"
2196 content = function() 2225 content = function()
2197 %> 2226 %>
2198 <p> 2227 <p>
2199 Checks whether <code>v1</code> is equal to <code>v2</code>, 2228 Checks whether <code>v1</code> is equal to <code>v2</code>,
2200 without invoking any metamethod. 2229 without invoking any metamethod.
2202 </p> 2231 </p>
2203 <% 2232 <%
2204 end 2233 end
2205 } 2234 }
2206 ["Luan.raw_get"] = { 2235 ["Luan.raw_get"] = {
2207 title = "<code>Luan.raw_get (table, index)</code>" 2236 title = "Luan.raw_get (table, index)"
2208 content = function() 2237 content = function()
2209 %> 2238 %>
2210 <p> 2239 <p>
2211 Gets the real value of <code>table[index]</code>, 2240 Gets the real value of <code>table[index]</code>,
2212 without invoking any metamethod. 2241 without invoking any metamethod.
2215 </p> 2244 </p>
2216 <% 2245 <%
2217 end 2246 end
2218 } 2247 }
2219 ["Luan.raw_len"] = { 2248 ["Luan.raw_len"] = {
2220 title = "<code>Luan.raw_len (v)</code>" 2249 title = "Luan.raw_len (v)"
2221 content = function() 2250 content = function()
2222 %> 2251 %>
2223 <p> 2252 <p>
2224 Returns the length of the object <code>v</code>, 2253 Returns the length of the object <code>v</code>,
2225 which must be a table or a string, 2254 which must be a table or a string,
2228 </p> 2257 </p>
2229 <% 2258 <%
2230 end 2259 end
2231 } 2260 }
2232 ["Luan.raw_set"] = { 2261 ["Luan.raw_set"] = {
2233 title = "<code>Luan.raw_set (table, index, value)</code>" 2262 title = "Luan.raw_set (table, index, value)"
2234 content = function() 2263 content = function()
2235 %> 2264 %>
2236 <p> 2265 <p>
2237 Sets the real value of <code>table[index]</code> to <code>value</code>, 2266 Sets the real value of <code>table[index]</code> to <code>value</code>,
2238 without invoking any metamethod. 2267 without invoking any metamethod.
2242 </p> 2271 </p>
2243 <% 2272 <%
2244 end 2273 end
2245 } 2274 }
2246 ["Luan.set_metatable"] = { 2275 ["Luan.set_metatable"] = {
2247 title = "<code>Luan.set_metatable (table, metatable)</code>" 2276 title = "Luan.set_metatable (table, metatable)"
2248 content = function() 2277 content = function()
2249 %> 2278 %>
2250 <p> 2279 <p>
2251 Sets the metatable for the given table. 2280 Sets the metatable for the given table.
2252 If <code>metatable</code> is <b>nil</b>, 2281 If <code>metatable</code> is <b>nil</b>,
2256 </p> 2285 </p>
2257 <% 2286 <%
2258 end 2287 end
2259 } 2288 }
2260 ["Luan.stringify"] = { 2289 ["Luan.stringify"] = {
2261 title = "<code>Luan.stringify (v [,options])</code>" 2290 title = "Luan.stringify (v [,options])"
2262 content = function() 2291 content = function()
2263 %> 2292 %>
2264 <p> 2293 <p>
2265 Receives a value of any type and converts it to a string that is a Luan expression. <code>options</code> is a table. If <code>options.strict==true</code> then invalid types throw an error. Otherwise invalid types are represented but the resulting expression is invalid. If <code>options.number_types==true</code> then numbers will be wrapped in functions for their type. 2294 Receives a value of any type and converts it to a string that is a Luan expression. <code>options</code> is a table. If <code>options.strict==true</code> then invalid types throw an error. Otherwise invalid types are represented but the resulting expression is invalid. If <code>options.number_types==true</code> then numbers will be wrapped in functions for their type.
2266 </p> 2295 </p>
2267 <% 2296 <%
2268 end 2297 end
2269 } 2298 }
2270 ["Luan.to_string"] = { 2299 ["Luan.to_string"] = {
2271 title = "<code>Luan.to_string (v)</code>" 2300 title = "Luan.to_string (v)"
2272 content = function() 2301 content = function()
2273 %> 2302 %>
2274 <p> 2303 <p>
2275 Receives a value of any type and 2304 Receives a value of any type and
2276 converts it to a string in a human-readable format. 2305 converts it to a string in a human-readable format.
2284 </p> 2313 </p>
2285 <% 2314 <%
2286 end 2315 end
2287 } 2316 }
2288 ["Luan.type"] = { 2317 ["Luan.type"] = {
2289 title = "<code>Luan.type (v)</code>" 2318 title = "Luan.type (v)"
2290 content = function() 2319 content = function()
2291 %> 2320 %>
2292 <p> 2321 <p>
2293 Returns the type of its only argument, coded as a string. 2322 Returns the type of its only argument, coded as a string.
2294 The possible results of this function are 2323 The possible results of this function are
2303 </p> 2332 </p>
2304 <% 2333 <%
2305 end 2334 end
2306 } 2335 }
2307 ["Luan.values"] = { 2336 ["Luan.values"] = {
2308 title = "<code>Luan.values (&middot;&middot;&middot;)</code>" 2337 title = "Luan.values (&middot;&middot;&middot;)"
2309 content = function() 2338 content = function()
2310 %> 2339 %>
2311 <p> 2340 <p>
2312 Returns a function so that the construction 2341 Returns a function so that the construction
2313 </p> 2342 </p>
2320 </p> 2349 </p>
2321 <% 2350 <%
2322 end 2351 end
2323 } 2352 }
2324 ["Luan.VERSION"] = { 2353 ["Luan.VERSION"] = {
2325 title = "<code>Luan.VERSION</code>" 2354 title = "Luan.VERSION"
2326 content = function() 2355 content = function()
2327 %> 2356 %>
2328 <p> 2357 <p>
2329 A global variable (not a function) that 2358 A global variable (not a function) that
2330 holds a string containing the current Luan version. 2359 holds a string containing the current Luan version.
2339 content = function() 2368 content = function()
2340 %> 2369 %>
2341 <p> 2370 <p>
2342 Include this library by: 2371 Include this library by:
2343 </p> 2372 </p>
2344 <pre> 2373 <code block>
2345 local Package = require "luan:Package.luan" 2374 local Package = require "luan:Package.luan"
2346 </pre> 2375 </code>
2347 2376
2348 <p> 2377 <p>
2349 The package library provides basic 2378 The package library provides basic
2350 facilities for loading modules in Luan. 2379 facilities for loading modules in Luan.
2351 </p> 2380 </p>
2352 <% 2381 <%
2353 end 2382 end
2354 subs = { 2383 subs = {
2355 ["Package.load"] = { 2384 ["Package.load"] = {
2356 title = "<code>Package.load (mod_uri)</code>" 2385 title = "Package.load (mod_uri)"
2357 content = function() 2386 content = function()
2358 %> 2387 %>
2359 <p> 2388 <p>
2360 Loads the given module. 2389 Loads the given module.
2361 The function starts by looking into the <a href="#Package.loaded"><code>Package.loaded</code></a> table 2390 The function starts by looking into the <a href="#Package.loaded"><code>Package.loaded</code></a> table
2378 </p> 2407 </p>
2379 <% 2408 <%
2380 end 2409 end
2381 } 2410 }
2382 ["Package.loaded"] = { 2411 ["Package.loaded"] = {
2383 title = "<code>Package.loaded</code>" 2412 title = "Package.loaded"
2384 content = function() 2413 content = function()
2385 %> 2414 %>
2386 <p> 2415 <p>
2387 A table used by <a href="#Package.load"><code>Package.load</code></a> to control which 2416 A table used by <a href="#Package.load"><code>Package.load</code></a> to control which
2388 modules are already loaded. 2417 modules are already loaded.
2406 content = function() 2435 content = function()
2407 %> 2436 %>
2408 <p> 2437 <p>
2409 Include this library by: 2438 Include this library by:
2410 </p> 2439 </p>
2411 <pre> 2440 <code block>
2412 local String = require "luan:String.luan" 2441 local String = require "luan:String.luan"
2413 </pre> 2442 </code>
2414 2443
2415 <p> 2444 <p>
2416 This library provides generic functions for string manipulation, 2445 This library provides generic functions for string manipulation,
2417 such as finding and extracting substrings, and pattern matching. 2446 such as finding and extracting substrings, and pattern matching.
2418 When indexing a string in Luan, the first character is at position&nbsp;1 2447 When indexing a string in Luan, the first character is at position&nbsp;1
2423 </p> 2452 </p>
2424 <% 2453 <%
2425 end 2454 end
2426 subs = { 2455 subs = {
2427 ["String.char"] = { 2456 ["String.char"] = {
2428 title = "<code>String.char (&middot;&middot;&middot;)</code>" 2457 title = "String.char (&middot;&middot;&middot;)"
2429 content = function() 2458 content = function()
2430 %> 2459 %>
2431 <p> 2460 <p>
2432 Receives zero or more integers. 2461 Receives zero or more integers.
2433 Returns a string with length equal to the number of arguments, 2462 Returns a string with length equal to the number of arguments,
2436 </p> 2465 </p>
2437 <% 2466 <%
2438 end 2467 end
2439 } 2468 }
2440 ["String.contains"] = { 2469 ["String.contains"] = {
2441 title = "<code>String.contains (s, s2)</code>" 2470 title = "String.contains (s, s2)"
2442 content = function() 2471 content = function()
2443 %> 2472 %>
2444 <p> 2473 <p>
2445 Returns a boolean indicating whether the <code>s</code> contains <code>s2</code>. 2474 Returns a boolean indicating whether the <code>s</code> contains <code>s2</code>.
2446 </p> 2475 </p>
2447 <% 2476 <%
2448 end 2477 end
2449 } 2478 }
2450 ["String.encode"] = { 2479 ["String.encode"] = {
2451 title = "<code>String.encode (s)</code>" 2480 title = "String.encode (s)"
2452 content = function() 2481 content = function()
2453 %> 2482 %>
2454 <p> 2483 <p>
2455 Encodes argument <code>s</code> into a string that can be placed in quotes so as to return the original value of the string. 2484 Encodes argument <code>s</code> into a string that can be placed in quotes so as to return the original value of the string.
2456 </p> 2485 </p>
2457 <% 2486 <%
2458 end 2487 end
2459 } 2488 }
2460 ["String.ends_with"] = { 2489 ["String.ends_with"] = {
2461 title = "<code>String.ends_with (s, s2)</code>" 2490 title = "String.ends_with (s, s2)"
2462 content = function() 2491 content = function()
2463 %> 2492 %>
2464 <p> 2493 <p>
2465 Returns a boolean indicating whether the <code>s</code> ends with <code>s2</code>. 2494 Returns a boolean indicating whether the <code>s</code> ends with <code>s2</code>.
2466 </p> 2495 </p>
2467 <% 2496 <%
2468 end 2497 end
2469 } 2498 }
2470 ["String.find"] = { 2499 ["String.find"] = {
2471 title = "<code>String.find (s, s2 [, init])</code>" 2500 title = "String.find (s, s2 [, init])"
2472 content = function() 2501 content = function()
2473 %> 2502 %>
2474 <p> 2503 <p>
2475 Looks for the first substring 2504 Looks for the first substring
2476 <code>s2</code> in the string <code>s</code>. 2505 <code>s2</code> in the string <code>s</code>.
2490 </p> 2519 </p>
2491 <% 2520 <%
2492 end 2521 end
2493 } 2522 }
2494 ["String.format"] = { 2523 ["String.format"] = {
2495 title = "<code>String.format (formatstring, &middot;&middot;&middot;)</code>" 2524 title = "String.format (formatstring, &middot;&middot;&middot;)"
2496 content = function() 2525 content = function()
2497 %> 2526 %>
2498 <p> 2527 <p>
2499 Returns a formatted version of its variable number of arguments 2528 Returns a formatted version of its variable number of arguments
2500 following the description given in its first argument (which must be a string). 2529 following the description given in its first argument (which must be a string).
2506 </p> 2535 </p>
2507 <% 2536 <%
2508 end 2537 end
2509 } 2538 }
2510 ["String.lower"] = { 2539 ["String.lower"] = {
2511 title = "<code>String.lower (s)</code>" 2540 title = "String.lower (s)"
2512 content = function() 2541 content = function()
2513 %> 2542 %>
2514 <p> 2543 <p>
2515 Receives a string and returns a copy of this string with all 2544 Receives a string and returns a copy of this string with all
2516 uppercase letters changed to lowercase. 2545 uppercase letters changed to lowercase.
2518 </p> 2547 </p>
2519 <% 2548 <%
2520 end 2549 end
2521 } 2550 }
2522 ["String.regex"] = { 2551 ["String.regex"] = {
2523 title = "<code>String.regex (s)</code>" 2552 title = "String.regex (s)"
2524 content = function() 2553 content = function()
2525 %> 2554 %>
2526 <p> 2555 <p>
2527 Returns a <a href="#regex_table">regex</a> table for the pattern <code>s</code>. 2556 Returns a <a href="#regex_table">regex</a> table for the pattern <code>s</code>.
2528 </p> 2557 </p>
2529 <% 2558 <%
2530 end 2559 end
2531 } 2560 }
2532 ["String.regex_quote"] = { 2561 ["String.regex_quote"] = {
2533 title = "<code>String.regex_quote (s)</code>" 2562 title = "String.regex_quote (s)"
2534 content = function() 2563 content = function()
2535 %> 2564 %>
2536 <p> 2565 <p>
2537 Returns a string which matches the literal string <code>s</code> in a regular expression. This function is simply the Java method <a href="http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html#quote(java.lang.String)"><code>Pattern.quote</code></a>. 2566 Returns a string which matches the literal string <code>s</code> in a regular expression. This function is simply the Java method <a href="http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html#quote(java.lang.String)"><code>Pattern.quote</code></a>.
2538 </p> 2567 </p>
2539 <% 2568 <%
2540 end 2569 end
2541 } 2570 }
2542 ["String.repeated"] = { 2571 ["String.repeated"] = {
2543 title = "<code>String.repeated (s, n [, sep])</code>" 2572 title = "String.repeated (s, n [, sep])"
2544 content = function() 2573 content = function()
2545 %> 2574 %>
2546 <p> 2575 <p>
2547 Returns a string that is the concatenation of <code>n</code> copies of 2576 Returns a string that is the concatenation of <code>n</code> copies of
2548 the string <code>s</code> separated by the string <code>sep</code>. 2577 the string <code>s</code> separated by the string <code>sep</code>.
2552 </p> 2581 </p>
2553 <% 2582 <%
2554 end 2583 end
2555 } 2584 }
2556 ["String.replace"] = { 2585 ["String.replace"] = {
2557 title = "<code>String.replace (s, target, replacement)</code>" 2586 title = "String.replace (s, target, replacement)"
2558 content = function() 2587 content = function()
2559 %> 2588 %>
2560 <p> 2589 <p>
2561 Returns a string where each substring <code>target</code> in <code>s</code> is replaced by <code>replacement</code>. 2590 Returns a string where each substring <code>target</code> in <code>s</code> is replaced by <code>replacement</code>.
2562 </p> 2591 </p>
2563 <% 2592 <%
2564 end 2593 end
2565 } 2594 }
2566 ["String.reverse"] = { 2595 ["String.reverse"] = {
2567 title = "<code>String.reverse (s)</code>" 2596 title = "String.reverse (s)"
2568 content = function() 2597 content = function()
2569 %> 2598 %>
2570 <p> 2599 <p>
2571 Returns a string that is the string <code>s</code> reversed. 2600 Returns a string that is the string <code>s</code> reversed.
2572 </p> 2601 </p>
2573 <% 2602 <%
2574 end 2603 end
2575 } 2604 }
2576 ["String.split"] = { 2605 ["String.split"] = {
2577 title = "<code>String.split (s, s2 [, limit])</code>" 2606 title = "String.split (s, s2 [, limit])"
2578 content = function() 2607 content = function()
2579 %> 2608 %>
2580 <p> 2609 <p>
2581 Splits <code>s</code> using substring <code>s2</code> and returns the results. If <code>limit</code> is positive, then only returns at most that many results. If <code>limit</code> is zero, then remove trailing empty results. 2610 Splits <code>s</code> using substring <code>s2</code> and returns the results. If <code>limit</code> is positive, then only returns at most that many results. If <code>limit</code> is zero, then remove trailing empty results.
2582 </p> 2611 </p>
2583 <% 2612 <%
2584 end 2613 end
2585 } 2614 }
2586 ["String.starts_with"] = { 2615 ["String.starts_with"] = {
2587 title = "<code>String.starts_with (s, s2)</code>" 2616 title = "String.starts_with (s, s2)"
2588 content = function() 2617 content = function()
2589 %> 2618 %>
2590 <p> 2619 <p>
2591 Returns a boolean indicating whether the <code>s</code> starts with <code>s2</code>. 2620 Returns a boolean indicating whether the <code>s</code> starts with <code>s2</code>.
2592 </p> 2621 </p>
2593 <% 2622 <%
2594 end 2623 end
2595 } 2624 }
2596 ["String.sub"] = { 2625 ["String.sub"] = {
2597 title = "<code>String.sub (s, i [, j])</code>" 2626 title = "String.sub (s, i [, j])"
2598 content = function() 2627 content = function()
2599 %> 2628 %>
2600 <p> 2629 <p>
2601 Returns the substring of <code>s</code> that 2630 Returns the substring of <code>s</code> that
2602 starts at <code>i</code> and continues until <code>j</code>; 2631 starts at <code>i</code> and continues until <code>j</code>;
2622 </p> 2651 </p>
2623 <% 2652 <%
2624 end 2653 end
2625 } 2654 }
2626 ["String.to_binary"] = { 2655 ["String.to_binary"] = {
2627 title = "<code>String.to_binary (s)</code>" 2656 title = "String.to_binary (s)"
2628 content = function() 2657 content = function()
2629 %> 2658 %>
2630 <p> 2659 <p>
2631 Converts a string to a binary by calling the Java method <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#getBytes()"><code>String.getBytes</code></a>. 2660 Converts a string to a binary by calling the Java method <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#getBytes()"><code>String.getBytes</code></a>.
2632 </p> 2661 </p>
2633 <% 2662 <%
2634 end 2663 end
2635 } 2664 }
2636 ["String.to_number"] = { 2665 ["String.to_number"] = {
2637 title = "<code>String.to_number (s [, base])</code>" 2666 title = "String.to_number (s [, base])"
2638 content = function() 2667 content = function()
2639 %> 2668 %>
2640 <p> 2669 <p>
2641 When called with no <code>base</code>, 2670 When called with no <code>base</code>,
2642 <code>to_number</code> tries to convert its argument to a number. 2671 <code>to_number</code> tries to convert its argument to a number.
2659 </p> 2688 </p>
2660 <% 2689 <%
2661 end 2690 end
2662 } 2691 }
2663 ["String.trim"] = { 2692 ["String.trim"] = {
2664 title = "<code>String.trim (s)</code>" 2693 title = "String.trim (s)"
2665 content = function() 2694 content = function()
2666 %> 2695 %>
2667 <p> 2696 <p>
2668 Removes the leading and trailing whitespace by calling the Java method <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#trim()"><code>String.trim</code></a>. 2697 Removes the leading and trailing whitespace by calling the Java method <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#trim()"><code>String.trim</code></a>.
2669 </p> 2698 </p>
2670 <% 2699 <%
2671 end 2700 end
2672 } 2701 }
2673 ["String.unicode"] = { 2702 ["String.unicode"] = {
2674 title = "<code>String.unicode (s [, i [, j]])</code>" 2703 title = "String.unicode (s [, i [, j]])"
2675 content = function() 2704 content = function()
2676 %> 2705 %>
2677 <p> 2706 <p>
2678 Returns the internal numerical codes of the characters <code>s[i]</code>, 2707 Returns the internal numerical codes of the characters <code>s[i]</code>,
2679 <code>s[i+1]</code>, ..., <code>s[j]</code>. 2708 <code>s[i+1]</code>, ..., <code>s[j]</code>.
2684 </p> 2713 </p>
2685 <% 2714 <%
2686 end 2715 end
2687 } 2716 }
2688 ["String.upper"] = { 2717 ["String.upper"] = {
2689 title = "<code>String.upper (s)</code>" 2718 title = "String.upper (s)"
2690 content = function() 2719 content = function()
2691 %> 2720 %>
2692 <p> 2721 <p>
2693 Receives a string and returns a copy of this string with all 2722 Receives a string and returns a copy of this string with all
2694 lowercase letters changed to uppercase. 2723 lowercase letters changed to uppercase.
2713 </p> 2742 </p>
2714 <% 2743 <%
2715 end 2744 end
2716 subs = { 2745 subs = {
2717 ["regex.find"] = { 2746 ["regex.find"] = {
2718 title = "<code>regex.find (s [, init])</code>" 2747 title = "regex.find (s [, init])"
2719 content = function() 2748 content = function()
2720 %> 2749 %>
2721 <p> 2750 <p>
2722 Looks for the first match of 2751 Looks for the first match of
2723 the regex in the string <code>s</code>. 2752 the regex in the string <code>s</code>.
2737 </p> 2766 </p>
2738 <% 2767 <%
2739 end 2768 end
2740 } 2769 }
2741 ["regex.gmatch"] = { 2770 ["regex.gmatch"] = {
2742 title = "<code>regex.gmatch (s)</code>" 2771 title = "regex.gmatch (s)"
2743 content = function() 2772 content = function()
2744 %> 2773 %>
2745 <p> 2774 <p>
2746 Returns an iterator function that, 2775 Returns an iterator function that,
2747 each time it is called, 2776 each time it is called,
2754 <p> 2783 <p>
2755 As an example, the following loop 2784 As an example, the following loop
2756 will iterate over all the words from string <code>s</code>, 2785 will iterate over all the words from string <code>s</code>,
2757 printing one per line: 2786 printing one per line:
2758 </p> 2787 </p>
2759 <pre> 2788 <code block>
2760 local r = String.regex[[\w+]] 2789 local r = String.regex[[\w+]]
2761 local s = "hello world from Lua" 2790 local s = "hello world from Lua"
2762 for w in r.gmatch(s) do 2791 for w in r.gmatch(s) do
2763 print(w) 2792 print(w)
2764 end 2793 end
2765 </pre> 2794 </code>
2766 2795
2767 <p> 2796 <p>
2768 The next example collects all pairs <code>key=value</code> from the 2797 The next example collects all pairs <code>key=value</code> from the
2769 given string into a table: 2798 given string into a table:
2770 </p> 2799 </p>
2771 <pre> 2800 <code block>
2772 local t = {} 2801 local t = {}
2773 local r = String.regex[[(\w+)=(\w+)]] 2802 local r = String.regex[[(\w+)=(\w+)]]
2774 local s = "from=world, to=Lua" 2803 local s = "from=world, to=Lua"
2775 for k, v in r.gmatch(s) do 2804 for k, v in r.gmatch(s) do
2776 t[k] = v 2805 t[k] = v
2777 end 2806 end
2778 </pre> 2807 </code>
2779 2808
2780 <p> 2809 <p>
2781 For this function, a caret '<code>^</code>' at the start of a pattern does not 2810 For this function, a caret '<code>^</code>' at the start of a pattern does not
2782 work as an anchor, as this would prevent the iteration. 2811 work as an anchor, as this would prevent the iteration.
2783 </p> 2812 </p>
2784 <% 2813 <%
2785 end 2814 end
2786 } 2815 }
2787 ["regex.gsub"] = { 2816 ["regex.gsub"] = {
2788 title = "<code>regex.gsub (s, repl [, n])</code>" 2817 title = "regex.gsub (s, repl [, n])"
2789 content = function() 2818 content = function()
2790 %> 2819 %>
2791 <p> 2820 <p>
2792 Returns a copy of <code>s</code> 2821 Returns a copy of <code>s</code>
2793 in which all (or the first <code>n</code>, if given) 2822 in which all (or the first <code>n</code>, if given)
2835 </p> 2864 </p>
2836 2865
2837 <p> 2866 <p>
2838 Here are some examples: 2867 Here are some examples:
2839 </p> 2868 </p>
2840 <pre> 2869
2841 local r = String.regex[[(\w+)]] 2870 <code block>
2842 local x = r.gsub("hello world", "$1 $1") 2871 local r = String.regex[[(\w+)]]
2843 --&gt; x="hello hello world world" 2872 local x = r.gsub("hello world", "$1 $1")
2844 2873 --&gt; x="hello hello world world"
2845 local r = String.regex[[(\w+)]] 2874
2846 local x = r.gsub("hello world", "$0 $0", 1) 2875 local r = String.regex[[(\w+)]]
2847 --&gt; x="hello hello world" 2876 local x = r.gsub("hello world", "$0 $0", 1)
2848 2877 --&gt; x="hello hello world"
2849 local r = String.regex[[(\w+)\s*(\w+)]] 2878
2850 local x = r.gsub("hello world from Luan", "$2 $1") 2879 local r = String.regex[[(\w+)\s*(\w+)]]
2851 --&gt; x="world hello Luan from" 2880 local x = r.gsub("hello world from Luan", "$2 $1")
2852 2881 --&gt; x="world hello Luan from"
2853 local r = String.regex[[\$(.*?)\$]] 2882
2854 local x = r.gsub("4+5 = $return 4+5$", function(s) 2883 local r = String.regex[[\$(.*?)\$]]
2855 return load(s)() 2884 local x = r.gsub("4+5 = $return 4+5$", function(s)
2856 end) 2885 return load(s)()
2857 --&gt; x="4+5 = 9" 2886 end)
2858 2887 --&gt; x="4+5 = 9"
2859 local r = String.regex[[\$(\w+)]] 2888
2860 local t = {name="lua", version="5.3"} 2889 local r = String.regex[[\$(\w+)]]
2861 local x = r.gsub("$name-$version.tar.gz", t) 2890 local t = {name="lua", version="5.3"}
2862 --&gt; x="lua-5.3.tar.gz" 2891 local x = r.gsub("$name-$version.tar.gz", t)
2863 </pre> 2892 --&gt; x="lua-5.3.tar.gz"
2893 </code>
2864 <% 2894 <%
2865 end 2895 end
2866 } 2896 }
2867 ["regex.match"] = { 2897 ["regex.match"] = {
2868 title = "<code>regex.match (s [, init])</code>" 2898 title = "regex.match (s [, init])"
2869 content = function() 2899 content = function()
2870 %> 2900 %>
2871 <p> 2901 <p>
2872 Looks for the first <em>match</em> of 2902 Looks for the first <em>match</em> of
2873 the regex in the string <code>s</code>. 2903 the regex in the string <code>s</code>.
2882 </p> 2912 </p>
2883 <% 2913 <%
2884 end 2914 end
2885 } 2915 }
2886 ["regex.matches"] = { 2916 ["regex.matches"] = {
2887 title = "<code>regex.matches (s)</code>" 2917 title = "regex.matches (s)"
2888 content = function() 2918 content = function()
2889 %> 2919 %>
2890 <p> 2920 <p>
2891 Returns a boolean indicating whether the regex can be found in string <code>s</code>. 2921 Returns a boolean indicating whether the regex can be found in string <code>s</code>.
2892 This function is equivalent to 2922 This function is equivalent to
2893 </p> 2923 </p>
2894 <pre> 2924 <code block>
2895 return regex.match(s) ~= nil 2925 return regex.match(s) ~= nil
2896 </pre> 2926 </code>
2897 <% 2927 <%
2898 end 2928 end
2899 } 2929 }
2900 ["regex.set"] = { 2930 ["regex.set"] = {
2901 title = "<code>regex.set (pattern)</code>" 2931 title = "regex.set (pattern)"
2902 content = function() 2932 content = function()
2903 %> 2933 %>
2904 <p> 2934 <p>
2905 Changes the regex pattern to <code>pattern</code>. 2935 Changes the regex pattern to <code>pattern</code>.
2906 </p> 2936 </p>
2907 <% 2937 <%
2908 end 2938 end
2909 } 2939 }
2910 ["regex.split"] = { 2940 ["regex.split"] = {
2911 title = "<code>regex.split (s [, limit])</code>" 2941 title = "regex.split (s [, limit])"
2912 content = function() 2942 content = function()
2913 %> 2943 %>
2914 <p> 2944 <p>
2915 Splits <code>s</code> using the regex and returns the results. If <code>limit</code> is positive, then only returns at most that many results. If <code>limit</code> is zero, then remove trailing empty results. 2945 Splits <code>s</code> using the regex and returns the results. If <code>limit</code> is positive, then only returns at most that many results. If <code>limit</code> is zero, then remove trailing empty results.
2916 </p> 2946 </p>
2924 content = function() 2954 content = function()
2925 %> 2955 %>
2926 <p> 2956 <p>
2927 Include this library by: 2957 Include this library by:
2928 </p> 2958 </p>
2929 <pre> 2959 <code block>
2930 local Binary = require "luan:Binary.luan" 2960 local Binary = require "luan:Binary.luan"
2931 </pre> 2961 </code>
2932 <% 2962 <%
2933 end 2963 end
2934 subs = { 2964 subs = {
2935 ["Binary.binary"] = { 2965 ["Binary.binary"] = {
2936 title = "<code>Binary.binary (&middot;&middot;&middot;)</code>" 2966 title = "Binary.binary (&middot;&middot;&middot;)"
2937 content = function() 2967 content = function()
2938 %> 2968 %>
2939 <p> 2969 <p>
2940 Receives zero or more bytes (as integers). 2970 Receives zero or more bytes (as integers).
2941 Returns a binary with length equal to the number of arguments, 2971 Returns a binary with length equal to the number of arguments,
2944 </p> 2974 </p>
2945 <% 2975 <%
2946 end 2976 end
2947 } 2977 }
2948 ["Binary.byte"] = { 2978 ["Binary.byte"] = {
2949 title = "<code>Binary.byte (b [, i [, j]])</code>" 2979 title = "Binary.byte (b [, i [, j]])"
2950 content = function() 2980 content = function()
2951 %> 2981 %>
2952 <p> 2982 <p>
2953 Returns the internal numerical codes of the bytes <code>b[i]</code>, 2983 Returns the internal numerical codes of the bytes <code>b[i]</code>,
2954 <code>b[i+1]</code>, ..., <code>b[j]</code>. 2984 <code>b[i+1]</code>, ..., <code>b[j]</code>.
2959 </p> 2989 </p>
2960 <% 2990 <%
2961 end 2991 end
2962 } 2992 }
2963 ["Binary.to_string"] = { 2993 ["Binary.to_string"] = {
2964 title = "<code>Binary.to_string (b [,charset])</code>" 2994 title = "Binary.to_string (b [,charset])"
2965 content = function() 2995 content = function()
2966 %> 2996 %>
2967 <p> 2997 <p>
2968 If <code>charset</code> is not nil then converts the binary <code>b</code> to a string using the Java <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#String(byte[],%20java.lang.String)">String constructor</a>, else makes each byte a char. 2998 If <code>charset</code> is not nil then converts the binary <code>b</code> to a string using the Java <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#String(byte[],%20java.lang.String)">String constructor</a>, else makes each byte a char.
2969 </p> 2999 </p>
2977 content = function() 3007 content = function()
2978 %> 3008 %>
2979 <p> 3009 <p>
2980 Include this library by: 3010 Include this library by:
2981 </p> 3011 </p>
2982 <pre> 3012 <code block>
2983 local Table = require "luan:Table.luan" 3013 local Table = require "luan:Table.luan"
2984 </pre> 3014 </code>
2985 3015
2986 <p> 3016 <p>
2987 This library provides generic functions for table manipulation. 3017 This library provides generic functions for table manipulation.
2988 It provides all its functions inside the table <code>Table</code>. 3018 It provides all its functions inside the table <code>Table</code>.
2989 </p> 3019 </p>
2990 <% 3020 <%
2991 end 3021 end
2992 subs = { 3022 subs = {
2993 ["Table.clear"] = { 3023 ["Table.clear"] = {
2994 title = "<code>Table.clear (tbl)</code>" 3024 title = "Table.clear (tbl)"
2995 content = function() 3025 content = function()
2996 %> 3026 %>
2997 <p> 3027 <p>
2998 Clears the table. 3028 Clears the table.
2999 </p> 3029 </p>
3000 <% 3030 <%
3001 end 3031 end
3002 } 3032 }
3003 ["Table.concat"] = { 3033 ["Table.concat"] = {
3004 title = "<code>Table.concat (list [, sep [, i [, j]]])</code>" 3034 title = "Table.concat (list [, sep [, i [, j]]])"
3005 content = function() 3035 content = function()
3006 %> 3036 %>
3007 <p> 3037 <p>
3008 Given a list, 3038 Given a list,
3009 returns the string <code>list[i]..sep..list[i+1] &middot;&middot;&middot; sep..list[j]</code>. 3039 returns the string <code>list[i]..sep..list[i+1] &middot;&middot;&middot; sep..list[j]</code>.
3014 </p> 3044 </p>
3015 <% 3045 <%
3016 end 3046 end
3017 } 3047 }
3018 ["Table.copy"] = { 3048 ["Table.copy"] = {
3019 title = "<code>Table.copy (tbl [, i [, j]])</code>" 3049 title = "Table.copy (tbl [, i [, j]])"
3020 content = function() 3050 content = function()
3021 %> 3051 %>
3022 <p> 3052 <p>
3023 If <code>i</code> is <code>nil</code>, returns a shallow copy of <code>tbl</code>. 3053 If <code>i</code> is <code>nil</code>, returns a shallow copy of <code>tbl</code>.
3024 Otherwise returns a new table which is a list of the elements <code>tbl[i] &middot;&middot;&middot; tbl[j]</code>. 3054 Otherwise returns a new table which is a list of the elements <code>tbl[i] &middot;&middot;&middot; tbl[j]</code>.
3026 </p> 3056 </p>
3027 <% 3057 <%
3028 end 3058 end
3029 } 3059 }
3030 ["Table.insert"] = { 3060 ["Table.insert"] = {
3031 title = "<code>Table.insert (list, pos, value)</code>" 3061 title = "Table.insert (list, pos, value)"
3032 content = function() 3062 content = function()
3033 %> 3063 %>
3034 <p> 3064 <p>
3035 Inserts element <code>value</code> at position <code>pos</code> in <code>list</code>, 3065 Inserts element <code>value</code> at position <code>pos</code> in <code>list</code>,
3036 shifting up the elements 3066 shifting up the elements
3038 </p> 3068 </p>
3039 <% 3069 <%
3040 end 3070 end
3041 } 3071 }
3042 ["Table.is_empty"] = { 3072 ["Table.is_empty"] = {
3043 title = "<code>Table.is_empty (tbl)</code>" 3073 title = "Table.is_empty (tbl)"
3044 content = function() 3074 content = function()
3045 %> 3075 %>
3046 <% 3076 <%
3047 end 3077 end
3048 } 3078 }
3049 ["Table.is_list"] = { 3079 ["Table.is_list"] = {
3050 title = "<code>Table.is_list (tbl)</code>" 3080 title = "Table.is_list (tbl)"
3051 content = function() 3081 content = function()
3052 %> 3082 %>
3053 <% 3083 <%
3054 end 3084 end
3055 } 3085 }
3056 ["Table.pack"] = { 3086 ["Table.pack"] = {
3057 title = "<code>Table.pack (&middot;&middot;&middot;)</code>" 3087 title = "Table.pack (&middot;&middot;&middot;)"
3058 content = function() 3088 content = function()
3059 %> 3089 %>
3060 <p> 3090 <p>
3061 Returns a new table with all parameters stored into keys 1, 2, etc. 3091 Returns a new table with all parameters stored into keys 1, 2, etc.
3062 and with a field "<code>n</code>" with the total number of parameters. 3092 and with a field "<code>n</code>" with the total number of parameters.
3064 </p> 3094 </p>
3065 <% 3095 <%
3066 end 3096 end
3067 } 3097 }
3068 ["Table.remove"] = { 3098 ["Table.remove"] = {
3069 title = "<code>Table.remove (list, pos)</code>" 3099 title = "Table.remove (list, pos)"
3070 content = function() 3100 content = function()
3071 %> 3101 %>
3072 <p> 3102 <p>
3073 Removes from <code>list</code> the element at position <code>pos</code>, 3103 Removes from <code>list</code> the element at position <code>pos</code>,
3074 returning the value of the removed element. 3104 returning the value of the removed element.
3082 </p> 3112 </p>
3083 <% 3113 <%
3084 end 3114 end
3085 } 3115 }
3086 ["Table.size"] = { 3116 ["Table.size"] = {
3087 title = "<code>Table.size (tbl)</code>" 3117 title = "Table.size (tbl)"
3088 content = function() 3118 content = function()
3089 %> 3119 %>
3090 <% 3120 <%
3091 end 3121 end
3092 } 3122 }
3093 ["Table.sort"] = { 3123 ["Table.sort"] = {
3094 title = "<code>Table.sort (list [, comp])</code>" 3124 title = "Table.sort (list [, comp])"
3095 content = function() 3125 content = function()
3096 %> 3126 %>
3097 <p> 3127 <p>
3098 Sorts list elements in a given order, <em>in-place</em>, 3128 Sorts list elements in a given order, <em>in-place</em>,
3099 from <code>list[1]</code> to <code>list[#list]</code>. 3129 from <code>list[1]</code> to <code>list[#list]</code>.
3113 </p> 3143 </p>
3114 <% 3144 <%
3115 end 3145 end
3116 } 3146 }
3117 ["Table.unpack"] = { 3147 ["Table.unpack"] = {
3118 title = "<code>Table.unpack (list [, i [, j]])</code>" 3148 title = "Table.unpack (list [, i [, j]])"
3119 content = function() 3149 content = function()
3120 %> 3150 %>
3121 <p> 3151 <p>
3122 Returns the elements from the given list. 3152 Returns the elements from the given list.
3123 This function is equivalent to 3153 This function is equivalent to
3124 </p> 3154 </p>
3125 <pre> 3155 <code block>
3126 return list[i], list[i+1], &middot;&middot;&middot;, list[j] 3156 return list[i], list[i+1], &middot;&middot;&middot;, list[j]
3127 </pre> 3157 </code>
3128 3158
3129 <p> 3159 <p>
3130 By default, <code>i</code> is 1 and <code>j</code> is <code>list.n or #list</code>. 3160 By default, <code>i</code> is 1 and <code>j</code> is <code>list.n or #list</code>.
3131 </p> 3161 </p>
3132 <% 3162 <%
3139 content = function() 3169 content = function()
3140 %> 3170 %>
3141 <p> 3171 <p>
3142 Include this library by: 3172 Include this library by:
3143 </p> 3173 </p>
3144 <pre> 3174 <code block>
3145 local Number = require "luan:Number.luan" 3175 local Number = require "luan:Number.luan"
3146 </pre> 3176 </code>
3147 <% 3177 <%
3148 end 3178 end
3149 subs = { 3179 subs = {
3150 ["Number.double"] = { 3180 ["Number.double"] = {
3151 title = "<code>Number.double (x)</code>" 3181 title = "Number.double (x)"
3152 content = function() 3182 content = function()
3153 %> 3183 %>
3154 <p> 3184 <p>
3155 Returns <code>x</code> as a double. 3185 Returns <code>x</code> as a double.
3156 </p> 3186 </p>
3157 <% 3187 <%
3158 end 3188 end
3159 } 3189 }
3160 ["Number.float"] = { 3190 ["Number.float"] = {
3161 title = "<code>Number.float (x)</code>" 3191 title = "Number.float (x)"
3162 content = function() 3192 content = function()
3163 %> 3193 %>
3164 <p> 3194 <p>
3165 Returns <code>x</code> as a float. 3195 Returns <code>x</code> as a float.
3166 </p> 3196 </p>
3167 <% 3197 <%
3168 end 3198 end
3169 } 3199 }
3170 ["Number.integer"] = { 3200 ["Number.integer"] = {
3171 title = "<code>Number.integer (x)</code>" 3201 title = "Number.integer (x)"
3172 content = function() 3202 content = function()
3173 %> 3203 %>
3174 <p> 3204 <p>
3175 If the value <code>x</code> is convertible to an integer, 3205 If the value <code>x</code> is convertible to an integer,
3176 returns that integer. 3206 returns that integer.
3178 </p> 3208 </p>
3179 <% 3209 <%
3180 end 3210 end
3181 } 3211 }
3182 ["Number.long"] = { 3212 ["Number.long"] = {
3183 title = "<code>Number.long (x)</code>" 3213 title = "Number.long (x)"
3184 content = function() 3214 content = function()
3185 %> 3215 %>
3186 <p> 3216 <p>
3187 If the value <code>x</code> is convertible to an long, 3217 If the value <code>x</code> is convertible to an long,
3188 returns that long. 3218 returns that long.
3190 </p> 3220 </p>
3191 <% 3221 <%
3192 end 3222 end
3193 } 3223 }
3194 ["Number.long_to_string"] = { 3224 ["Number.long_to_string"] = {
3195 title = "<code>Number.long_to_string (i, radix)</code>" 3225 title = "Number.long_to_string (i, radix)"
3196 content = function() 3226 content = function()
3197 %> 3227 %>
3198 <p> 3228 <p>
3199 Converts long value <code>i</code> to a string by calling <code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Long.html#toString(long,%20int)">Long.toString</a></code>. 3229 Converts long value <code>i</code> to a string by calling <code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Long.html#toString(long,%20int)">Long.toString</a></code>.
3200 </p> 3230 </p>
3201 <% 3231 <%
3202 end 3232 end
3203 } 3233 }
3204 ["Number.type"] = { 3234 ["Number.type"] = {
3205 title = "<code>Number.type (x)</code>" 3235 title = "Number.type (x)"
3206 content = function() 3236 content = function()
3207 %> 3237 %>
3208 <p> 3238 <p>
3209 Returns a string for the numeric type of <code>x</code>. Possible return values include "<code>integer</code>", "<code>long</code>", "<code>double</code>", and "<code>float</code>". 3239 Returns a string for the numeric type of <code>x</code>. Possible return values include "<code>integer</code>", "<code>long</code>", "<code>double</code>", and "<code>float</code>".
3210 </p> 3240 </p>
3218 content = function() 3248 content = function()
3219 %> 3249 %>
3220 <p> 3250 <p>
3221 Include this library by: 3251 Include this library by:
3222 </p> 3252 </p>
3223 <pre> 3253 <code block>
3224 local Math = require "luan:Math.luan" 3254 local Math = require "luan:Math.luan"
3225 </pre> 3255 </code>
3226 3256
3227 <p> 3257 <p>
3228 This library provides basic mathematical functions. 3258 This library provides basic mathematical functions.
3229 It provides all its functions and constants inside the table <code>Math</code>. 3259 It provides all its functions and constants inside the table <code>Math</code>.
3230 </p> 3260 </p>
3231 <% 3261 <%
3232 end 3262 end
3233 subs = { 3263 subs = {
3234 ["Math.abs"] = { 3264 ["Math.abs"] = {
3235 title = "<code>Math.abs (x)</code>" 3265 title = "Math.abs (x)"
3236 content = function() 3266 content = function()
3237 %> 3267 %>
3238 <p> 3268 <p>
3239 Returns the absolute value of <code>x</code>. 3269 Returns the absolute value of <code>x</code>.
3240 </p> 3270 </p>
3241 <% 3271 <%
3242 end 3272 end
3243 } 3273 }
3244 ["Math.acos"] = { 3274 ["Math.acos"] = {
3245 title = "<code>Math.acos (x)</code>" 3275 title = "Math.acos (x)"
3246 content = function() 3276 content = function()
3247 %> 3277 %>
3248 <p> 3278 <p>
3249 Returns the arc cosine of <code>x</code> (in radians). 3279 Returns the arc cosine of <code>x</code> (in radians).
3250 </p> 3280 </p>
3251 <% 3281 <%
3252 end 3282 end
3253 } 3283 }
3254 ["Math.asin"] = { 3284 ["Math.asin"] = {
3255 title = "<code>Math.asin (x)</code>" 3285 title = "Math.asin (x)"
3256 content = function() 3286 content = function()
3257 %> 3287 %>
3258 <p> 3288 <p>
3259 Returns the arc sine of <code>x</code> (in radians). 3289 Returns the arc sine of <code>x</code> (in radians).
3260 </p> 3290 </p>
3261 <% 3291 <%
3262 end 3292 end
3263 } 3293 }
3264 ["Math.atan"] = { 3294 ["Math.atan"] = {
3265 title = "<code>Math.atan (y, x)</code>" 3295 title = "Math.atan (y, x)"
3266 content = function() 3296 content = function()
3267 %> 3297 %>
3268 <p> 3298 <p>
3269 Returns the arc tangent of <code>y/x</code> (in radians), 3299 Returns the arc tangent of <code>y/x</code> (in radians),
3270 but uses the signs of both parameters to find the 3300 but uses the signs of both parameters to find the
3273 </p> 3303 </p>
3274 <% 3304 <%
3275 end 3305 end
3276 } 3306 }
3277 ["Math.ceil"] = { 3307 ["Math.ceil"] = {
3278 title = "<code>Math.ceil (x)</code>" 3308 title = "Math.ceil (x)"
3279 content = function() 3309 content = function()
3280 %> 3310 %>
3281 <p> 3311 <p>
3282 Returns the smallest integral value larger than or equal to <code>x</code>. 3312 Returns the smallest integral value larger than or equal to <code>x</code>.
3283 </p> 3313 </p>
3284 <% 3314 <%
3285 end 3315 end
3286 } 3316 }
3287 ["Math.cos"] = { 3317 ["Math.cos"] = {
3288 title = "<code>Math.cos (x)</code>" 3318 title = "Math.cos (x)"
3289 content = function() 3319 content = function()
3290 %> 3320 %>
3291 <p> 3321 <p>
3292 Returns the cosine of <code>x</code> (assumed to be in radians). 3322 Returns the cosine of <code>x</code> (assumed to be in radians).
3293 </p> 3323 </p>
3294 <% 3324 <%
3295 end 3325 end
3296 } 3326 }
3297 ["Math.deg"] = { 3327 ["Math.deg"] = {
3298 title = "<code>Math.deg (x)</code>" 3328 title = "Math.deg (x)"
3299 content = function() 3329 content = function()
3300 %> 3330 %>
3301 <p> 3331 <p>
3302 Converts the angle <code>x</code> from radians to degrees. 3332 Converts the angle <code>x</code> from radians to degrees.
3303 </p> 3333 </p>
3304 <% 3334 <%
3305 end 3335 end
3306 } 3336 }
3307 ["Math.exp"] = { 3337 ["Math.exp"] = {
3308 title = "<code>Math.exp (x)</code>" 3338 title = "Math.exp (x)"
3309 content = function() 3339 content = function()
3310 %> 3340 %>
3311 <p> 3341 <p>
3312 Returns the value <em>e<sup>x</sup></em> 3342 Returns the value <em>e<sup>x</sup></em>
3313 (where <code>e</code> is the base of natural logarithms). 3343 (where <code>e</code> is the base of natural logarithms).
3314 </p> 3344 </p>
3315 <% 3345 <%
3316 end 3346 end
3317 } 3347 }
3318 ["Math.floor"] = { 3348 ["Math.floor"] = {
3319 title = "<code>Math.floor (x)</code>" 3349 title = "Math.floor (x)"
3320 content = function() 3350 content = function()
3321 %> 3351 %>
3322 <p> 3352 <p>
3323 Returns the largest integral value smaller than or equal to <code>x</code>. 3353 Returns the largest integral value smaller than or equal to <code>x</code>.
3324 </p> 3354 </p>
3325 <% 3355 <%
3326 end 3356 end
3327 } 3357 }
3328 ["Math.fmod"] = { 3358 ["Math.fmod"] = {
3329 title = "<code>Math.fmod (x, y)</code>" 3359 title = "Math.fmod (x, y)"
3330 content = function() 3360 content = function()
3331 %> 3361 %>
3332 <p> 3362 <p>
3333 Returns the remainder of the division of <code>x</code> by <code>y</code> 3363 Returns the remainder of the division of <code>x</code> by <code>y</code>
3334 that rounds the quotient towards zero. 3364 that rounds the quotient towards zero.
3335 </p> 3365 </p>
3336 <% 3366 <%
3337 end 3367 end
3338 } 3368 }
3339 ["Math.huge"] = { 3369 ["Math.huge"] = {
3340 title = "<code>Math.huge</code>" 3370 title = "Math.huge"
3341 content = function() 3371 content = function()
3342 %> 3372 %>
3343 <p> 3373 <p>
3344 A value larger than any other numerical value. 3374 A value larger than any other numerical value.
3345 </p> 3375 </p>
3346 <% 3376 <%
3347 end 3377 end
3348 } 3378 }
3349 ["Math.log"] = { 3379 ["Math.log"] = {
3350 title = "<code>Math.log (x [, base])</code>" 3380 title = "Math.log (x [, base])"
3351 content = function() 3381 content = function()
3352 %> 3382 %>
3353 <p> 3383 <p>
3354 Returns the logarithm of <code>x</code> in the given base. 3384 Returns the logarithm of <code>x</code> in the given base.
3355 The default for <code>base</code> is <em>e</em> 3385 The default for <code>base</code> is <em>e</em>
3357 </p> 3387 </p>
3358 <% 3388 <%
3359 end 3389 end
3360 } 3390 }
3361 ["Math.max"] = { 3391 ["Math.max"] = {
3362 title = "<code>Math.max (x, &middot;&middot;&middot;)</code>" 3392 title = "Math.max (x, &middot;&middot;&middot;)"
3363 content = function() 3393 content = function()
3364 %> 3394 %>
3365 <p> 3395 <p>
3366 Returns the argument with the maximum value, 3396 Returns the argument with the maximum value,
3367 according to the Lua operator <code>&lt;</code>. 3397 according to the Lua operator <code>&lt;</code>.
3368 </p> 3398 </p>
3369 <% 3399 <%
3370 end 3400 end
3371 } 3401 }
3372 ["Math.max_integer"] = { 3402 ["Math.max_integer"] = {
3373 title = "<code>Math.max_integer</code>" 3403 title = "Math.max_integer"
3374 content = function() 3404 content = function()
3375 %> 3405 %>
3376 <p> 3406 <p>
3377 An integer with the maximum value for an integer. 3407 An integer with the maximum value for an integer.
3378 </p> 3408 </p>
3379 <% 3409 <%
3380 end 3410 end
3381 } 3411 }
3382 ["Math.min"] = { 3412 ["Math.min"] = {
3383 title = "<code>Math.min (x, &middot;&middot;&middot;)</code>" 3413 title = "Math.min (x, &middot;&middot;&middot;)"
3384 content = function() 3414 content = function()
3385 %> 3415 %>
3386 <p> 3416 <p>
3387 Returns the argument with the minimum value, 3417 Returns the argument with the minimum value,
3388 according to the Lua operator <code>&lt;</code>. 3418 according to the Lua operator <code>&lt;</code>.
3389 </p> 3419 </p>
3390 <% 3420 <%
3391 end 3421 end
3392 } 3422 }
3393 ["Math.min_integer"] = { 3423 ["Math.min_integer"] = {
3394 title = "<code>Math.min_integer</code>" 3424 title = "Math.min_integer"
3395 content = function() 3425 content = function()
3396 %> 3426 %>
3397 <p> 3427 <p>
3398 An integer with the minimum value for an integer. 3428 An integer with the minimum value for an integer.
3399 </p> 3429 </p>
3400 <% 3430 <%
3401 end 3431 end
3402 } 3432 }
3403 ["Math.modf"] = { 3433 ["Math.modf"] = {
3404 title = "<code>Math.modf (x)</code>" 3434 title = "Math.modf (x)"
3405 content = function() 3435 content = function()
3406 %> 3436 %>
3407 <p> 3437 <p>
3408 Returns the integral part of <code>x</code> and the fractional part of <code>x</code>. 3438 Returns the integral part of <code>x</code> and the fractional part of <code>x</code>.
3409 </p> 3439 </p>
3410 <% 3440 <%
3411 end 3441 end
3412 } 3442 }
3413 ["Math.pi"] = { 3443 ["Math.pi"] = {
3414 title = "<code>Math.pi</code>" 3444 title = "Math.pi"
3415 content = function() 3445 content = function()
3416 %> 3446 %>
3417 <p> 3447 <p>
3418 The value of <em>&pi;</em>. 3448 The value of <em>&pi;</em>.
3419 </p> 3449 </p>
3420 <% 3450 <%
3421 end 3451 end
3422 } 3452 }
3423 ["Math.rad"] = { 3453 ["Math.rad"] = {
3424 title = "<code>Math.rad (x)</code>" 3454 title = "Math.rad (x)"
3425 content = function() 3455 content = function()
3426 %> 3456 %>
3427 <p> 3457 <p>
3428 Converts the angle <code>x</code> from degrees to radians. 3458 Converts the angle <code>x</code> from degrees to radians.
3429 </p> 3459 </p>
3430 <% 3460 <%
3431 end 3461 end
3432 } 3462 }
3433 ["Math.random"] = { 3463 ["Math.random"] = {
3434 title = "<code>Math.random ([m [, n])</code>" 3464 title = "Math.random ([m [, n])"
3435 content = function() 3465 content = function()
3436 %> 3466 %>
3437 <p> 3467 <p>
3438 When called without arguments, 3468 When called without arguments,
3439 returns a pseudo-random float with uniform distribution 3469 returns a pseudo-random float with uniform distribution
3452 </p> 3482 </p>
3453 <% 3483 <%
3454 end 3484 end
3455 } 3485 }
3456 ["Math.sin"] = { 3486 ["Math.sin"] = {
3457 title = "<code>Math.sin (x)</code>" 3487 title = "Math.sin (x)"
3458 content = function() 3488 content = function()
3459 %> 3489 %>
3460 <p> 3490 <p>
3461 Returns the sine of <code>x</code> (assumed to be in radians). 3491 Returns the sine of <code>x</code> (assumed to be in radians).
3462 </p> 3492 </p>
3463 <% 3493 <%
3464 end 3494 end
3465 } 3495 }
3466 ["Math.sqrt"] = { 3496 ["Math.sqrt"] = {
3467 title = "<code>Math.sqrt (x)</code>" 3497 title = "Math.sqrt (x)"
3468 content = function() 3498 content = function()
3469 %> 3499 %>
3470 <p> 3500 <p>
3471 Returns the square root of <code>x</code>. 3501 Returns the square root of <code>x</code>.
3472 (You can also use the expression <code>x^0.5</code> to compute this value.) 3502 (You can also use the expression <code>x^0.5</code> to compute this value.)
3473 </p> 3503 </p>
3474 <% 3504 <%
3475 end 3505 end
3476 } 3506 }
3477 ["Math.tan"] = { 3507 ["Math.tan"] = {
3478 title = "<code>Math.tan (x)</code>" 3508 title = "Math.tan (x)"
3479 content = function() 3509 content = function()
3480 %> 3510 %>
3481 <p> 3511 <p>
3482 Returns the tangent of <code>x</code> (assumed to be in radians). 3512 Returns the tangent of <code>x</code> (assumed to be in radians).
3483 </p> 3513 </p>
3498 <html> 3528 <html>
3499 <head> 3529 <head>
3500 <% head() %> 3530 <% head() %>
3501 <title>Luan Reference Manual</title> 3531 <title>Luan Reference Manual</title>
3502 <style> 3532 <style>
3503 p[keywords] { 3533 p[list] {
3504 font-family: monospace; 3534 font-family: monospace;
3505 margin-left: 40px; 3535 margin-left: 40px;
3536 }
3537 p[list] span {
3538 display: inline-block;
3539 }
3540 p[list=keywords] {
3506 max-width: 700px; 3541 max-width: 700px;
3507 } 3542 }
3508 p[keywords] span { 3543 p[list=keywords] span {
3509 display: inline-block;
3510 width: 100px; 3544 width: 100px;
3511 } 3545 }
3512 code { 3546 p[list=tokens] {
3513 font-size: 16px; 3547 max-width: 400px;
3514 font-weight: bold;
3515 } 3548 }
3516 div[toc] code { 3549 p[list=tokens] span {
3517 font-size: inherit; 3550 width: 50px;
3518 font-weight: inherit; 3551 }
3552 li[c_libs] li li > a {
3553 font-family: monospace;
3519 } 3554 }
3520 </style> 3555 </style>
3521 </head> 3556 </head>
3522 <body> 3557 <body>
3523 <% docs_header() %> 3558 <% docs_header() %>