{"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":"
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
"},{"location":"#_1","title":"\u4e3b\u8981\u7279\u6027","text":"\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a hello.oraset \u7684\u6587\u4ef6\uff0c\u5185\u5bb9\u5982\u4e0b\uff1a
!! \u7b2c\u4e00\u4e2a Oraset \u7a0b\u5e8f\nshow(`Hello, Oraset!`);\n \u8fd0\u884c\u7a0b\u5e8f\uff1a
python oraset.py hello.oraset\n"},{"location":"#_5","title":"\u6587\u6863\u5bfc\u822a","text":"Oraset \u4f7f\u7528 GNU \u901a\u7528\u516c\u5171\u8bb8\u53ef\u8bc1 v3.0\u3002
"},{"location":"en/","title":"Oraset Programming Language","text":""},{"location":"en/#what-is-oraset","title":"What is Oraset?","text":"Oraset is a simple, powerful, cross-platform programming language designed to provide an easy-to-learn and easy-to-use programming tool.
"},{"location":"en/#key-features","title":"Key Features","text":"Create a file named hello.oraset with the following content:
!! First Oraset program\nshow(`Hello, Oraset!`);\n Run the program:
python oraset.py hello.oraset\n"},{"location":"en/#documentation-navigation","title":"Documentation Navigation","text":"Oraset uses the GNU General Public License v3.0.
"},{"location":"en/libraries/math/","title":"Math Library","text":""},{"location":"en/libraries/math/#introduction","title":"Introduction","text":"The math library (@math) provides a range of mathematical functions, including basic operations, trigonometric functions, random number generation, and more.
@math;\n"},{"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":"Calculate absolute value.
Parameters: - x - Number
Returns: - Absolute value of the number
Example:
show(`abs(-123) = `, math.abs(-123)); // Output: 123\n"},{"location":"en/libraries/math/#mathsqrtx","title":"math.sqrt(x)","text":"Calculate square root.
Parameters: - x - Non-negative number
Returns: - Square root value
Example:
show(`sqrt(16) = `, math.sqrt(16)); // Output: 4\n"},{"location":"en/libraries/math/#mathpowx-y","title":"math.pow(x, y)","text":"Calculate power operation.
Parameters: - x - Base - y - Exponent
Returns: - x raised to the power of y
Example:
show(`pow(2, 3) = `, math.pow(2, 3)); // Output: 8\n"},{"location":"en/libraries/math/#trigonometric-functions","title":"Trigonometric Functions","text":""},{"location":"en/libraries/math/#mathsinx","title":"math.sin(x)","text":"Calculate sine value (in degrees).
Parameters: - x - Angle in degrees
Returns: - Sine value
Example:
show(`sin(90) = `, math.sin(90)); // Output: 1\n"},{"location":"en/libraries/math/#mathcosx","title":"math.cos(x)","text":"Calculate cosine value (in degrees).
Parameters: - x - Angle in degrees
Returns: - Cosine value
Example:
show(`cos(0) = `, math.cos(0)); // Output: 1\n"},{"location":"en/libraries/math/#mathtanx","title":"math.tan(x)","text":"Calculate tangent value (in degrees).
Parameters: - x - Angle in degrees
Returns: - Tangent value
Example:
show(`tan(45) = `, math.tan(45)); // Output: 1\n"},{"location":"en/libraries/math/#math-constants","title":"Math Constants","text":""},{"location":"en/libraries/math/#mathpi","title":"math.pi()","text":"Return the value of pi (\u03c0).
Parameters: None
Returns: - Value of \u03c0 (approximately 3.14159...)
Example:
show(`\u03c0 = `, math.pi()); // Output: 3.141592653589793\n"},{"location":"en/libraries/math/#mathe","title":"math.e()","text":"Return the value of Euler's number (e).
Parameters: None
Returns: - Value of e (approximately 2.71828...)
Example:
show(`e = `, math.e()); // Output: 2.718281828459045\n"},{"location":"en/libraries/math/#extremum-functions","title":"Extremum Functions","text":""},{"location":"en/libraries/math/#mathmaxargs","title":"math.max(...args)","text":"Calculate the maximum of multiple numbers.
Parameters: - ...args - Multiple numbers
Returns: - Maximum value
Example:
show(`max(10, 5, 20) = `, math.max(10, 5, 20)); // Output: 20\n"},{"location":"en/libraries/math/#mathminargs","title":"math.min(...args)","text":"Calculate the minimum of multiple numbers.
Parameters: - ...args - Multiple numbers
Returns: - Minimum value
Example:
show(`min(10, 5, 20) = `, math.min(10, 5, 20)); // Output: 5\n"},{"location":"en/libraries/math/#random-number-functions","title":"Random Number Functions","text":""},{"location":"en/libraries/math/#mathrandom","title":"math.random()","text":"Generate a random number between 0 and 1.
Parameters: None
Returns: - Random float between 0 and 1
Example:
show(`random() = `, math.random()); // Output: 0.123456...\n"},{"location":"en/libraries/math/#mathrandinta-b","title":"math.randint(a, b)","text":"Generate a random integer within a specified range.
Parameters: - a - Minimum value - b - Maximum value
Returns: - Random integer between a and b (inclusive)
Example:
show(`randint(1, 100) = `, math.randint(1, 100)); // Output: 42\n"},{"location":"en/libraries/math/#example-code","title":"Example Code","text":"@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"},{"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":"oraset.py file directly.exe for Windows, executable for Linux)Create a file named hello.oraset with the following content:
!! This is a comment\nshow(`Hello, Oraset!`);\n"},{"location":"en/tutorial/quickstart/#run-the-program","title":"Run the Program","text":""},{"location":"en/tutorial/quickstart/#using-python","title":"Using Python","text":"python oraset.py hello.oraset\n"},{"location":"en/tutorial/quickstart/#using-binary","title":"Using Binary","text":"# Windows\noraset.exe hello.oraset\n\n# Linux\n./oraset hello.oraset\n"},{"location":"en/tutorial/quickstart/#expected-output","title":"Expected Output","text":"After running the program, you should see the following output:
Hello, Oraset!\n"},{"location":"en/tutorial/quickstart/#basic-syntax-examples","title":"Basic Syntax Examples","text":""},{"location":"en/tutorial/quickstart/#variable-assignment","title":"Variable Assignment","text":"name = `John`;\nage = 25;\nprice = 9.99;\n"},{"location":"en/tutorial/quickstart/#output","title":"Output","text":"show(`Name: `, name);\nshow(`Age: `, age);\nshow(`Price: `, price);\n"},{"location":"en/tutorial/quickstart/#simple-calculation","title":"Simple Calculation","text":"num1 = 10;\nnum2 = 20;\nsum = num1 + num2;\nshow(`Sum: `, sum);\n"},{"location":"en/tutorial/quickstart/#next-steps","title":"Next Steps","text":"show functiondef factorial(n) {\n if (n <= 1) {\n return 1;\n }\n return n * factorial(n - 1);\n}\n\nshow(`5! = `, factorial(5));\n"},{"location":"en/tutorial/quickstart/#array-operations","title":"Array Operations","text":"fruits = arr(`apple`, `banana`, `cherry`);\nshow(`Fruits: `, fruits);\nshow(`First fruit: `, fruits[0]);\n"},{"location":"libraries/math/","title":"\u6570\u5b66\u5e93","text":""},{"location":"libraries/math/#_2","title":"\u7b80\u4ecb","text":"\u6570\u5b66\u5e93\uff08@math\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
@math;\n"},{"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":"\u8ba1\u7b97\u7edd\u5bf9\u503c\u3002
\u53c2\u6570\uff1a - x - \u6570\u5b57
\u8fd4\u56de\u503c\uff1a - \u6570\u5b57\u7684\u7edd\u5bf9\u503c
\u793a\u4f8b\uff1a
show(`abs(-123) = `, math.abs(-123)); // \u8f93\u51fa: 123\n"},{"location":"libraries/math/#mathsqrtx","title":"math.sqrt(x)","text":"\u8ba1\u7b97\u5e73\u65b9\u6839\u3002
\u53c2\u6570\uff1a - x - \u975e\u8d1f\u6570
\u8fd4\u56de\u503c\uff1a - \u5e73\u65b9\u6839\u503c
\u793a\u4f8b\uff1a
show(`sqrt(16) = `, math.sqrt(16)); // \u8f93\u51fa: 4\n"},{"location":"libraries/math/#mathpowx-y","title":"math.pow(x, y)","text":"\u8ba1\u7b97\u5e42\u8fd0\u7b97\u3002
\u53c2\u6570\uff1a - x - \u5e95\u6570 - y - \u6307\u6570
\u8fd4\u56de\u503c\uff1a - x \u7684 y \u6b21\u5e42
\u793a\u4f8b\uff1a
show(`pow(2, 3) = `, math.pow(2, 3)); // \u8f93\u51fa: 8\n"},{"location":"libraries/math/#_6","title":"\u4e09\u89d2\u51fd\u6570","text":""},{"location":"libraries/math/#mathsinx","title":"math.sin(x)","text":"\u8ba1\u7b97\u6b63\u5f26\u503c\uff08\u89d2\u5ea6\uff09\u3002
\u53c2\u6570\uff1a - x - \u89d2\u5ea6\u503c
\u8fd4\u56de\u503c\uff1a - \u6b63\u5f26\u503c
\u793a\u4f8b\uff1a
show(`sin(90) = `, math.sin(90)); // \u8f93\u51fa: 1\n"},{"location":"libraries/math/#mathcosx","title":"math.cos(x)","text":"\u8ba1\u7b97\u4f59\u5f26\u503c\uff08\u89d2\u5ea6\uff09\u3002
\u53c2\u6570\uff1a - x - \u89d2\u5ea6\u503c
\u8fd4\u56de\u503c\uff1a - \u4f59\u5f26\u503c
\u793a\u4f8b\uff1a
show(`cos(0) = `, math.cos(0)); // \u8f93\u51fa: 1\n"},{"location":"libraries/math/#mathtanx","title":"math.tan(x)","text":"\u8ba1\u7b97\u6b63\u5207\u503c\uff08\u89d2\u5ea6\uff09\u3002
\u53c2\u6570\uff1a - x - \u89d2\u5ea6\u503c
\u8fd4\u56de\u503c\uff1a - \u6b63\u5207\u503c
\u793a\u4f8b\uff1a
show(`tan(45) = `, math.tan(45)); // \u8f93\u51fa: 1\n"},{"location":"libraries/math/#_7","title":"\u6570\u5b66\u5e38\u6570","text":""},{"location":"libraries/math/#mathpi","title":"math.pi()","text":"\u8fd4\u56de\u5706\u5468\u7387 \u03c0 \u7684\u503c\u3002
\u53c2\u6570\uff1a \u65e0
\u8fd4\u56de\u503c\uff1a - \u03c0 \u7684\u503c\uff08\u7ea6 3.14159...\uff09
\u793a\u4f8b\uff1a
show(`\u03c0 = `, math.pi()); // \u8f93\u51fa: 3.141592653589793\n"},{"location":"libraries/math/#mathe","title":"math.e()","text":"\u8fd4\u56de\u81ea\u7136\u5bf9\u6570\u5e95\u6570 e \u7684\u503c\u3002
\u53c2\u6570\uff1a \u65e0
\u8fd4\u56de\u503c\uff1a - e \u7684\u503c\uff08\u7ea6 2.71828...\uff09
\u793a\u4f8b\uff1a
show(`e = `, math.e()); // \u8f93\u51fa: 2.718281828459045\n"},{"location":"libraries/math/#_8","title":"\u6700\u503c\u51fd\u6570","text":""},{"location":"libraries/math/#mathmaxargs","title":"math.max(...args)","text":"\u8ba1\u7b97\u591a\u4e2a\u6570\u7684\u6700\u5927\u503c\u3002
\u53c2\u6570\uff1a - ...args - \u591a\u4e2a\u6570\u5b57
\u8fd4\u56de\u503c\uff1a - \u6700\u5927\u503c
\u793a\u4f8b\uff1a
show(`max(10, 5, 20) = `, math.max(10, 5, 20)); // \u8f93\u51fa: 20\n"},{"location":"libraries/math/#mathminargs","title":"math.min(...args)","text":"\u8ba1\u7b97\u591a\u4e2a\u6570\u7684\u6700\u5c0f\u503c\u3002
\u53c2\u6570\uff1a - ...args - \u591a\u4e2a\u6570\u5b57
\u8fd4\u56de\u503c\uff1a - \u6700\u5c0f\u503c
\u793a\u4f8b\uff1a
show(`min(10, 5, 20) = `, math.min(10, 5, 20)); // \u8f93\u51fa: 5\n"},{"location":"libraries/math/#_9","title":"\u968f\u673a\u6570\u51fd\u6570","text":""},{"location":"libraries/math/#mathrandom","title":"math.random()","text":"\u751f\u6210 0 \u5230 1 \u4e4b\u95f4\u7684\u968f\u673a\u6570\u3002
\u53c2\u6570\uff1a \u65e0
\u8fd4\u56de\u503c\uff1a - 0 \u5230 1 \u4e4b\u95f4\u7684\u968f\u673a\u6d6e\u70b9\u6570
\u793a\u4f8b\uff1a
show(`random() = `, math.random()); // \u8f93\u51fa: 0.123456...\n"},{"location":"libraries/math/#mathrandinta-b","title":"math.randint(a, b)","text":"\u751f\u6210\u6307\u5b9a\u8303\u56f4\u5185\u7684\u968f\u673a\u6574\u6570\u3002
\u53c2\u6570\uff1a - a - \u6700\u5c0f\u503c - b - \u6700\u5927\u503c
\u8fd4\u56de\u503c\uff1a - a \u5230 b \u4e4b\u95f4\u7684\u968f\u673a\u6574\u6570\uff08\u5305\u542b a \u548c b\uff09
\u793a\u4f8b\uff1a
show(`randint(1, 100) = `, math.randint(1, 100)); // \u8f93\u51fa: 42\n"},{"location":"libraries/math/#_10","title":"\u793a\u4f8b\u4ee3\u7801","text":"@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"},{"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":"oraset.py \u6587\u4ef6\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a hello.oraset \u7684\u6587\u4ef6\uff0c\u5185\u5bb9\u5982\u4e0b\uff1a
!! \u8fd9\u662f\u4e00\u4e2a\u6ce8\u91ca\nshow(`Hello, Oraset!`);\n"},{"location":"tutorial/quickstart/#_6","title":"\u8fd0\u884c\u7a0b\u5e8f","text":""},{"location":"tutorial/quickstart/#python","title":"\u4f7f\u7528 Python \u8fd0\u884c","text":"python oraset.py hello.oraset\n"},{"location":"tutorial/quickstart/#_7","title":"\u4f7f\u7528\u4e8c\u8fdb\u5236\u6587\u4ef6\u8fd0\u884c","text":"# Windows\noraset.exe hello.oraset\n\n# Linux\n./oraset hello.oraset\n"},{"location":"tutorial/quickstart/#_8","title":"\u8fd0\u884c\u7ed3\u679c","text":"\u7a0b\u5e8f\u8fd0\u884c\u540e\uff0c\u4f60\u5e94\u8be5\u4f1a\u770b\u5230\u5982\u4e0b\u8f93\u51fa\uff1a
Hello, Oraset!\n"},{"location":"tutorial/quickstart/#_9","title":"\u57fa\u672c\u8bed\u6cd5\u793a\u4f8b","text":""},{"location":"tutorial/quickstart/#_10","title":"\u53d8\u91cf\u8d4b\u503c","text":"name = `John`;\nage = 25;\nprice = 9.99;\n"},{"location":"tutorial/quickstart/#_11","title":"\u8f93\u51fa","text":"show(`Name: `, name);\nshow(`Age: `, age);\nshow(`Price: `, price);\n"},{"location":"tutorial/quickstart/#_12","title":"\u7b80\u5355\u8ba1\u7b97","text":"num1 = 10;\nnum2 = 20;\nsum = num1 + num2;\nshow(`Sum: `, sum);\n"},{"location":"tutorial/quickstart/#_13","title":"\u4e0b\u4e00\u6b65","text":"show \u51fd\u6570def factorial(n) {\n if (n <= 1) {\n return 1;\n }\n return n * factorial(n - 1);\n}\n\nshow(`5! = `, factorial(5));\n"},{"location":"tutorial/quickstart/#_20","title":"\u6570\u7ec4\u64cd\u4f5c","text":"fruits = arr(`apple`, `banana`, `cherry`);\nshow(`Fruits: `, fruits);\nshow(`First fruit: `, fruits[0]);\n"}]}