Mercurial Hosting > luan
comparison website/src/manual.html.luan @ 1816:e62c88b2883b
docs work
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 11 Jun 2024 21:39:18 -0600 |
parents | fa0e73119b7c |
children | 969ced346cef |
comparison
equal
deleted
inserted
replaced
1815:3dabc11da660 | 1816:e62c88b2883b |
---|---|
416 </p> | 416 </p> |
417 </li> | 417 </li> |
418 | 418 |
419 <li><p> | 419 <li><p> |
420 <b>"gc":</b> | 420 <b>"gc":</b> |
421 This is when a table is garbage collected. When the table's <a href="https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#finalize()">finalize</a> method is called by the Java garbage collector, if there is a "<code>__gc</code>" metamethod then it is called with the table as a parameter. | 421 This is when a table is garbage collected. When the table's <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--">finalize</a> method is called by the Java garbage collector, if there is a "<code>__gc</code>" metamethod then it is called with the table as a parameter. |
422 </p></li> | 422 </p></li> |
423 | 423 |
424 </ul> | 424 </ul> |
425 <% | 425 <% |
426 end | 426 end |
1309 <li><b><code>^</code>: </b>exponentiation</li> | 1309 <li><b><code>^</code>: </b>exponentiation</li> |
1310 <li><b><code>-</code>: </b>unary minus</li> | 1310 <li><b><code>-</code>: </b>unary minus</li> |
1311 </ul> | 1311 </ul> |
1312 | 1312 |
1313 <p> | 1313 <p> |
1314 Addition, subtraction, multiplication, division, and unary minus are the same as these operators in Java. Exponentiation uses Java's <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Math.html#pow(double,%20double)">Math.pow</a> function. | 1314 Addition, subtraction, multiplication, division, and unary minus are the same as these operators in Java. Exponentiation uses Java's <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#pow-double-double-">Math.pow</a> function. |
1315 </p> | 1315 </p> |
1316 | 1316 |
1317 <p> | 1317 <p> |
1318 Floor division (//) is a division that rounds the quotient towards minus infinity, that is, the floor of the division of its operands. | 1318 Floor division (//) is a division that rounds the quotient towards minus infinity, that is, the floor of the division of its operands. |
1319 </p> | 1319 </p> |
1382 You can change the way that Luan compares tables | 1382 You can change the way that Luan compares tables |
1383 by using the "eq" metamethod (see <a href="#meta">Metatables and Metamethods</a>). | 1383 by using the "eq" metamethod (see <a href="#meta">Metatables and Metamethods</a>). |
1384 </p> | 1384 </p> |
1385 | 1385 |
1386 <p> | 1386 <p> |
1387 Java values are compared for equality with the Java <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#equals(java.lang.Object)"><code>equals</code></a> method. | 1387 Java values are compared for equality with the Java <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-"><code>equals</code></a> method. |
1388 </p> | 1388 </p> |
1389 | 1389 |
1390 <p> | 1390 <p> |
1391 Equality comparisons do not convert strings to numbers | 1391 Equality comparisons do not convert strings to numbers |
1392 or vice versa. | 1392 or vice versa. |
2542 Returns a boolean indicating whether the <code>s</code> contains <code>s2</code>. | 2542 Returns a boolean indicating whether the <code>s</code> contains <code>s2</code>. |
2543 </p> | 2543 </p> |
2544 <% | 2544 <% |
2545 end | 2545 end |
2546 } | 2546 } |
2547 ["String.digest_message"] = { | |
2548 title = "String.digest_message (algorithm, s)" | |
2549 content = function() | |
2550 %> | |
2551 <p>Returns a hex digest string of <code>s</code>. Could be defined as:</p> | |
2552 | |
2553 <code block> | |
2554 function String.digest_message(algorithm,s) | |
2555 return <a href="http://localhost:8080/manual.html#Binary.to_hex">Binary.to_hex</a>( <a href="http://localhost:8080/manual.html#Binary.digest_message">Binary.digest_message</a>( algorithm, <a href="http://localhost:8080/manual.html#String.to_binary">String.to_binary(s)</a> ) ) | |
2556 end | |
2557 </code> | |
2558 <% | |
2559 end | |
2560 } | |
2547 ["String.encode"] = { | 2561 ["String.encode"] = { |
2548 title = "String.encode (s)" | 2562 title = "String.encode (s)" |
2549 content = function() | 2563 content = function() |
2550 %> | 2564 %> |
2551 <p> | 2565 <p> |
2593 content = function() | 2607 content = function() |
2594 %> | 2608 %> |
2595 <p> | 2609 <p> |
2596 Returns a formatted version of its variable number of arguments | 2610 Returns a formatted version of its variable number of arguments |
2597 following the description given in its first argument (which must be a string). | 2611 following the description given in its first argument (which must be a string). |
2598 The format string follows the same rules as the Java function <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#format(java.lang.String,%20java.lang.Object...)"><code>String.format</code></a> because Luan calls this internally. | 2612 The format string follows the same rules as the Java function <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#format-java.lang.String-java.lang.Object...-"><code>String.format</code></a> because Luan calls this internally. |
2599 </p> | 2613 </p> |
2600 | 2614 |
2601 <p> | 2615 <p> |
2602 Note that Java's <code>String.format</code> is too stupid to convert between ints and floats, so you must provide the right kind of number. | 2616 Note that Java's <code>String.format</code> is too stupid to convert between ints and floats, so you must provide the right kind of number. |
2603 </p> | 2617 </p> |
2629 ["String.regex_quote"] = { | 2643 ["String.regex_quote"] = { |
2630 title = "String.regex_quote (s)" | 2644 title = "String.regex_quote (s)" |
2631 content = function() | 2645 content = function() |
2632 %> | 2646 %> |
2633 <p> | 2647 <p> |
2634 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>. | 2648 Returns a string which matches the literal string <code>s</code> in a regular expression. This function is simply the Java method <a href="https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html#quote-java.lang.String-"><code>Pattern.quote</code></a>. |
2635 </p> | 2649 </p> |
2636 <% | 2650 <% |
2637 end | 2651 end |
2638 } | 2652 } |
2639 ["String.repeated"] = { | 2653 ["String.repeated"] = { |
2723 ["String.to_binary"] = { | 2737 ["String.to_binary"] = { |
2724 title = "String.to_binary (s)" | 2738 title = "String.to_binary (s)" |
2725 content = function() | 2739 content = function() |
2726 %> | 2740 %> |
2727 <p> | 2741 <p> |
2728 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>. | 2742 Converts a string to a binary by calling the Java method <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#getBytes--"><code>String.getBytes</code></a>. |
2729 </p> | 2743 </p> |
2730 <% | 2744 <% |
2731 end | 2745 end |
2732 } | 2746 } |
2733 ["String.to_number"] = { | 2747 ["String.to_number"] = { |
2760 ["String.trim"] = { | 2774 ["String.trim"] = { |
2761 title = "String.trim (s)" | 2775 title = "String.trim (s)" |
2762 content = function() | 2776 content = function() |
2763 %> | 2777 %> |
2764 <p> | 2778 <p> |
2765 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>. | 2779 Removes the leading and trailing whitespace by calling the Java method <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#trim--"><code>String.trim</code></a>. |
2766 </p> | 2780 </p> |
2767 <% | 2781 <% |
2768 end | 2782 end |
2769 } | 2783 } |
2770 ["String.unicode"] = { | 2784 ["String.unicode"] = { |
2804 <p> | 2818 <p> |
2805 Regular expressions are handled using a regex table generated by <a href="#String.regex">String.regex</a>. | 2819 Regular expressions are handled using a regex table generated by <a href="#String.regex">String.regex</a>. |
2806 </p> | 2820 </p> |
2807 | 2821 |
2808 <p> | 2822 <p> |
2809 Pattern matching is based on the Java <a href="http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html">Pattern</a> class. | 2823 Pattern matching is based on the Java <a href="https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html">Pattern</a> class. |
2810 </p> | 2824 </p> |
2811 <% | 2825 <% |
2812 end | 2826 end |
2813 subs = { | 2827 subs = { |
2814 ["regex.find"] = { | 2828 ["regex.find"] = { |
3028 local Binary = require "luan:Binary.luan" | 3042 local Binary = require "luan:Binary.luan" |
3029 </code> | 3043 </code> |
3030 <% | 3044 <% |
3031 end | 3045 end |
3032 subs = { | 3046 subs = { |
3047 ["Binary.base64_decode"] = { | |
3048 title = "Binary.base64_decode (s)" | |
3049 content = function() | |
3050 %> | |
3051 <p>Same as Java's <a href="https://docs.oracle.com/javase/8/docs/api/java/util/Base64.Decoder.html#decode-java.lang.String-">Base64.Decoder.decode</a>.</p> | |
3052 <% | |
3053 end | |
3054 } | |
3055 ["Binary.base64_encode"] = { | |
3056 title = "Binary.base64_encode (b)" | |
3057 content = function() | |
3058 %> | |
3059 <p>Same as Java's <a href="https://docs.oracle.com/javase/8/docs/api/java/util/Base64.Encoder.html#encodeToString-byte:A-">Base64.Encoder.encodeToString</a>.</p> | |
3060 <% | |
3061 end | |
3062 } | |
3033 ["Binary.binary"] = { | 3063 ["Binary.binary"] = { |
3034 title = "Binary.binary (···)" | 3064 title = "Binary.binary (···)" |
3035 content = function() | 3065 content = function() |
3036 %> | 3066 %> |
3037 <p> | 3067 <p> |
3056 following the same rules of function <a href="#String.sub"><code>String.sub</code></a>. | 3086 following the same rules of function <a href="#String.sub"><code>String.sub</code></a>. |
3057 </p> | 3087 </p> |
3058 <% | 3088 <% |
3059 end | 3089 end |
3060 } | 3090 } |
3091 ["Binary.digest_message"] = { | |
3092 title = "Binary.digest_message (algorithm, b)" | |
3093 content = function() | |
3094 %> | |
3095 <p>Implemented in Java as:</p> | |
3096 | |
3097 <code block> | |
3098 return <a href="https://docs.oracle.com/javase/8/docs/api/java/security/MessageDigest.html">MessageDigest</a>.<a href="https://docs.oracle.com/javase/8/docs/api/java/security/MessageDigest.html#getInstance-java.lang.String-">getInstance</a>(algorithm).<a href="https://docs.oracle.com/javase/8/docs/api/java/security/MessageDigest.html#digest-byte:A-">digest</a>(b); | |
3099 </code> | |
3100 <% | |
3101 end | |
3102 } | |
3103 ["Binary.to_hex"] = { | |
3104 title = "Binary.to_hex (b)" | |
3105 content = function() | |
3106 %> | |
3107 <p>Converts a binary to a hex string.</p> | |
3108 <% | |
3109 end | |
3110 } | |
3061 ["Binary.to_string"] = { | 3111 ["Binary.to_string"] = { |
3062 title = "Binary.to_string (b [,charset])" | 3112 title = "Binary.to_string (b [,charset])" |
3063 content = function() | 3113 content = function() |
3064 %> | 3114 %> |
3065 <p> | 3115 <p> |
3066 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. | 3116 If <code>charset</code> is not nil then converts the binary <code>b</code> to a string using the Java <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#String-byte:A-java.lang.String-">String constructor</a>, else makes each byte a char. |
3067 </p> | 3117 </p> |
3068 <% | 3118 <% |
3069 end | 3119 end |
3070 } | 3120 } |
3071 } | 3121 } |
3292 ["Number.long_to_string"] = { | 3342 ["Number.long_to_string"] = { |
3293 title = "Number.long_to_string (i, radix)" | 3343 title = "Number.long_to_string (i, radix)" |
3294 content = function() | 3344 content = function() |
3295 %> | 3345 %> |
3296 <p> | 3346 <p> |
3297 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>. | 3347 Converts long value <code>i</code> to a string by calling <code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Long.html#toString-long-int-">Long.toString</a></code>. |
3298 </p> | 3348 </p> |
3299 <% | 3349 <% |
3300 end | 3350 end |
3301 } | 3351 } |
3302 ["Number.type"] = { | 3352 ["Number.type"] = { |