1 line
25 KiB
JSON
1 line
25 KiB
JSON
{"config":{"lang":["en"],"separator":"[\\s\\u200b\\u3000\\-\u3001\u3002\uff0c\uff0e\uff1f\uff01\uff1b]+","pipeline":["stemmer"],"fields":{"title":{"boost":1000.0},"text":{"boost":1.0},"tags":{"boost":1000000.0}}},"docs":[{"location":"","title":"Oraset \u7f16\u7a0b\u8bed\u8a00","text":""},{"location":"#oraset_1","title":"\u4ec0\u4e48\u662f Oraset\uff1f","text":"<p>Oraset \u662f\u4e00\u79cd\u7b80\u5355\u3001\u5f3a\u5927\u3001\u8de8\u5e73\u53f0\u7684\u7f16\u7a0b\u8bed\u8a00\uff0c\u8bbe\u8ba1\u521d\u8877\u662f\u63d0\u4f9b\u4e00\u79cd\u6613\u4e8e\u5b66\u4e60\u548c\u4f7f\u7528\u7684\u7f16\u7a0b\u5de5\u5177\u3002</p>"},{"location":"#_1","title":"\u4e3b\u8981\u7279\u6027","text":"<ul> <li>\u7b80\u5355\u76f4\u89c2\u7684\u8bed\u6cd5\uff1a\u6e05\u6670\u7684\u8bed\u6cd5\u8bbe\u8ba1\uff0c\u6613\u4e8e\u5b66\u4e60\u548c\u4f7f\u7528</li> <li>\u8de8\u5e73\u53f0\u652f\u6301\uff1a\u53ef\u5728 Windows \u548c Linux \u7b49\u591a\u4e2a\u5e73\u53f0\u8fd0\u884c</li> <li>\u4e30\u5bcc\u7684\u5e93\u51fd\u6570\uff1a\u5185\u7f6e\u6570\u5b66\u3001\u5b57\u7b26\u4e32\u3001\u6570\u7ec4\u7b49\u591a\u79cd\u5b9e\u7528\u5e93</li> <li>\u6587\u4ef6\u6253\u5305\u529f\u80fd\uff1a\u652f\u6301\u5c06\u4ee3\u7801\u6253\u5305\u4e3a\u52a0\u5bc6\u7684 .osp \u6587\u4ef6</li> <li>\u7f51\u7edc\u8bf7\u6c42\u80fd\u529b\uff1a\u5185\u7f6e HTTP \u8bf7\u6c42\u529f\u80fd\uff0c\u8f7b\u677e\u4e0e\u7f51\u7edc\u670d\u52a1\u4ea4\u4e92</li> <li>\u6269\u5c55\u6027\uff1a\u652f\u6301\u901a\u8fc7 includes \u76ee\u5f55\u6dfb\u52a0\u81ea\u5b9a\u4e49\u6269\u5c55</li> </ul>"},{"location":"#_2","title":"\u5feb\u901f\u5f00\u59cb","text":""},{"location":"#_3","title":"\u5b89\u88c5","text":"<ol> <li>\u4e0b\u8f7d Oraset \u89e3\u91ca\u5668</li> <li>\u89e3\u538b\u5230\u4efb\u610f\u76ee\u5f55</li> <li>\u5c06 Oraset \u6240\u5728\u76ee\u5f55\u6dfb\u52a0\u5230\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\uff08\u53ef\u9009\uff09</li> </ol>"},{"location":"#_4","title":"\u7b2c\u4e00\u4e2a\u7a0b\u5e8f","text":"<p>\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a <code>hello.oraset</code> \u7684\u6587\u4ef6\uff0c\u5185\u5bb9\u5982\u4e0b\uff1a</p> <pre><code>!! \u7b2c\u4e00\u4e2a Oraset \u7a0b\u5e8f\nshow(`Hello, Oraset!`);\n</code></pre> <p>\u8fd0\u884c\u7a0b\u5e8f\uff1a</p> <pre><code>python oraset.py hello.oraset\n</code></pre>"},{"location":"#_5","title":"\u6587\u6863\u5bfc\u822a","text":"<ul> <li>\u5165\u95e8\u6559\u7a0b - \u5b66\u4e60 Oraset \u7684\u57fa\u672c\u8bed\u6cd5\u548c\u4f7f\u7528\u65b9\u6cd5</li> <li>\u8bed\u6cd5\u53c2\u8003 - \u8be6\u7ec6\u7684\u8bed\u6cd5\u89c4\u5219</li> <li>\u5e93\u51fd\u6570\u53c2\u8003 - \u5185\u7f6e\u5e93\u51fd\u6570\u7684\u4f7f\u7528\u65b9\u6cd5</li> <li>\u9ad8\u7ea7\u7279\u6027 - \u9ad8\u7ea7\u529f\u80fd\u548c\u6700\u4f73\u5b9e\u8df5</li> <li>\u5173\u4e8e\u9879\u76ee - \u9879\u76ee\u4ecb\u7ecd\u548c\u8d21\u732e\u6307\u5357</li> </ul>"},{"location":"#_6","title":"\u793e\u533a","text":"<ul> <li>GitHub \u4ed3\u5e93 - \u6e90\u7801\u548c\u8d21\u732e</li> <li>\u8bba\u575b - \u8ba8\u8bba\u548c\u5e2e\u52a9</li> <li>\u95ee\u9898\u8ffd\u8e2a - \u62a5\u544a\u95ee\u9898</li> </ul>"},{"location":"#_7","title":"\u8bb8\u53ef\u8bc1","text":"<p>Oraset \u4f7f\u7528 GNU \u901a\u7528\u516c\u5171\u8bb8\u53ef\u8bc1 v3.0\u3002</p>"},{"location":"en/","title":"Oraset Programming Language","text":""},{"location":"en/#what-is-oraset","title":"What is Oraset?","text":"<p>Oraset is a simple, powerful, cross-platform programming language designed to provide an easy-to-learn and easy-to-use programming tool.</p>"},{"location":"en/#key-features","title":"Key Features","text":"<ul> <li>Simple and intuitive syntax: Clear syntax design, easy to learn and use</li> <li>Cross-platform support: Runs on multiple platforms including Windows and Linux</li> <li>Rich library functions: Built-in libraries for math, string, array, and more</li> <li>File packaging: Supports packaging code into encrypted .osp files</li> <li>Network capabilities: Built-in HTTP request functionality for easy interaction with web services</li> <li>Extensibility: Supports adding custom extensions through the includes directory</li> </ul>"},{"location":"en/#quick-start","title":"Quick Start","text":""},{"location":"en/#installation","title":"Installation","text":"<ol> <li>Download the Oraset interpreter</li> <li>Extract it to any directory</li> <li>Add the Oraset directory to your system environment variables (optional)</li> </ol>"},{"location":"en/#your-first-program","title":"Your First Program","text":"<p>Create a file named <code>hello.oraset</code> with the following content:</p> <pre><code>!! First Oraset program\nshow(`Hello, Oraset!`);\n</code></pre> <p>Run the program:</p> <pre><code>python oraset.py hello.oraset\n</code></pre>"},{"location":"en/#documentation-navigation","title":"Documentation Navigation","text":"<ul> <li>Getting Started - Learn Oraset's basic syntax and usage</li> <li>Syntax Reference - Detailed syntax rules</li> <li>Library Reference - Usage of built-in libraries</li> <li>Advanced Features - Advanced features and best practices</li> <li>About - Project introduction and contribution guidelines</li> </ul>"},{"location":"en/#community","title":"Community","text":"<ul> <li>GitHub Repository - Source code and contributions</li> <li>Forum - Discussion and help</li> <li>Issue Tracker - Report issues</li> </ul>"},{"location":"en/#license","title":"License","text":"<p>Oraset uses the GNU General Public License v3.0.</p>"},{"location":"en/libraries/math/","title":"Math Library","text":""},{"location":"en/libraries/math/#introduction","title":"Introduction","text":"<p>The math library (<code>@math</code>) provides a range of mathematical functions, including basic operations, trigonometric functions, random number generation, and more.</p>"},{"location":"en/libraries/math/#import","title":"Import","text":"<pre><code>@math;\n</code></pre>"},{"location":"en/libraries/math/#function-reference","title":"Function Reference","text":""},{"location":"en/libraries/math/#basic-math-functions","title":"Basic Math Functions","text":""},{"location":"en/libraries/math/#mathabsx","title":"math.abs(x)","text":"<p>Calculate absolute value.</p> <p>Parameters: - <code>x</code> - Number</p> <p>Returns: - Absolute value of the number</p> <p>Example:</p> <pre><code>show(`abs(-123) = `, math.abs(-123)); // Output: 123\n</code></pre>"},{"location":"en/libraries/math/#mathsqrtx","title":"math.sqrt(x)","text":"<p>Calculate square root.</p> <p>Parameters: - <code>x</code> - Non-negative number</p> <p>Returns: - Square root value</p> <p>Example:</p> <pre><code>show(`sqrt(16) = `, math.sqrt(16)); // Output: 4\n</code></pre>"},{"location":"en/libraries/math/#mathpowx-y","title":"math.pow(x, y)","text":"<p>Calculate power operation.</p> <p>Parameters: - <code>x</code> - Base - <code>y</code> - Exponent</p> <p>Returns: - x raised to the power of y</p> <p>Example:</p> <pre><code>show(`pow(2, 3) = `, math.pow(2, 3)); // Output: 8\n</code></pre>"},{"location":"en/libraries/math/#trigonometric-functions","title":"Trigonometric Functions","text":""},{"location":"en/libraries/math/#mathsinx","title":"math.sin(x)","text":"<p>Calculate sine value (in degrees).</p> <p>Parameters: - <code>x</code> - Angle in degrees</p> <p>Returns: - Sine value</p> <p>Example:</p> <pre><code>show(`sin(90) = `, math.sin(90)); // Output: 1\n</code></pre>"},{"location":"en/libraries/math/#mathcosx","title":"math.cos(x)","text":"<p>Calculate cosine value (in degrees).</p> <p>Parameters: - <code>x</code> - Angle in degrees</p> <p>Returns: - Cosine value</p> <p>Example:</p> <pre><code>show(`cos(0) = `, math.cos(0)); // Output: 1\n</code></pre>"},{"location":"en/libraries/math/#mathtanx","title":"math.tan(x)","text":"<p>Calculate tangent value (in degrees).</p> <p>Parameters: - <code>x</code> - Angle in degrees</p> <p>Returns: - Tangent value</p> <p>Example:</p> <pre><code>show(`tan(45) = `, math.tan(45)); // Output: 1\n</code></pre>"},{"location":"en/libraries/math/#math-constants","title":"Math Constants","text":""},{"location":"en/libraries/math/#mathpi","title":"math.pi()","text":"<p>Return the value of pi (\u03c0).</p> <p>Parameters: None</p> <p>Returns: - Value of \u03c0 (approximately 3.14159...)</p> <p>Example:</p> <pre><code>show(`\u03c0 = `, math.pi()); // Output: 3.141592653589793\n</code></pre>"},{"location":"en/libraries/math/#mathe","title":"math.e()","text":"<p>Return the value of Euler's number (e).</p> <p>Parameters: None</p> <p>Returns: - Value of e (approximately 2.71828...)</p> <p>Example:</p> <pre><code>show(`e = `, math.e()); // Output: 2.718281828459045\n</code></pre>"},{"location":"en/libraries/math/#extremum-functions","title":"Extremum Functions","text":""},{"location":"en/libraries/math/#mathmaxargs","title":"math.max(...args)","text":"<p>Calculate the maximum of multiple numbers.</p> <p>Parameters: - <code>...args</code> - Multiple numbers</p> <p>Returns: - Maximum value</p> <p>Example:</p> <pre><code>show(`max(10, 5, 20) = `, math.max(10, 5, 20)); // Output: 20\n</code></pre>"},{"location":"en/libraries/math/#mathminargs","title":"math.min(...args)","text":"<p>Calculate the minimum of multiple numbers.</p> <p>Parameters: - <code>...args</code> - Multiple numbers</p> <p>Returns: - Minimum value</p> <p>Example:</p> <pre><code>show(`min(10, 5, 20) = `, math.min(10, 5, 20)); // Output: 5\n</code></pre>"},{"location":"en/libraries/math/#random-number-functions","title":"Random Number Functions","text":""},{"location":"en/libraries/math/#mathrandom","title":"math.random()","text":"<p>Generate a random number between 0 and 1.</p> <p>Parameters: None</p> <p>Returns: - Random float between 0 and 1</p> <p>Example:</p> <pre><code>show(`random() = `, math.random()); // Output: 0.123456...\n</code></pre>"},{"location":"en/libraries/math/#mathrandinta-b","title":"math.randint(a, b)","text":"<p>Generate a random integer within a specified range.</p> <p>Parameters: - <code>a</code> - Minimum value - <code>b</code> - Maximum value</p> <p>Returns: - Random integer between a and b (inclusive)</p> <p>Example:</p> <pre><code>show(`randint(1, 100) = `, math.randint(1, 100)); // Output: 42\n</code></pre>"},{"location":"en/libraries/math/#example-code","title":"Example Code","text":"<pre><code>@math;\n\n!! Basic operations\nshow(`abs(-123) = `, math.abs(-123));\nshow(`sqrt(16) = `, math.sqrt(16));\nshow(`pow(2, 3) = `, math.pow(2, 3));\n\n!! Trigonometric functions\nshow(`sin(90) = `, math.sin(90));\nshow(`cos(0) = `, math.cos(0));\nshow(`tan(45) = `, math.tan(45));\n\n!! Math constants\nshow(`\u03c0 = `, math.pi());\nshow(`e = `, math.e());\n\n!! Extremum\nshow(`max(10, 5, 20) = `, math.max(10, 5, 20));\nshow(`min(10, 5, 20) = `, math.min(10, 5, 20));\n\n!! Random numbers\nshow(`random() = `, math.random());\nshow(`randint(1, 100) = `, math.randint(1, 100));\n</code></pre>"},{"location":"en/tutorial/quickstart/","title":"Quick Start","text":""},{"location":"en/tutorial/quickstart/#installing-oraset","title":"Installing Oraset","text":""},{"location":"en/tutorial/quickstart/#from-source","title":"From Source","text":"<ol> <li>Clone or download the Oraset source code to your local machine</li> <li>Ensure your system has Python 3.6 or higher installed</li> <li>Navigate to the Oraset directory and run the <code>oraset.py</code> file directly</li> </ol>"},{"location":"en/tutorial/quickstart/#from-binary","title":"From Binary","text":"<ol> <li>Download the binary file for your platform (<code>.exe</code> for Windows, executable for Linux)</li> <li>Extract it to any directory</li> <li>Add the executable directory to your system environment variables (optional)</li> </ol>"},{"location":"en/tutorial/quickstart/#running-your-first-program","title":"Running Your First Program","text":""},{"location":"en/tutorial/quickstart/#create-a-program-file","title":"Create a Program File","text":"<p>Create a file named <code>hello.oraset</code> with the following content:</p> <pre><code>!! This is a comment\nshow(`Hello, Oraset!`);\n</code></pre>"},{"location":"en/tutorial/quickstart/#run-the-program","title":"Run the Program","text":""},{"location":"en/tutorial/quickstart/#using-python","title":"Using Python","text":"<pre><code>python oraset.py hello.oraset\n</code></pre>"},{"location":"en/tutorial/quickstart/#using-binary","title":"Using Binary","text":"<pre><code># Windows\noraset.exe hello.oraset\n\n# Linux\n./oraset hello.oraset\n</code></pre>"},{"location":"en/tutorial/quickstart/#expected-output","title":"Expected Output","text":"<p>After running the program, you should see the following output:</p> <pre><code>Hello, Oraset!\n</code></pre>"},{"location":"en/tutorial/quickstart/#basic-syntax-examples","title":"Basic Syntax Examples","text":""},{"location":"en/tutorial/quickstart/#variable-assignment","title":"Variable Assignment","text":"<pre><code>name = `John`;\nage = 25;\nprice = 9.99;\n</code></pre>"},{"location":"en/tutorial/quickstart/#output","title":"Output","text":"<pre><code>show(`Name: `, name);\nshow(`Age: `, age);\nshow(`Price: `, price);\n</code></pre>"},{"location":"en/tutorial/quickstart/#simple-calculation","title":"Simple Calculation","text":"<pre><code>num1 = 10;\nnum2 = 20;\nsum = num1 + num2;\nshow(`Sum: `, sum);\n</code></pre>"},{"location":"en/tutorial/quickstart/#next-steps","title":"Next Steps","text":"<ul> <li>Learn about Basic Syntax for more syntax rules</li> <li>Understand how to use Data Types</li> <li>Learn about Control Structures like conditionals and loops</li> <li>Explore Functions for defining and using functions</li> </ul>"},{"location":"en/tutorial/quickstart/#common-issues","title":"Common Issues","text":""},{"location":"en/tutorial/quickstart/#no-output-when-running-program","title":"No Output When Running Program","text":"<ul> <li>Check if you're using the <code>show</code> function</li> <li>Ensure the file path is correct</li> <li>Check for syntax errors</li> </ul>"},{"location":"en/tutorial/quickstart/#syntax-errors","title":"Syntax Errors","text":"<ul> <li>Check that parentheses are matched</li> <li>Ensure strings are enclosed in backticks</li> <li>Verify variable names are correct</li> </ul>"},{"location":"en/tutorial/quickstart/#command-not-found","title":"Command Not Found","text":"<ul> <li>Ensure the Oraset directory is added to your environment variables</li> <li>Or use the absolute path to run</li> </ul>"},{"location":"en/tutorial/quickstart/#example-code","title":"Example Code","text":""},{"location":"en/tutorial/quickstart/#calculating-factorial","title":"Calculating Factorial","text":"<pre><code>def factorial(n) {\n if (n <= 1) {\n return 1;\n }\n return n * factorial(n - 1);\n}\n\nshow(`5! = `, factorial(5));\n</code></pre>"},{"location":"en/tutorial/quickstart/#array-operations","title":"Array Operations","text":"<pre><code>fruits = arr(`apple`, `banana`, `cherry`);\nshow(`Fruits: `, fruits);\nshow(`First fruit: `, fruits[0]);\n</code></pre>"},{"location":"libraries/math/","title":"\u6570\u5b66\u5e93","text":""},{"location":"libraries/math/#_2","title":"\u7b80\u4ecb","text":"<p>\u6570\u5b66\u5e93\uff08<code>@math</code>\uff09\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u6570\u5b66\u8fd0\u7b97\u51fd\u6570\uff0c\u5305\u62ec\u57fa\u672c\u8fd0\u7b97\u3001\u4e09\u89d2\u51fd\u6570\u3001\u968f\u673a\u6570\u751f\u6210\u7b49\u3002</p>"},{"location":"libraries/math/#_3","title":"\u5bfc\u5165\u65b9\u5f0f","text":"<pre><code>@math;\n</code></pre>"},{"location":"libraries/math/#_4","title":"\u51fd\u6570\u53c2\u8003","text":""},{"location":"libraries/math/#_5","title":"\u57fa\u672c\u6570\u5b66\u51fd\u6570","text":""},{"location":"libraries/math/#mathabsx","title":"math.abs(x)","text":"<p>\u8ba1\u7b97\u7edd\u5bf9\u503c\u3002</p> <p>\u53c2\u6570\uff1a - <code>x</code> - \u6570\u5b57</p> <p>\u8fd4\u56de\u503c\uff1a - \u6570\u5b57\u7684\u7edd\u5bf9\u503c</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>show(`abs(-123) = `, math.abs(-123)); // \u8f93\u51fa: 123\n</code></pre>"},{"location":"libraries/math/#mathsqrtx","title":"math.sqrt(x)","text":"<p>\u8ba1\u7b97\u5e73\u65b9\u6839\u3002</p> <p>\u53c2\u6570\uff1a - <code>x</code> - \u975e\u8d1f\u6570</p> <p>\u8fd4\u56de\u503c\uff1a - \u5e73\u65b9\u6839\u503c</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>show(`sqrt(16) = `, math.sqrt(16)); // \u8f93\u51fa: 4\n</code></pre>"},{"location":"libraries/math/#mathpowx-y","title":"math.pow(x, y)","text":"<p>\u8ba1\u7b97\u5e42\u8fd0\u7b97\u3002</p> <p>\u53c2\u6570\uff1a - <code>x</code> - \u5e95\u6570 - <code>y</code> - \u6307\u6570</p> <p>\u8fd4\u56de\u503c\uff1a - x \u7684 y \u6b21\u5e42</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>show(`pow(2, 3) = `, math.pow(2, 3)); // \u8f93\u51fa: 8\n</code></pre>"},{"location":"libraries/math/#_6","title":"\u4e09\u89d2\u51fd\u6570","text":""},{"location":"libraries/math/#mathsinx","title":"math.sin(x)","text":"<p>\u8ba1\u7b97\u6b63\u5f26\u503c\uff08\u89d2\u5ea6\uff09\u3002</p> <p>\u53c2\u6570\uff1a - <code>x</code> - \u89d2\u5ea6\u503c</p> <p>\u8fd4\u56de\u503c\uff1a - \u6b63\u5f26\u503c</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>show(`sin(90) = `, math.sin(90)); // \u8f93\u51fa: 1\n</code></pre>"},{"location":"libraries/math/#mathcosx","title":"math.cos(x)","text":"<p>\u8ba1\u7b97\u4f59\u5f26\u503c\uff08\u89d2\u5ea6\uff09\u3002</p> <p>\u53c2\u6570\uff1a - <code>x</code> - \u89d2\u5ea6\u503c</p> <p>\u8fd4\u56de\u503c\uff1a - \u4f59\u5f26\u503c</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>show(`cos(0) = `, math.cos(0)); // \u8f93\u51fa: 1\n</code></pre>"},{"location":"libraries/math/#mathtanx","title":"math.tan(x)","text":"<p>\u8ba1\u7b97\u6b63\u5207\u503c\uff08\u89d2\u5ea6\uff09\u3002</p> <p>\u53c2\u6570\uff1a - <code>x</code> - \u89d2\u5ea6\u503c</p> <p>\u8fd4\u56de\u503c\uff1a - \u6b63\u5207\u503c</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>show(`tan(45) = `, math.tan(45)); // \u8f93\u51fa: 1\n</code></pre>"},{"location":"libraries/math/#_7","title":"\u6570\u5b66\u5e38\u6570","text":""},{"location":"libraries/math/#mathpi","title":"math.pi()","text":"<p>\u8fd4\u56de\u5706\u5468\u7387 \u03c0 \u7684\u503c\u3002</p> <p>\u53c2\u6570\uff1a \u65e0</p> <p>\u8fd4\u56de\u503c\uff1a - \u03c0 \u7684\u503c\uff08\u7ea6 3.14159...\uff09</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>show(`\u03c0 = `, math.pi()); // \u8f93\u51fa: 3.141592653589793\n</code></pre>"},{"location":"libraries/math/#mathe","title":"math.e()","text":"<p>\u8fd4\u56de\u81ea\u7136\u5bf9\u6570\u5e95\u6570 e \u7684\u503c\u3002</p> <p>\u53c2\u6570\uff1a \u65e0</p> <p>\u8fd4\u56de\u503c\uff1a - e \u7684\u503c\uff08\u7ea6 2.71828...\uff09</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>show(`e = `, math.e()); // \u8f93\u51fa: 2.718281828459045\n</code></pre>"},{"location":"libraries/math/#_8","title":"\u6700\u503c\u51fd\u6570","text":""},{"location":"libraries/math/#mathmaxargs","title":"math.max(...args)","text":"<p>\u8ba1\u7b97\u591a\u4e2a\u6570\u7684\u6700\u5927\u503c\u3002</p> <p>\u53c2\u6570\uff1a - <code>...args</code> - \u591a\u4e2a\u6570\u5b57</p> <p>\u8fd4\u56de\u503c\uff1a - \u6700\u5927\u503c</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>show(`max(10, 5, 20) = `, math.max(10, 5, 20)); // \u8f93\u51fa: 20\n</code></pre>"},{"location":"libraries/math/#mathminargs","title":"math.min(...args)","text":"<p>\u8ba1\u7b97\u591a\u4e2a\u6570\u7684\u6700\u5c0f\u503c\u3002</p> <p>\u53c2\u6570\uff1a - <code>...args</code> - \u591a\u4e2a\u6570\u5b57</p> <p>\u8fd4\u56de\u503c\uff1a - \u6700\u5c0f\u503c</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>show(`min(10, 5, 20) = `, math.min(10, 5, 20)); // \u8f93\u51fa: 5\n</code></pre>"},{"location":"libraries/math/#_9","title":"\u968f\u673a\u6570\u51fd\u6570","text":""},{"location":"libraries/math/#mathrandom","title":"math.random()","text":"<p>\u751f\u6210 0 \u5230 1 \u4e4b\u95f4\u7684\u968f\u673a\u6570\u3002</p> <p>\u53c2\u6570\uff1a \u65e0</p> <p>\u8fd4\u56de\u503c\uff1a - 0 \u5230 1 \u4e4b\u95f4\u7684\u968f\u673a\u6d6e\u70b9\u6570</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>show(`random() = `, math.random()); // \u8f93\u51fa: 0.123456...\n</code></pre>"},{"location":"libraries/math/#mathrandinta-b","title":"math.randint(a, b)","text":"<p>\u751f\u6210\u6307\u5b9a\u8303\u56f4\u5185\u7684\u968f\u673a\u6574\u6570\u3002</p> <p>\u53c2\u6570\uff1a - <code>a</code> - \u6700\u5c0f\u503c - <code>b</code> - \u6700\u5927\u503c</p> <p>\u8fd4\u56de\u503c\uff1a - a \u5230 b \u4e4b\u95f4\u7684\u968f\u673a\u6574\u6570\uff08\u5305\u542b a \u548c b\uff09</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>show(`randint(1, 100) = `, math.randint(1, 100)); // \u8f93\u51fa: 42\n</code></pre>"},{"location":"libraries/math/#_10","title":"\u793a\u4f8b\u4ee3\u7801","text":"<pre><code>@math;\n\n!! \u57fa\u672c\u8fd0\u7b97\nshow(`abs(-123) = `, math.abs(-123));\nshow(`sqrt(16) = `, math.sqrt(16));\nshow(`pow(2, 3) = `, math.pow(2, 3));\n\n!! \u4e09\u89d2\u51fd\u6570\nshow(`sin(90) = `, math.sin(90));\nshow(`cos(0) = `, math.cos(0));\nshow(`tan(45) = `, math.tan(45));\n\n!! \u6570\u5b66\u5e38\u6570\nshow(`\u03c0 = `, math.pi());\nshow(`e = `, math.e());\n\n!! \u6700\u503c\nshow(`max(10, 5, 20) = `, math.max(10, 5, 20));\nshow(`min(10, 5, 20) = `, math.min(10, 5, 20));\n\n!! \u968f\u673a\u6570\nshow(`random() = `, math.random());\nshow(`randint(1, 100) = `, math.randint(1, 100));\n</code></pre>"},{"location":"tutorial/quickstart/","title":"\u5feb\u901f\u5f00\u59cb","text":""},{"location":"tutorial/quickstart/#oraset","title":"\u5b89\u88c5 Oraset","text":""},{"location":"tutorial/quickstart/#_2","title":"\u4ece\u6e90\u7801\u5b89\u88c5","text":"<ol> <li>\u514b\u9686\u6216\u4e0b\u8f7d Oraset \u6e90\u7801\u5230\u672c\u5730</li> <li>\u786e\u4fdd\u4f60\u7684\u7cfb\u7edf\u5df2\u5b89\u88c5 Python 3.6 \u6216\u66f4\u9ad8\u7248\u672c</li> <li>\u8fdb\u5165 Oraset \u76ee\u5f55\uff0c\u76f4\u63a5\u8fd0\u884c <code>oraset.py</code> \u6587\u4ef6</li> </ol>"},{"location":"tutorial/quickstart/#_3","title":"\u4ece\u4e8c\u8fdb\u5236\u5b89\u88c5","text":"<ol> <li>\u4e0b\u8f7d\u5bf9\u5e94\u5e73\u53f0\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\uff08Windows \u4e3a .exe \u6587\u4ef6\uff0cLinux \u4e3a\u53ef\u6267\u884c\u6587\u4ef6\uff09</li> <li>\u89e3\u538b\u5230\u4efb\u610f\u76ee\u5f55</li> <li>\u5c06\u53ef\u6267\u884c\u6587\u4ef6\u6240\u5728\u76ee\u5f55\u6dfb\u52a0\u5230\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\uff08\u53ef\u9009\uff09</li> </ol>"},{"location":"tutorial/quickstart/#_4","title":"\u8fd0\u884c\u4f60\u7684\u7b2c\u4e00\u4e2a\u7a0b\u5e8f","text":""},{"location":"tutorial/quickstart/#_5","title":"\u521b\u5efa\u7a0b\u5e8f\u6587\u4ef6","text":"<p>\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a <code>hello.oraset</code> \u7684\u6587\u4ef6\uff0c\u5185\u5bb9\u5982\u4e0b\uff1a</p> <pre><code>!! \u8fd9\u662f\u4e00\u4e2a\u6ce8\u91ca\nshow(`Hello, Oraset!`);\n</code></pre>"},{"location":"tutorial/quickstart/#_6","title":"\u8fd0\u884c\u7a0b\u5e8f","text":""},{"location":"tutorial/quickstart/#python","title":"\u4f7f\u7528 Python \u8fd0\u884c","text":"<pre><code>python oraset.py hello.oraset\n</code></pre>"},{"location":"tutorial/quickstart/#_7","title":"\u4f7f\u7528\u4e8c\u8fdb\u5236\u6587\u4ef6\u8fd0\u884c","text":"<pre><code># Windows\noraset.exe hello.oraset\n\n# Linux\n./oraset hello.oraset\n</code></pre>"},{"location":"tutorial/quickstart/#_8","title":"\u8fd0\u884c\u7ed3\u679c","text":"<p>\u7a0b\u5e8f\u8fd0\u884c\u540e\uff0c\u4f60\u5e94\u8be5\u4f1a\u770b\u5230\u5982\u4e0b\u8f93\u51fa\uff1a</p> <pre><code>Hello, Oraset!\n</code></pre>"},{"location":"tutorial/quickstart/#_9","title":"\u57fa\u672c\u8bed\u6cd5\u793a\u4f8b","text":""},{"location":"tutorial/quickstart/#_10","title":"\u53d8\u91cf\u8d4b\u503c","text":"<pre><code>name = `John`;\nage = 25;\nprice = 9.99;\n</code></pre>"},{"location":"tutorial/quickstart/#_11","title":"\u8f93\u51fa","text":"<pre><code>show(`Name: `, name);\nshow(`Age: `, age);\nshow(`Price: `, price);\n</code></pre>"},{"location":"tutorial/quickstart/#_12","title":"\u7b80\u5355\u8ba1\u7b97","text":"<pre><code>num1 = 10;\nnum2 = 20;\nsum = num1 + num2;\nshow(`Sum: `, sum);\n</code></pre>"},{"location":"tutorial/quickstart/#_13","title":"\u4e0b\u4e00\u6b65","text":"<ul> <li>\u5b66\u4e60 \u57fa\u672c\u8bed\u6cd5 \u4e86\u89e3\u66f4\u591a\u8bed\u6cd5\u89c4\u5219</li> <li>\u4e86\u89e3 \u6570\u636e\u7c7b\u578b \u7684\u4f7f\u7528</li> <li>\u5b66\u4e60 \u63a7\u5236\u7ed3\u6784 \u5982\u6761\u4ef6\u8bed\u53e5\u548c\u5faa\u73af</li> <li>\u63a2\u7d22 \u51fd\u6570 \u7684\u5b9a\u4e49\u548c\u4f7f\u7528</li> </ul>"},{"location":"tutorial/quickstart/#_14","title":"\u5e38\u89c1\u95ee\u9898","text":""},{"location":"tutorial/quickstart/#_15","title":"\u7a0b\u5e8f\u8fd0\u884c\u65f6\u6ca1\u6709\u8f93\u51fa","text":"<ul> <li>\u68c0\u67e5\u662f\u5426\u4f7f\u7528\u4e86 <code>show</code> \u51fd\u6570</li> <li>\u786e\u4fdd\u6587\u4ef6\u8def\u5f84\u6b63\u786e</li> <li>\u68c0\u67e5\u662f\u5426\u6709\u8bed\u6cd5\u9519\u8bef</li> </ul>"},{"location":"tutorial/quickstart/#_16","title":"\u8bed\u6cd5\u9519\u8bef","text":"<ul> <li>\u68c0\u67e5\u62ec\u53f7\u662f\u5426\u5339\u914d</li> <li>\u786e\u4fdd\u5b57\u7b26\u4e32\u4f7f\u7528\u53cd\u5f15\u53f7\u5305\u56f4</li> <li>\u68c0\u67e5\u53d8\u91cf\u540d\u662f\u5426\u6b63\u786e</li> </ul>"},{"location":"tutorial/quickstart/#_17","title":"\u627e\u4e0d\u5230\u547d\u4ee4","text":"<ul> <li>\u786e\u4fdd Oraset \u6240\u5728\u76ee\u5f55\u5df2\u6dfb\u52a0\u5230\u73af\u5883\u53d8\u91cf</li> <li>\u6216\u4f7f\u7528\u7edd\u5bf9\u8def\u5f84\u8fd0\u884c</li> </ul>"},{"location":"tutorial/quickstart/#_18","title":"\u793a\u4f8b\u4ee3\u7801","text":""},{"location":"tutorial/quickstart/#_19","title":"\u8ba1\u7b97\u9636\u4e58","text":"<pre><code>def factorial(n) {\n if (n <= 1) {\n return 1;\n }\n return n * factorial(n - 1);\n}\n\nshow(`5! = `, factorial(5));\n</code></pre>"},{"location":"tutorial/quickstart/#_20","title":"\u6570\u7ec4\u64cd\u4f5c","text":"<pre><code>fruits = arr(`apple`, `banana`, `cherry`);\nshow(`Fruits: `, fruits);\nshow(`First fruit: `, fruits[0]);\n</code></pre>"}]} |