Files
oraset/docs/site/search/search_index.json
T
JGZ_YES 51ece5afed
Build and Package Oraset / build (macos-latest) (push) Waiting to run
Build and Package Oraset / build (ubuntu-latest) (push) Waiting to run
Build and Package Oraset / build (windows-latest) (push) Waiting to run
Build and Package Oraset / release (push) Blocked by required conditions
Initial commit: Oraset B-5
2026-07-23 13:25:11 +08:00

1 line
87 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\u76ee\u6807\u662f\u63d0\u4f9b\u4e00\u79cd\u6613\u4e8e\u5b66\u4e60\u548c\u4f7f\u7528\u7684\u7f16\u7a0b\u5de5\u5177\u3002\u5b83\u5177\u6709\u4ee5\u4e0b\u7279\u70b9\uff1a</p> <ul> <li>\u7b80\u5355\u6613\u5b66\uff1a\u8bed\u6cd5\u7b80\u6d01\u660e\u4e86\uff0c\u9002\u5408\u521d\u5b66\u8005</li> <li>\u8de8\u5e73\u53f0\uff1a\u652f\u6301 Windows \u548c Linux \u64cd\u4f5c\u7cfb\u7edf</li> <li>\u5f3a\u5927\u529f\u80fd\uff1a\u652f\u6301\u53d8\u91cf\u3001\u8868\u8fbe\u5f0f\u3001\u6761\u4ef6\u8bed\u53e5\u3001\u5faa\u73af\u3001\u51fd\u6570\u3001\u7c7b\u7b49\u6838\u5fc3\u529f\u80fd</li> <li>\u5185\u7f6e\u5e93\uff1a\u63d0\u4f9b\u6570\u5b66\u3001\u5b57\u7b26\u4e32\u3001\u6570\u7ec4\u3001\u5de5\u5177\u7b49\u5b9e\u7528\u5e93</li> <li>\u6587\u4ef6\u6253\u5305\uff1a\u652f\u6301\u5c06\u4ee3\u7801\u6253\u5305\u4e3a\u52a0\u5bc6\u7684 .osp \u4e8c\u8fdb\u5236\u6587\u4ef6</li> </ul>"},{"location":"#_1","title":"\u5feb\u901f\u5f00\u59cb","text":""},{"location":"#oraset_2","title":"\u5b89\u88c5 Oraset","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":"#_2","title":"\u8fd0\u884c\u4f60\u7684\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>show(`Hello, Oraset!`);\n</code></pre> <p>\u7136\u540e\u8fd0\u884c\uff1a</p> <pre><code>python oraset.py hello.oraset\n</code></pre> <p>\u4f60\u5c06\u770b\u5230\u8f93\u51fa\uff1a</p> <pre><code>Hello, Oraset!\n</code></pre>"},{"location":"#_3","title":"\u6838\u5fc3\u7279\u6027","text":""},{"location":"#_4","title":"\u8bed\u6cd5\u7279\u70b9","text":"<ul> <li>\u4f7f\u7528\u53cd\u5f15\u53f7 <code>`</code> \u8868\u793a\u5b57\u7b26\u4e32</li> <li>\u4f7f\u7528 <code>show</code> \u4ee3\u66ff <code>print</code> \u8fdb\u884c\u8f93\u51fa</li> <li>\u4f7f\u7528 <code>@</code> \u5bfc\u5165\u5e93</li> <li>\u652f\u6301\u5206\u53f7\u4f5c\u4e3a\u8bed\u53e5\u7ed3\u675f\u7b26</li> </ul>"},{"location":"#_5","title":"\u57fa\u672c\u6570\u636e\u7c7b\u578b","text":"<ul> <li>\u6570\u5b57\uff08\u6574\u6570\u548c\u6d6e\u70b9\u6570\uff09</li> <li>\u5b57\u7b26\u4e32</li> <li>\u6570\u7ec4</li> <li>\u5e03\u5c14\u503c</li> </ul>"},{"location":"#_6","title":"\u63a7\u5236\u7ed3\u6784","text":"<ul> <li>\u6761\u4ef6\u8bed\u53e5\uff1a<code>if</code>\u3001<code>else</code>\u3001<code>else if</code></li> <li>\u5faa\u73af\u8bed\u53e5\uff1a<code>while</code></li> </ul>"},{"location":"#_7","title":"\u51fd\u6570\u548c\u7c7b","text":"<ul> <li>\u51fd\u6570\u5b9a\u4e49\uff1a<code>def function_name(params) { ... }</code></li> <li>\u7c7b\u5b9a\u4e49\uff1a<code>class ClassName { ... }</code></li> </ul>"},{"location":"#_8","title":"\u5185\u7f6e\u5e93","text":"<ul> <li><code>@math</code> - \u6570\u5b66\u5e93</li> <li><code>@string</code> - \u5b57\u7b26\u4e32\u5e93</li> <li><code>@array</code> - \u6570\u7ec4\u5e93</li> <li><code>@util</code> - \u5de5\u5177\u5e93</li> </ul>"},{"location":"#_9","title":"\u5b66\u4e60\u8d44\u6e90","text":"<ul> <li>\u5feb\u901f\u5f00\u59cb\uff1a\u5feb\u901f\u5f00\u59cb\u6559\u7a0b</li> <li>\u57fa\u672c\u8bed\u6cd5\uff1a\u57fa\u672c\u8bed\u6cd5\u6559\u7a0b</li> <li>\u63a7\u5236\u7ed3\u6784\uff1a\u63a7\u5236\u7ed3\u6784\u6559\u7a0b</li> <li>\u51fd\u6570\u548c\u7c7b\uff1a\u51fd\u6570\u548c\u7c7b\u6559\u7a0b</li> <li>\u5e93\u53c2\u8003\uff1a\u5e93\u53c2\u8003\u6587\u6863</li> </ul>"},{"location":"#_10","title":"\u793e\u533a","text":"<ul> <li>GitHub \u4ed3\u5e93 - \u6e90\u4ee3\u7801\u548c\u8d21\u732e</li> <li>\u8bba\u575b - \u8ba8\u8bba\u548c\u5e2e\u52a9</li> <li>Issue \u8ffd\u8e2a - \u62a5\u544a\u95ee\u9898</li> </ul>"},{"location":"#_11","title":"\u8bb8\u53ef\u8bc1","text":"<p>Oraset \u4f7f\u7528 GNU \u901a\u7528\u516c\u5171\u8bb8\u53ef\u8bc1 v3.0\u3002</p>"},{"location":"libraries/array/","title":"\u6570\u7ec4\u5e93","text":""},{"location":"libraries/array/#_2","title":"\u7b80\u4ecb","text":"<p>\u6570\u7ec4\u5e93\uff08<code>@array</code>\uff09\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u6570\u7ec4\u64cd\u4f5c\u51fd\u6570\uff0c\u5305\u62ec\u6570\u7ec4\u957f\u5ea6\u83b7\u53d6\u3001\u5143\u7d20\u6dfb\u52a0\u3001\u5220\u9664\u3001\u67e5\u627e\u3001\u6392\u5e8f\u7b49\u529f\u80fd\u3002</p>"},{"location":"libraries/array/#_3","title":"\u5bfc\u5165\u65b9\u5f0f","text":"<pre><code>@array;\n</code></pre>"},{"location":"libraries/array/#_4","title":"\u51fd\u6570\u53c2\u8003","text":""},{"location":"libraries/array/#_5","title":"\u57fa\u672c\u6570\u7ec4\u64cd\u4f5c","text":""},{"location":"libraries/array/#arraylengtharr","title":"array.length(arr)","text":"<p>\u83b7\u53d6\u6570\u7ec4\u957f\u5ea6\u3002</p> <p>\u53c2\u6570\uff1a - <code>arr</code> - \u6570\u7ec4</p> <p>\u8fd4\u56de\u503c\uff1a - \u6570\u7ec4\u7684\u957f\u5ea6</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@array;\n\nfruits = arr(`apple`, `banana`, `cherry`);\nresult = array.length(fruits);\nshow(`Array length: `, result); !! \u8f93\u51fa: 3\n</code></pre>"},{"location":"libraries/array/#arraypusharr-item","title":"array.push(arr, item)","text":"<p>\u5411\u6570\u7ec4\u672b\u5c3e\u6dfb\u52a0\u4e00\u4e2a\u5143\u7d20\u3002</p> <p>\u53c2\u6570\uff1a - <code>arr</code> - \u6570\u7ec4 - <code>item</code> - \u8981\u6dfb\u52a0\u7684\u5143\u7d20</p> <p>\u8fd4\u56de\u503c\uff1a - \u6dfb\u52a0\u5143\u7d20\u540e\u7684\u65b0\u6570\u7ec4</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@array;\n\nfruits = arr(`apple`, `banana`);\nresult = array.push(fruits, `cherry`);\nshow(`After push: `, result); !! \u8f93\u51fa: [\"apple\", \"banana\", \"cherry\"]\n</code></pre>"},{"location":"libraries/array/#arraypoparr","title":"array.pop(arr)","text":"<p>\u79fb\u9664\u6570\u7ec4\u672b\u5c3e\u7684\u5143\u7d20\u3002</p> <p>\u53c2\u6570\uff1a - <code>arr</code> - \u6570\u7ec4</p> <p>\u8fd4\u56de\u503c\uff1a - \u79fb\u9664\u5143\u7d20\u540e\u7684\u65b0\u6570\u7ec4</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@array;\n\nfruits = arr(`apple`, `banana`, `cherry`);\nresult = array.pop(fruits);\nshow(`After pop: `, result); !! \u8f93\u51fa: [\"apple\", \"banana\"]\n</code></pre>"},{"location":"libraries/array/#arrayshiftarr","title":"array.shift(arr)","text":"<p>\u79fb\u9664\u6570\u7ec4\u5f00\u5934\u7684\u5143\u7d20\u3002</p> <p>\u53c2\u6570\uff1a - <code>arr</code> - \u6570\u7ec4</p> <p>\u8fd4\u56de\u503c\uff1a - \u79fb\u9664\u5143\u7d20\u540e\u7684\u65b0\u6570\u7ec4</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@array;\n\nfruits = arr(`apple`, `banana`, `cherry`);\nresult = array.shift(fruits);\nshow(`After shift: `, result); !! \u8f93\u51fa: [\"banana\", \"cherry\"]\n</code></pre>"},{"location":"libraries/array/#arrayunshiftarr-item","title":"array.unshift(arr, item)","text":"<p>\u5411\u6570\u7ec4\u5f00\u5934\u6dfb\u52a0\u4e00\u4e2a\u5143\u7d20\u3002</p> <p>\u53c2\u6570\uff1a - <code>arr</code> - \u6570\u7ec4 - <code>item</code> - \u8981\u6dfb\u52a0\u7684\u5143\u7d20</p> <p>\u8fd4\u56de\u503c\uff1a - \u6dfb\u52a0\u5143\u7d20\u540e\u7684\u65b0\u6570\u7ec4</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@array;\n\nfruits = arr(`banana`, `cherry`);\nresult = array.unshift(fruits, `apple`);\nshow(`After unshift: `, result); !! \u8f93\u51fa: [\"apple\", \"banana\", \"cherry\"]\n</code></pre>"},{"location":"libraries/array/#_6","title":"\u6570\u7ec4\u67e5\u627e","text":""},{"location":"libraries/array/#arrayindexofarr-item","title":"array.indexOf(arr, item)","text":"<p>\u67e5\u627e\u5143\u7d20\u5728\u6570\u7ec4\u4e2d\u7684\u4f4d\u7f6e\u3002</p> <p>\u53c2\u6570\uff1a - <code>arr</code> - \u6570\u7ec4 - <code>item</code> - \u8981\u67e5\u627e\u7684\u5143\u7d20</p> <p>\u8fd4\u56de\u503c\uff1a - \u5143\u7d20\u7684\u7d22\u5f15\uff0c\u672a\u627e\u5230\u8fd4\u56de -1</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@array;\n\nfruits = arr(`apple`, `banana`, `cherry`);\nresult1 = array.indexOf(fruits, `banana`);\nresult2 = array.indexOf(fruits, `orange`);\nshow(`Index of 'banana': `, result1); !! \u8f93\u51fa: 1\nshow(`Index of 'orange': `, result2); !! \u8f93\u51fa: -1\n</code></pre>"},{"location":"libraries/array/#arraylastindexofarr-item","title":"array.lastIndexOf(arr, item)","text":"<p>\u4ece\u6570\u7ec4\u672b\u5c3e\u5f00\u59cb\u67e5\u627e\u5143\u7d20\u7684\u4f4d\u7f6e\u3002</p> <p>\u53c2\u6570\uff1a - <code>arr</code> - \u6570\u7ec4 - <code>item</code> - \u8981\u67e5\u627e\u7684\u5143\u7d20</p> <p>\u8fd4\u56de\u503c\uff1a - \u5143\u7d20\u7684\u7d22\u5f15\uff0c\u672a\u627e\u5230\u8fd4\u56de -1</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@array;\n\nnumbers = arr(1, 2, 3, 2, 1);\nresult = array.lastIndexOf(numbers, 2);\nshow(`Last index of 2: `, result); !! \u8f93\u51fa: 3\n</code></pre>"},{"location":"libraries/array/#arrayincludesarr-item","title":"array.includes(arr, item)","text":"<p>\u68c0\u67e5\u6570\u7ec4\u662f\u5426\u5305\u542b\u6307\u5b9a\u5143\u7d20\u3002</p> <p>\u53c2\u6570\uff1a - <code>arr</code> - \u6570\u7ec4 - <code>item</code> - \u8981\u68c0\u67e5\u7684\u5143\u7d20</p> <p>\u8fd4\u56de\u503c\uff1a - \u5e03\u5c14\u503c\uff0c\u8868\u793a\u6570\u7ec4\u662f\u5426\u5305\u542b\u6307\u5b9a\u5143\u7d20</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@array;\n\nfruits = arr(`apple`, `banana`, `cherry`);\nresult1 = array.includes(fruits, `banana`);\nresult2 = array.includes(fruits, `orange`);\nshow(`Includes 'banana': `, result1); !! \u8f93\u51fa: true\nshow(`Includes 'orange': `, result2); !! \u8f93\u51fa: false\n</code></pre>"},{"location":"libraries/array/#_7","title":"\u6570\u7ec4\u8f6c\u6362","text":""},{"location":"libraries/array/#arrayjoinarr-sep","title":"array.join(arr, sep)","text":"<p>\u5c06\u6570\u7ec4\u5143\u7d20\u8fde\u63a5\u6210\u4e00\u4e2a\u5b57\u7b26\u4e32\u3002</p> <p>\u53c2\u6570\uff1a - <code>arr</code> - \u6570\u7ec4 - <code>sep</code> - \u5206\u9694\u7b26</p> <p>\u8fd4\u56de\u503c\uff1a - \u8fde\u63a5\u540e\u7684\u5b57\u7b26\u4e32</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@array;\n\nfruits = arr(`apple`, `banana`, `cherry`);\nresult = array.join(fruits, `, `);\nshow(`Joined: `, result); !! \u8f93\u51fa: apple, banana, cherry\n</code></pre>"},{"location":"libraries/array/#arrayreversearr","title":"array.reverse(arr)","text":"<p>\u53cd\u8f6c\u6570\u7ec4\u5143\u7d20\u7684\u987a\u5e8f\u3002</p> <p>\u53c2\u6570\uff1a - <code>arr</code> - \u6570\u7ec4</p> <p>\u8fd4\u56de\u503c\uff1a - \u53cd\u8f6c\u540e\u7684\u65b0\u6570\u7ec4</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@array;\n\nfruits = arr(`apple`, `banana`, `cherry`);\nresult = array.reverse(fruits);\nshow(`Reversed: `, result); !! \u8f93\u51fa: [\"cherry\", \"banana\", \"apple\"]\n</code></pre>"},{"location":"libraries/array/#arraysortarr","title":"array.sort(arr)","text":"<p>\u5bf9\u6570\u7ec4\u5143\u7d20\u8fdb\u884c\u6392\u5e8f\u3002</p> <p>\u53c2\u6570\uff1a - <code>arr</code> - \u6570\u7ec4</p> <p>\u8fd4\u56de\u503c\uff1a - \u6392\u5e8f\u540e\u7684\u65b0\u6570\u7ec4</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@array;\n\nnumbers = arr(3, 1, 4, 1, 5, 9, 2, 6);\nresult = array.sort(numbers);\nshow(`Sorted: `, result); !! \u8f93\u51fa: [1, 1, 2, 3, 4, 5, 6, 9]\n\nfruits = arr(`cherry`, `apple`, `banana`);\nresult = array.sort(fruits);\nshow(`Sorted fruits: `, result); !! \u8f93\u51fa: [\"apple\", \"banana\", \"cherry\"]\n</code></pre>"},{"location":"libraries/array/#arrayslicearr-start-end","title":"array.slice(arr, start, end)","text":"<p>\u63d0\u53d6\u6570\u7ec4\u7684\u4e00\u90e8\u5206\u3002</p> <p>\u53c2\u6570\uff1a - <code>arr</code> - \u6570\u7ec4 - <code>start</code> - \u8d77\u59cb\u7d22\u5f15\uff08\u4ece0\u5f00\u59cb\uff09 - <code>end</code> - \u7ed3\u675f\u7d22\u5f15\uff08\u4e0d\u5305\u542b\uff09</p> <p>\u8fd4\u56de\u503c\uff1a - \u63d0\u53d6\u7684\u5b50\u6570\u7ec4</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@array;\n\nnumbers = arr(0, 1, 2, 3, 4, 5);\nresult1 = array.slice(numbers, 2, 4);\nresult2 = array.slice(numbers, 1);\nshow(`Slice (2-4): `, result1); !! \u8f93\u51fa: [2, 3]\nshow(`Slice (1+): `, result2); !! \u8f93\u51fa: [1, 2, 3, 4, 5]\n</code></pre>"},{"location":"libraries/array/#_8","title":"\u793a\u4f8b\u4ee3\u7801","text":"<pre><code>@array;\n\n!! \u521b\u5efa\u6570\u7ec4\nfruits = arr(`apple`, `banana`, `cherry`);\nshow(`Original array: `, fruits);\n\n!! \u57fa\u672c\u64cd\u4f5c\nshow(`Length: `, array.length(fruits));\nshow(`After push: `, array.push(fruits, `orange`));\nshow(`After pop: `, array.pop(fruits));\nshow(`After unshift: `, array.unshift(fruits, `grape`));\nshow(`After shift: `, array.shift(fruits));\n\n!! \u67e5\u627e\u64cd\u4f5c\nshow(`Index of 'banana': `, array.indexOf(fruits, `banana`));\nshow(`Last index of 'banana': `, array.lastIndexOf(fruits, `banana`));\nshow(`Includes 'cherry': `, array.includes(fruits, `cherry`));\n\n!! \u8f6c\u6362\u64cd\u4f5c\nshow(`Joined: `, array.join(fruits, ` | `));\nshow(`Reversed: `, array.reverse(fruits));\n\n!! \u6392\u5e8f\u64cd\u4f5c\nnumbers = arr(5, 2, 8, 1, 9);\nshow(`Original numbers: `, numbers);\nshow(`Sorted numbers: `, array.sort(numbers));\n\n!! \u5207\u7247\u64cd\u4f5c\nshow(`Slice (1-3): `, array.slice(numbers, 1, 3));\n</code></pre>"},{"location":"libraries/array/#_9","title":"\u6ce8\u610f\u4e8b\u9879","text":"<ul> <li>\u6240\u6709\u6570\u7ec4\u64cd\u4f5c\u51fd\u6570\u90fd\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684\u6570\u7ec4\uff0c\u4e0d\u4f1a\u4fee\u6539\u539f\u59cb\u6570\u7ec4</li> <li>\u6570\u7ec4\u7d22\u5f15\u4ece0\u5f00\u59cb</li> <li>\u6570\u7ec4\u5143\u7d20\u53ef\u4ee5\u662f\u4e0d\u540c\u7c7b\u578b\u7684\u503c</li> <li>\u5bf9\u4e8e\u5927\u578b\u6570\u7ec4\uff0c\u67d0\u4e9b\u64cd\u4f5c\uff08\u5982\u6392\u5e8f\uff09\u53ef\u80fd\u4f1a\u5f71\u54cd\u6027\u80fd</li> </ul>"},{"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>@math;\n\nshow(`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>@math;\n\nshow(`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 x \u7684 y \u6b21\u65b9\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\u65b9</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@math;\n\nshow(`pow(2, 3) = `, math.pow(2, 3)); !! \u8f93\u51fa: 8\n</code></pre>"},{"location":"libraries/math/#mathexpx","title":"math.exp(x)","text":"<p>\u8ba1\u7b97 e \u7684 x \u6b21\u65b9\u3002</p> <p>\u53c2\u6570\uff1a - <code>x</code> - \u6307\u6570</p> <p>\u8fd4\u56de\u503c\uff1a - e \u7684 x \u6b21\u65b9</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@math;\n\nshow(`exp(1) = `, math.exp(1)); !! \u8f93\u51fa: 2.718281828459045\n</code></pre>"},{"location":"libraries/math/#mathlogx","title":"math.log(x)","text":"<p>\u8ba1\u7b97\u81ea\u7136\u5bf9\u6570\u3002</p> <p>\u53c2\u6570\uff1a - <code>x</code> - \u6b63\u6570</p> <p>\u8fd4\u56de\u503c\uff1a - \u81ea\u7136\u5bf9\u6570\u503c</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@math;\n\nshow(`log(e) = `, math.log(math.exp(1))); !! \u8f93\u51fa: 1\n</code></pre>"},{"location":"libraries/math/#mathlog10x","title":"math.log10(x)","text":"<p>\u8ba1\u7b97\u4ee5 10 \u4e3a\u5e95\u7684\u5bf9\u6570\u3002</p> <p>\u53c2\u6570\uff1a - <code>x</code> - \u6b63\u6570</p> <p>\u8fd4\u56de\u503c\uff1a - \u4ee5 10 \u4e3a\u5e95\u7684\u5bf9\u6570\u503c</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@math;\n\nshow(`log10(100) = `, math.log10(100)); !! \u8f93\u51fa: 2\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</p> <p>\u8fd4\u56de\u503c\uff1a - \u6b63\u5f26\u503c</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@math;\n\nshow(`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</p> <p>\u8fd4\u56de\u503c\uff1a - \u4f59\u5f26\u503c</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@math;\n\nshow(`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</p> <p>\u8fd4\u56de\u503c\uff1a - \u6b63\u5207\u503c</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@math;\n\nshow(`tan(45) = `, math.tan(45)); !! \u8f93\u51fa: 1\n</code></pre>"},{"location":"libraries/math/#mathasinx","title":"math.asin(x)","text":"<p>\u8ba1\u7b97\u53cd\u6b63\u5f26\u503c\uff08\u8fd4\u56de\u89d2\u5ea6\uff09\u3002</p> <p>\u53c2\u6570\uff1a - <code>x</code> - \u503c\uff08-1 \u5230 1 \u4e4b\u95f4\uff09</p> <p>\u8fd4\u56de\u503c\uff1a - \u53cd\u6b63\u5f26\u89d2\u5ea6</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@math;\n\nshow(`asin(1) = `, math.asin(1)); !! \u8f93\u51fa: 90\n</code></pre>"},{"location":"libraries/math/#mathacosx","title":"math.acos(x)","text":"<p>\u8ba1\u7b97\u53cd\u4f59\u5f26\u503c\uff08\u8fd4\u56de\u89d2\u5ea6\uff09\u3002</p> <p>\u53c2\u6570\uff1a - <code>x</code> - \u503c\uff08-1 \u5230 1 \u4e4b\u95f4\uff09</p> <p>\u8fd4\u56de\u503c\uff1a - \u53cd\u4f59\u5f26\u89d2\u5ea6</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@math;\n\nshow(`acos(1) = `, math.acos(1)); !! \u8f93\u51fa: 0\n</code></pre>"},{"location":"libraries/math/#mathatanx","title":"math.atan(x)","text":"<p>\u8ba1\u7b97\u53cd\u6b63\u5207\u503c\uff08\u8fd4\u56de\u89d2\u5ea6\uff09\u3002</p> <p>\u53c2\u6570\uff1a - <code>x</code> - \u503c</p> <p>\u8fd4\u56de\u503c\uff1a - \u53cd\u6b63\u5207\u89d2\u5ea6</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@math;\n\nshow(`atan(1) = `, math.atan(1)); !! \u8f93\u51fa: 45\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\u3002</p> <p>\u53c2\u6570\uff1a - \u65e0</p> <p>\u8fd4\u56de\u503c\uff1a - \u5706\u5468\u7387 \u03c0 \u503c</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@math;\n\nshow(`\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\u7684\u5e95 e\u3002</p> <p>\u53c2\u6570\uff1a - \u65e0</p> <p>\u8fd4\u56de\u503c\uff1a - \u81ea\u7136\u5bf9\u6570\u7684\u5e95 e \u503c</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@math;\n\nshow(`e = `, math.e()); !! \u8f93\u51fa: 2.718281828459045\n</code></pre>"},{"location":"libraries/math/#_8","title":"\u53d6\u6574\u51fd\u6570","text":""},{"location":"libraries/math/#mathfloorx","title":"math.floor(x)","text":"<p>\u5411\u4e0b\u53d6\u6574\u3002</p> <p>\u53c2\u6570\uff1a - <code>x</code> - \u6570\u5b57</p> <p>\u8fd4\u56de\u503c\uff1a - \u5411\u4e0b\u53d6\u6574\u540e\u7684\u6574\u6570</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@math;\n\nshow(`floor(3.9) = `, math.floor(3.9)); !! \u8f93\u51fa: 3\nshow(`floor(-3.1) = `, math.floor(-3.1)); !! \u8f93\u51fa: -4\n</code></pre>"},{"location":"libraries/math/#mathceilx","title":"math.ceil(x)","text":"<p>\u5411\u4e0a\u53d6\u6574\u3002</p> <p>\u53c2\u6570\uff1a - <code>x</code> - \u6570\u5b57</p> <p>\u8fd4\u56de\u503c\uff1a - \u5411\u4e0a\u53d6\u6574\u540e\u7684\u6574\u6570</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@math;\n\nshow(`ceil(3.1) = `, math.ceil(3.1)); !! \u8f93\u51fa: 4\nshow(`ceil(-3.9) = `, math.ceil(-3.9)); !! \u8f93\u51fa: -3\n</code></pre>"},{"location":"libraries/math/#mathroundx","title":"math.round(x)","text":"<p>\u56db\u820d\u4e94\u5165\u3002</p> <p>\u53c2\u6570\uff1a - <code>x</code> - \u6570\u5b57</p> <p>\u8fd4\u56de\u503c\uff1a - \u56db\u820d\u4e94\u5165\u540e\u7684\u6574\u6570</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@math;\n\nshow(`round(3.1) = `, math.round(3.1)); !! \u8f93\u51fa: 3\nshow(`round(3.6) = `, math.round(3.6)); !! \u8f93\u51fa: 4\n</code></pre>"},{"location":"libraries/math/#_9","title":"\u6700\u503c\u51fd\u6570","text":""},{"location":"libraries/math/#mathmaxargs","title":"math.max(...args)","text":"<p>\u8fd4\u56de\u591a\u4e2a\u6570\u5b57\u4e2d\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>@math;\n\nshow(`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>\u8fd4\u56de\u591a\u4e2a\u6570\u5b57\u4e2d\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>@math;\n\nshow(`min(10, 5, 20) = `, math.min(10, 5, 20)); !! \u8f93\u51fa: 5\n</code></pre>"},{"location":"libraries/math/#_10","title":"\u968f\u673a\u6570","text":""},{"location":"libraries/math/#mathrandom","title":"math.random()","text":"<p>\u751f\u6210 0 \u5230 1 \u4e4b\u95f4\u7684\u968f\u673a\u5c0f\u6570\u3002</p> <p>\u53c2\u6570\uff1a - \u65e0</p> <p>\u8fd4\u56de\u503c\uff1a - 0 \u5230 1 \u4e4b\u95f4\u7684\u968f\u673a\u5c0f\u6570</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@math;\n\nshow(`random() = `, math.random()); !! \u8f93\u51fa: 0.123456789\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 - \u8303\u56f4\u5185\u7684\u968f\u673a\u6574\u6570</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@math;\n\nshow(`randint(1, 100) = `, math.randint(1, 100)); !! \u8f93\u51fa: 42\n</code></pre>"},{"location":"libraries/math/#_11","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));\nshow(`exp(1) = `, math.exp(1));\nshow(`log(e) = `, math.log(math.exp(1)));\nshow(`log10(100) = `, math.log10(100));\n\n!! \u4e09\u89d2\u51fd\u6570\nshow(`sin(90) = `, math.sin(90));\nshow(`cos(0) = `, math.cos(0));\nshow(`tan(45) = `, math.tan(45));\nshow(`asin(1) = `, math.asin(1));\nshow(`acos(1) = `, math.acos(1));\nshow(`atan(1) = `, math.atan(1));\n\n!! \u6570\u5b66\u5e38\u6570\nshow(`\u03c0 = `, math.pi());\nshow(`e = `, math.e());\n\n!! \u53d6\u6574\u51fd\u6570\nshow(`floor(3.9) = `, math.floor(3.9));\nshow(`ceil(3.1) = `, math.ceil(3.1));\nshow(`round(3.6) = `, math.round(3.6));\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":"libraries/math/#_12","title":"\u6ce8\u610f\u4e8b\u9879","text":"<ul> <li>\u4e09\u89d2\u51fd\u6570\u4f7f\u7528\u89d2\u5ea6\u4f5c\u4e3a\u53c2\u6570\uff0c\u800c\u975e\u5f27\u5ea6</li> <li>\u5bf9\u4e8e <code>sqrt</code> \u548c <code>log</code> \u7b49\u51fd\u6570\uff0c\u53c2\u6570\u5fc5\u987b\u6ee1\u8db3\u6570\u5b66\u8981\u6c42</li> <li>\u968f\u673a\u6570\u751f\u6210\u51fd\u6570\u4f7f\u7528\u7cfb\u7edf\u7684\u968f\u673a\u6570\u751f\u6210\u5668</li> <li>\u6240\u6709\u51fd\u6570\u90fd\u8fd4\u56de\u6570\u5b57\u7c7b\u578b\u7684\u503c</li> </ul>"},{"location":"libraries/string/","title":"\u5b57\u7b26\u4e32\u5e93","text":""},{"location":"libraries/string/#_2","title":"\u7b80\u4ecb","text":"<p>\u5b57\u7b26\u4e32\u5e93\uff08<code>@string</code>\uff09\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u5b57\u7b26\u4e32\u64cd\u4f5c\u51fd\u6570\uff0c\u5305\u62ec\u5b57\u7b26\u4e32\u5206\u5272\u3001\u5927\u5c0f\u5199\u8f6c\u6362\u3001\u67e5\u627e\u66ff\u6362\u7b49\u529f\u80fd\u3002</p>"},{"location":"libraries/string/#_3","title":"\u5bfc\u5165\u65b9\u5f0f","text":"<pre><code>@string;\n</code></pre>"},{"location":"libraries/string/#_4","title":"\u51fd\u6570\u53c2\u8003","text":""},{"location":"libraries/string/#_5","title":"\u5b57\u7b26\u4e32\u5206\u5272\u4e0e\u8fde\u63a5","text":""},{"location":"libraries/string/#stringsplits-sep","title":"string.split(s, sep)","text":"<p>\u5206\u5272\u5b57\u7b26\u4e32\u3002</p> <p>\u53c2\u6570\uff1a - <code>s</code> - \u5b57\u7b26\u4e32 - <code>sep</code> - \u5206\u9694\u7b26</p> <p>\u8fd4\u56de\u503c\uff1a - \u5206\u5272\u540e\u7684\u6570\u7ec4</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@string;\n\ntext = `Hello,World,Oraset`;\nresult = string.split(text, `,`);\nshow(`Split result: `, result); !! \u8f93\u51fa: [\"Hello\", \"World\", \"Oraset\"]\n</code></pre>"},{"location":"libraries/string/#stringjoinarr-sep","title":"string.join(arr, sep)","text":"<p>\u8fde\u63a5\u6570\u7ec4\u5143\u7d20\u4e3a\u5b57\u7b26\u4e32\u3002</p> <p>\u53c2\u6570\uff1a - <code>arr</code> - \u6570\u7ec4 - <code>sep</code> - \u5206\u9694\u7b26</p> <p>\u8fd4\u56de\u503c\uff1a - \u8fde\u63a5\u540e\u7684\u5b57\u7b26\u4e32</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@string;\n\narr = arr(`Hello`, `World`, `Oraset`);\nresult = string.join(arr, ` `);\nshow(`Joined result: `, result); !! \u8f93\u51fa: Hello World Oraset\n</code></pre>"},{"location":"libraries/string/#_6","title":"\u5927\u5c0f\u5199\u8f6c\u6362","text":""},{"location":"libraries/string/#stringuppers","title":"string.upper(s)","text":"<p>\u8f6c\u6362\u4e3a\u5927\u5199\u3002</p> <p>\u53c2\u6570\uff1a - <code>s</code> - \u5b57\u7b26\u4e32</p> <p>\u8fd4\u56de\u503c\uff1a - \u5927\u5199\u5b57\u7b26\u4e32</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@string;\n\ntext = `hello world`;\nresult = string.upper(text);\nshow(`Upper case: `, result); !! \u8f93\u51fa: HELLO WORLD\n</code></pre>"},{"location":"libraries/string/#stringlowers","title":"string.lower(s)","text":"<p>\u8f6c\u6362\u4e3a\u5c0f\u5199\u3002</p> <p>\u53c2\u6570\uff1a - <code>s</code> - \u5b57\u7b26\u4e32</p> <p>\u8fd4\u56de\u503c\uff1a - \u5c0f\u5199\u5b57\u7b26\u4e32</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@string;\n\ntext = `HELLO WORLD`;\nresult = string.lower(text);\nshow(`Lower case: `, result); !! \u8f93\u51fa: hello world\n</code></pre>"},{"location":"libraries/string/#stringcapitalizes","title":"string.capitalize(s)","text":"<p>\u9996\u5b57\u6bcd\u5927\u5199\u3002</p> <p>\u53c2\u6570\uff1a - <code>s</code> - \u5b57\u7b26\u4e32</p> <p>\u8fd4\u56de\u503c\uff1a - \u9996\u5b57\u6bcd\u5927\u5199\u7684\u5b57\u7b26\u4e32</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@string;\n\ntext = `hello world`;\nresult = string.capitalize(text);\nshow(`Capitalized: `, result); !! \u8f93\u51fa: Hello world\n</code></pre>"},{"location":"libraries/string/#_7","title":"\u5b57\u7b26\u4e32\u957f\u5ea6\u4e0e\u63d0\u53d6","text":""},{"location":"libraries/string/#stringlengths","title":"string.length(s)","text":"<p>\u83b7\u53d6\u5b57\u7b26\u4e32\u957f\u5ea6\u3002</p> <p>\u53c2\u6570\uff1a - <code>s</code> - \u5b57\u7b26\u4e32</p> <p>\u8fd4\u56de\u503c\uff1a - \u5b57\u7b26\u4e32\u957f\u5ea6</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@string;\n\ntext = `Hello, Oraset!`;\nresult = string.length(text);\nshow(`Length: `, result); !! \u8f93\u51fa: 13\n</code></pre>"},{"location":"libraries/string/#stringsubstrings-start-end","title":"string.substring(s, start, end)","text":"<p>\u63d0\u53d6\u5b50\u5b57\u7b26\u4e32\u3002</p> <p>\u53c2\u6570\uff1a - <code>s</code> - \u5b57\u7b26\u4e32 - <code>start</code> - \u8d77\u59cb\u7d22\u5f15 - <code>end</code> - \u7ed3\u675f\u7d22\u5f15\uff08\u53ef\u9009\uff09</p> <p>\u8fd4\u56de\u503c\uff1a - \u63d0\u53d6\u7684\u5b50\u5b57\u7b26\u4e32</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@string;\n\ntext = `Hello, Oraset!`;\nresult1 = string.substring(text, 7);\nresult2 = string.substring(text, 0, 5);\nshow(`Substring from 7: `, result1); !! \u8f93\u51fa: Oraset!\nshow(`Substring from 0 to 5: `, result2); !! \u8f93\u51fa: Hello\n</code></pre>"},{"location":"libraries/string/#stringcharats-index","title":"string.charAt(s, index)","text":"<p>\u83b7\u53d6\u6307\u5b9a\u4f4d\u7f6e\u7684\u5b57\u7b26\u3002</p> <p>\u53c2\u6570\uff1a - <code>s</code> - \u5b57\u7b26\u4e32 - <code>index</code> - \u7d22\u5f15</p> <p>\u8fd4\u56de\u503c\uff1a - \u6307\u5b9a\u4f4d\u7f6e\u7684\u5b57\u7b26</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@string;\n\ntext = `Hello`;\nresult = string.charAt(text, 0);\nshow(`First character: `, result); !! \u8f93\u51fa: H\n</code></pre>"},{"location":"libraries/string/#_8","title":"\u5b57\u7b26\u4e32\u67e5\u627e","text":""},{"location":"libraries/string/#stringindexofs-substr","title":"string.indexOf(s, substr)","text":"<p>\u67e5\u627e\u5b50\u5b57\u7b26\u4e32\u7684\u4f4d\u7f6e\u3002</p> <p>\u53c2\u6570\uff1a - <code>s</code> - \u5b57\u7b26\u4e32 - <code>substr</code> - \u5b50\u5b57\u7b26\u4e32</p> <p>\u8fd4\u56de\u503c\uff1a - \u5b50\u5b57\u7b26\u4e32\u7684\u8d77\u59cb\u4f4d\u7f6e\uff0c\u672a\u627e\u5230\u8fd4\u56de -1</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@string;\n\ntext = `Hello, Oraset!`;\nresult1 = string.indexOf(text, `Oraset`);\nresult2 = string.indexOf(text, `World`);\nshow(`Index of 'Oraset': `, result1); !! \u8f93\u51fa: 7\nshow(`Index of 'World': `, result2); !! \u8f93\u51fa: -1\n</code></pre>"},{"location":"libraries/string/#stringlastindexofs-substr","title":"string.lastIndexOf(s, substr)","text":"<p>\u4ece\u672b\u5c3e\u5f00\u59cb\u67e5\u627e\u5b50\u5b57\u7b26\u4e32\u7684\u4f4d\u7f6e\u3002</p> <p>\u53c2\u6570\uff1a - <code>s</code> - \u5b57\u7b26\u4e32 - <code>substr</code> - \u5b50\u5b57\u7b26\u4e32</p> <p>\u8fd4\u56de\u503c\uff1a - \u5b50\u5b57\u7b26\u4e32\u7684\u8d77\u59cb\u4f4d\u7f6e\uff0c\u672a\u627e\u5230\u8fd4\u56de -1</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@string;\n\ntext = `Hello, Oraset, Oraset!`;\nresult = string.lastIndexOf(text, `Oraset`);\nshow(`Last index of 'Oraset': `, result); !! \u8f93\u51fa: 14\n</code></pre>"},{"location":"libraries/string/#stringincludess-substr","title":"string.includes(s, substr)","text":"<p>\u68c0\u67e5\u5b57\u7b26\u4e32\u662f\u5426\u5305\u542b\u5b50\u5b57\u7b26\u4e32\u3002</p> <p>\u53c2\u6570\uff1a - <code>s</code> - \u5b57\u7b26\u4e32 - <code>substr</code> - \u5b50\u5b57\u7b26\u4e32</p> <p>\u8fd4\u56de\u503c\uff1a - \u5e03\u5c14\u503c\uff0c\u8868\u793a\u662f\u5426\u5305\u542b\u5b50\u5b57\u7b26\u4e32</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@string;\n\ntext = `Hello, Oraset!`;\nresult1 = string.includes(text, `Oraset`);\nresult2 = string.includes(text, `World`);\nshow(`Includes 'Oraset': `, result1); !! \u8f93\u51fa: true\nshow(`Includes 'World': `, result2); !! \u8f93\u51fa: false\n</code></pre>"},{"location":"libraries/string/#_9","title":"\u5b57\u7b26\u4e32\u66ff\u6362","text":""},{"location":"libraries/string/#stringreplaces-old-new","title":"string.replace(s, old, new)","text":"<p>\u66ff\u6362\u5b50\u5b57\u7b26\u4e32\u3002</p> <p>\u53c2\u6570\uff1a - <code>s</code> - \u5b57\u7b26\u4e32 - <code>old</code> - \u8981\u66ff\u6362\u7684\u5b50\u5b57\u7b26\u4e32 - <code>new</code> - \u66ff\u6362\u540e\u7684\u5b50\u5b57\u7b26\u4e32</p> <p>\u8fd4\u56de\u503c\uff1a - \u66ff\u6362\u540e\u7684\u5b57\u7b26\u4e32</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@string;\n\ntext = `Hello, World!`;\nresult = string.replace(text, `World`, `Oraset`);\nshow(`Replaced: `, result); !! \u8f93\u51fa: Hello, Oraset!\n</code></pre>"},{"location":"libraries/string/#stringreplacealls-old-new","title":"string.replaceAll(s, old, new)","text":"<p>\u66ff\u6362\u6240\u6709\u5339\u914d\u7684\u5b50\u5b57\u7b26\u4e32\u3002</p> <p>\u53c2\u6570\uff1a - <code>s</code> - \u5b57\u7b26\u4e32 - <code>old</code> - \u8981\u66ff\u6362\u7684\u5b50\u5b57\u7b26\u4e32 - <code>new</code> - \u66ff\u6362\u540e\u7684\u5b50\u5b57\u7b26\u4e32</p> <p>\u8fd4\u56de\u503c\uff1a - \u66ff\u6362\u540e\u7684\u5b57\u7b26\u4e32</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@string;\n\ntext = `Hello, World! Hello, World!`;\nresult = string.replaceAll(text, `World`, `Oraset`);\nshow(`Replaced all: `, result); !! \u8f93\u51fa: Hello, Oraset! Hello, Oraset!\n</code></pre>"},{"location":"libraries/string/#_10","title":"\u5b57\u7b26\u4e32\u4fee\u526a","text":""},{"location":"libraries/string/#stringtrims","title":"string.trim(s)","text":"<p>\u79fb\u9664\u5b57\u7b26\u4e32\u4e24\u7aef\u7684\u7a7a\u767d\u5b57\u7b26\u3002</p> <p>\u53c2\u6570\uff1a - <code>s</code> - \u5b57\u7b26\u4e32</p> <p>\u8fd4\u56de\u503c\uff1a - \u4fee\u526a\u540e\u7684\u5b57\u7b26\u4e32</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@string;\n\ntext = ` Hello, Oraset! `;\nresult = string.trim(text);\nshow(`Trimmed: `, result); !! \u8f93\u51fa: Hello, Oraset!\n</code></pre>"},{"location":"libraries/string/#stringtrimstarts","title":"string.trimStart(s)","text":"<p>\u79fb\u9664\u5b57\u7b26\u4e32\u5f00\u5934\u7684\u7a7a\u767d\u5b57\u7b26\u3002</p> <p>\u53c2\u6570\uff1a - <code>s</code> - \u5b57\u7b26\u4e32</p> <p>\u8fd4\u56de\u503c\uff1a - \u4fee\u526a\u540e\u7684\u5b57\u7b26\u4e32</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@string;\n\ntext = ` Hello, Oraset!`;\nresult = string.trimStart(text);\nshow(`Trimmed start: `, result); !! \u8f93\u51fa: Hello, Oraset!\n</code></pre>"},{"location":"libraries/string/#stringtrimends","title":"string.trimEnd(s)","text":"<p>\u79fb\u9664\u5b57\u7b26\u4e32\u672b\u5c3e\u7684\u7a7a\u767d\u5b57\u7b26\u3002</p> <p>\u53c2\u6570\uff1a - <code>s</code> - \u5b57\u7b26\u4e32</p> <p>\u8fd4\u56de\u503c\uff1a - \u4fee\u526a\u540e\u7684\u5b57\u7b26\u4e32</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@string;\n\ntext = `Hello, Oraset! `;\nresult = string.trimEnd(text);\nshow(`Trimmed end: `, result); !! \u8f93\u51fa: Hello, Oraset!\n</code></pre>"},{"location":"libraries/string/#_11","title":"\u5b57\u7b26\u4e32\u68c0\u67e5","text":""},{"location":"libraries/string/#stringstartswiths-prefix","title":"string.startsWith(s, prefix)","text":"<p>\u68c0\u67e5\u5b57\u7b26\u4e32\u662f\u5426\u4ee5\u6307\u5b9a\u524d\u7f00\u5f00\u5934\u3002</p> <p>\u53c2\u6570\uff1a - <code>s</code> - \u5b57\u7b26\u4e32 - <code>prefix</code> - \u524d\u7f00</p> <p>\u8fd4\u56de\u503c\uff1a - \u5e03\u5c14\u503c\uff0c\u8868\u793a\u662f\u5426\u4ee5\u6307\u5b9a\u524d\u7f00\u5f00\u5934</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@string;\n\ntext = `Hello, Oraset!`;\nresult1 = string.startsWith(text, `Hello`);\nresult2 = string.startsWith(text, `World`);\nshow(`Starts with 'Hello': `, result1); !! \u8f93\u51fa: true\nshow(`Starts with 'World': `, result2); !! \u8f93\u51fa: false\n</code></pre>"},{"location":"libraries/string/#stringendswiths-suffix","title":"string.endsWith(s, suffix)","text":"<p>\u68c0\u67e5\u5b57\u7b26\u4e32\u662f\u5426\u4ee5\u6307\u5b9a\u540e\u7f00\u7ed3\u5c3e\u3002</p> <p>\u53c2\u6570\uff1a - <code>s</code> - \u5b57\u7b26\u4e32 - <code>suffix</code> - \u540e\u7f00</p> <p>\u8fd4\u56de\u503c\uff1a - \u5e03\u5c14\u503c\uff0c\u8868\u793a\u662f\u5426\u4ee5\u6307\u5b9a\u540e\u7f00\u7ed3\u5c3e</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@string;\n\ntext = `Hello, Oraset!`;\nresult1 = string.endsWith(text, `!`);\nresult2 = string.endsWith(text, `.`);\nshow(`Ends with '!': `, result1); !! \u8f93\u51fa: true\nshow(`Ends with '.': `, result2); !! \u8f93\u51fa: false\n</code></pre>"},{"location":"libraries/string/#_12","title":"\u5b57\u7b26\u4e32\u91cd\u590d","text":""},{"location":"libraries/string/#stringrepeats-count","title":"string.repeat(s, count)","text":"<p>\u91cd\u590d\u5b57\u7b26\u4e32\u6307\u5b9a\u6b21\u6570\u3002</p> <p>\u53c2\u6570\uff1a - <code>s</code> - \u5b57\u7b26\u4e32 - <code>count</code> - \u91cd\u590d\u6b21\u6570</p> <p>\u8fd4\u56de\u503c\uff1a - \u91cd\u590d\u540e\u7684\u5b57\u7b26\u4e32</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@string;\n\ntext = `Hello `;\nresult = string.repeat(text, 3);\nshow(`Repeated: `, result); !! \u8f93\u51fa: Hello Hello Hello \n</code></pre>"},{"location":"libraries/string/#_13","title":"\u5b57\u7b26\u4e32\u53cd\u8f6c","text":""},{"location":"libraries/string/#stringreverses","title":"string.reverse(s)","text":"<p>\u53cd\u8f6c\u5b57\u7b26\u4e32\u3002</p> <p>\u53c2\u6570\uff1a - <code>s</code> - \u5b57\u7b26\u4e32</p> <p>\u8fd4\u56de\u503c\uff1a - \u53cd\u8f6c\u540e\u7684\u5b57\u7b26\u4e32</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@string;\n\ntext = `Hello`;\nresult = string.reverse(text);\nshow(`Reversed: `, result); !! \u8f93\u51fa: olleH\n</code></pre>"},{"location":"libraries/string/#_14","title":"\u793a\u4f8b\u4ee3\u7801","text":"<pre><code>@string;\n\n!! \u5b57\u7b26\u4e32\u5206\u5272\u4e0e\u8fde\u63a5\ntext = `Hello,World,Oraset`;\nshow(`Original: `, text);\nshow(`Split: `, string.split(text, `,`));\n\narr = arr(`Hello`, `World`, `Oraset`);\nshow(`Joined: `, string.join(arr, ` `));\n\n!! \u5927\u5c0f\u5199\u8f6c\u6362\ntext = `Hello, Oraset!`;\nshow(`Original: `, text);\nshow(`Upper: `, string.upper(text));\nshow(`Lower: `, string.lower(text));\nshow(`Capitalized: `, string.capitalize(text));\n\n!! \u5b57\u7b26\u4e32\u957f\u5ea6\u4e0e\u63d0\u53d6\ntext = `Hello, Oraset!`;\nshow(`Length: `, string.length(text));\nshow(`Substring from 7: `, string.substring(text, 7));\nshow(`Substring 0-5: `, string.substring(text, 0, 5));\nshow(`Character at 0: `, string.charAt(text, 0));\n\n!! \u5b57\u7b26\u4e32\u67e5\u627e\ntext = `Hello, Oraset!`;\nshow(`Index of 'Oraset': `, string.indexOf(text, `Oraset`));\nshow(`Includes 'Oraset': `, string.includes(text, `Oraset`));\n\n!! \u5b57\u7b26\u4e32\u66ff\u6362\ntext = `Hello, World!`;\nshow(`Original: `, text);\nshow(`Replaced: `, string.replace(text, `World`, `Oraset`));\n\n!! \u5b57\u7b26\u4e32\u4fee\u526a\ntext = ` Hello, Oraset! `;\nshow(`Original: '`, text, `'`);\nshow(`Trimmed: '`, string.trim(text), `'`);\nshow(`Trimmed start: '`, string.trimStart(text), `'`);\nshow(`Trimmed end: '`, string.trimEnd(text), `'`);\n\n!! \u5b57\u7b26\u4e32\u68c0\u67e5\ntext = `Hello, Oraset!`;\nshow(`Starts with 'Hello': `, string.startsWith(text, `Hello`));\nshow(`Ends with '!': `, string.endsWith(text, `!`));\n\n!! \u5b57\u7b26\u4e32\u91cd\u590d\u548c\u53cd\u8f6c\ntext = `Hello`;\nshow(`Original: `, text);\nshow(`Repeated: `, string.repeat(text, 3));\nshow(`Reversed: `, string.reverse(text));\n</code></pre>"},{"location":"libraries/string/#_15","title":"\u6ce8\u610f\u4e8b\u9879","text":"<ul> <li>\u5b57\u7b26\u4e32\u7d22\u5f15\u4ece 0 \u5f00\u59cb</li> <li>\u6240\u6709\u5b57\u7b26\u4e32\u64cd\u4f5c\u51fd\u6570\u90fd\u8fd4\u56de\u65b0\u7684\u5b57\u7b26\u4e32\uff0c\u4e0d\u4f1a\u4fee\u6539\u539f\u59cb\u5b57\u7b26\u4e32</li> <li>\u5bf9\u4e8e <code>substring</code> \u51fd\u6570\uff0c\u5982\u679c\u4e0d\u6307\u5b9a <code>end</code> \u53c2\u6570\uff0c\u5c06\u63d0\u53d6\u5230\u5b57\u7b26\u4e32\u672b\u5c3e</li> <li>\u5bf9\u4e8e <code>split</code> \u51fd\u6570\uff0c\u5982\u679c\u5206\u9694\u7b26\u4e3a\u7a7a\u5b57\u7b26\u4e32\uff0c\u5c06\u5206\u5272\u6bcf\u4e2a\u5b57\u7b26</li> </ul>"},{"location":"libraries/util/","title":"\u5de5\u5177\u5e93","text":""},{"location":"libraries/util/#_2","title":"\u7b80\u4ecb","text":"<p>\u5de5\u5177\u5e93\uff08<code>@util</code>\uff09\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u5b9e\u7528\u7684\u5de5\u5177\u51fd\u6570\uff0c\u5305\u62ec\u968f\u673a\u6570\u751f\u6210\u3001\u6570\u5b66\u8ba1\u7b97\u3001\u7c7b\u578b\u68c0\u67e5\u7b49\u529f\u80fd\u3002</p>"},{"location":"libraries/util/#_3","title":"\u5bfc\u5165\u65b9\u5f0f","text":"<pre><code>@util;\n</code></pre>"},{"location":"libraries/util/#_4","title":"\u51fd\u6570\u53c2\u8003","text":""},{"location":"libraries/util/#_5","title":"\u968f\u673a\u6570\u751f\u6210","text":""},{"location":"libraries/util/#utilrandom","title":"util.random()","text":"<p>\u751f\u6210\u4e00\u4e2a0\u52301\u4e4b\u95f4\u7684\u968f\u673a\u5c0f\u6570\u3002</p> <p>\u53c2\u6570\uff1a - \u65e0</p> <p>\u8fd4\u56de\u503c\uff1a - 0\u52301\u4e4b\u95f4\u7684\u968f\u673a\u5c0f\u6570</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@util;\n\nresult = util.random();\nshow(`Random number: `, result); !! \u8f93\u51fa: 0.123456789\n</code></pre>"},{"location":"libraries/util/#utilrandinta-b","title":"util.randint(a, b)","text":"<p>\u751f\u6210\u4e00\u4e2a\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 - \u8303\u56f4\u5185\u7684\u968f\u673a\u6574\u6570</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@util;\n\nresult = util.randint(1, 100);\nshow(`Random integer: `, result); !! \u8f93\u51fa: 42\n</code></pre>"},{"location":"libraries/util/#_6","title":"\u6570\u5b66\u8ba1\u7b97","text":""},{"location":"libraries/util/#utilroundx-n","title":"util.round(x, n)","text":"<p>\u5bf9\u6570\u5b57\u8fdb\u884c\u56db\u820d\u4e94\u5165\u3002</p> <p>\u53c2\u6570\uff1a - <code>x</code> - \u8981\u56db\u820d\u4e94\u5165\u7684\u6570\u5b57 - <code>n</code> - \u5c0f\u6570\u4f4d\u6570\uff08\u9ed8\u8ba4\u4e3a0\uff09</p> <p>\u8fd4\u56de\u503c\uff1a - \u56db\u820d\u4e94\u5165\u540e\u7684\u6570\u5b57</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@util;\n\nresult1 = util.round(3.14159);\nresult2 = util.round(3.14159, 2);\nshow(`Rounded: `, result1); !! \u8f93\u51fa: 3\nshow(`Rounded to 2 decimals: `, result2); !! \u8f93\u51fa: 3.14\n</code></pre>"},{"location":"libraries/util/#utilabsx","title":"util.abs(x)","text":"<p>\u8ba1\u7b97\u6570\u5b57\u7684\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>@util;\n\nresult = util.abs(-123);\nshow(`Absolute value: `, result); !! \u8f93\u51fa: 123\n</code></pre>"},{"location":"libraries/util/#utilminargs","title":"util.min(...args)","text":"<p>\u8fd4\u56de\u591a\u4e2a\u6570\u5b57\u4e2d\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>@util;\n\nresult = util.min(10, 5, 20, 3);\nshow(`Minimum: `, result); !! \u8f93\u51fa: 3\n</code></pre>"},{"location":"libraries/util/#utilmaxargs","title":"util.max(...args)","text":"<p>\u8fd4\u56de\u591a\u4e2a\u6570\u5b57\u4e2d\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>@util;\n\nresult = util.max(10, 5, 20, 3);\nshow(`Maximum: `, result); !! \u8f93\u51fa: 20\n</code></pre>"},{"location":"libraries/util/#utilsumargs","title":"util.sum(...args)","text":"<p>\u8ba1\u7b97\u591a\u4e2a\u6570\u5b57\u7684\u548c\u3002</p> <p>\u53c2\u6570\uff1a - <code>...args</code> - \u591a\u4e2a\u6570\u5b57</p> <p>\u8fd4\u56de\u503c\uff1a - \u6570\u5b57\u7684\u548c</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@util;\n\nresult = util.sum(1, 2, 3, 4, 5);\nshow(`Sum: `, result); !! \u8f93\u51fa: 15\n</code></pre>"},{"location":"libraries/util/#utilaverageargs","title":"util.average(...args)","text":"<p>\u8ba1\u7b97\u591a\u4e2a\u6570\u5b57\u7684\u5e73\u5747\u503c\u3002</p> <p>\u53c2\u6570\uff1a - <code>...args</code> - \u591a\u4e2a\u6570\u5b57</p> <p>\u8fd4\u56de\u503c\uff1a - \u6570\u5b57\u7684\u5e73\u5747\u503c</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@util;\n\nresult = util.average(1, 2, 3, 4, 5);\nshow(`Average: `, result); !! \u8f93\u51fa: 3\n</code></pre>"},{"location":"libraries/util/#_7","title":"\u7c7b\u578b\u68c0\u67e5","text":""},{"location":"libraries/util/#utilisnumberx","title":"util.isNumber(x)","text":"<p>\u68c0\u67e5\u503c\u662f\u5426\u4e3a\u6570\u5b57\u3002</p> <p>\u53c2\u6570\uff1a - <code>x</code> - \u8981\u68c0\u67e5\u7684\u503c</p> <p>\u8fd4\u56de\u503c\uff1a - \u5e03\u5c14\u503c\uff0c\u8868\u793a\u662f\u5426\u4e3a\u6570\u5b57</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@util;\n\nresult1 = util.isNumber(123);\nresult2 = util.isNumber(`123`);\nresult3 = util.isNumber(`abc`);\nshow(`Is 123 a number: `, result1); !! \u8f93\u51fa: true\nshow(`Is '123' a number: `, result2); !! \u8f93\u51fa: true\nshow(`Is 'abc' a number: `, result3); !! \u8f93\u51fa: false\n</code></pre>"},{"location":"libraries/util/#utilisstringx","title":"util.isString(x)","text":"<p>\u68c0\u67e5\u503c\u662f\u5426\u4e3a\u5b57\u7b26\u4e32\u3002</p> <p>\u53c2\u6570\uff1a - <code>x</code> - \u8981\u68c0\u67e5\u7684\u503c</p> <p>\u8fd4\u56de\u503c\uff1a - \u5e03\u5c14\u503c\uff0c\u8868\u793a\u662f\u5426\u4e3a\u5b57\u7b26\u4e32</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@util;\n\nresult1 = util.isString(`Hello`);\nresult2 = util.isString(123);\nshow(`Is 'Hello' a string: `, result1); !! \u8f93\u51fa: true\nshow(`Is 123 a string: `, result2); !! \u8f93\u51fa: false\n</code></pre>"},{"location":"libraries/util/#utilisarrayx","title":"util.isArray(x)","text":"<p>\u68c0\u67e5\u503c\u662f\u5426\u4e3a\u6570\u7ec4\u3002</p> <p>\u53c2\u6570\uff1a - <code>x</code> - \u8981\u68c0\u67e5\u7684\u503c</p> <p>\u8fd4\u56de\u503c\uff1a - \u5e03\u5c14\u503c\uff0c\u8868\u793a\u662f\u5426\u4e3a\u6570\u7ec4</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@util;\n\nresult1 = util.isArray(arr(1, 2, 3));\nresult2 = util.isArray(`[1, 2, 3]`);\nresult3 = util.isArray(123);\nshow(`Is arr(1, 2, 3) an array: `, result1); !! \u8f93\u51fa: true\nshow(`Is '[1, 2, 3]' an array: `, result2); !! \u8f93\u51fa: true\nshow(`Is 123 an array: `, result3); !! \u8f93\u51fa: false\n</code></pre>"},{"location":"libraries/util/#_8","title":"\u7c7b\u578b\u8f6c\u6362","text":""},{"location":"libraries/util/#utiltonumberx","title":"util.toNumber(x)","text":"<p>\u5c06\u503c\u8f6c\u6362\u4e3a\u6570\u5b57\u3002</p> <p>\u53c2\u6570\uff1a - <code>x</code> - \u8981\u8f6c\u6362\u7684\u503c</p> <p>\u8fd4\u56de\u503c\uff1a - \u8f6c\u6362\u540e\u7684\u6570\u5b57</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@util;\n\nresult = util.toNumber(`123`);\nshow(`Converted to number: `, result); !! \u8f93\u51fa: 123\n</code></pre>"},{"location":"libraries/util/#utiltostringx","title":"util.toString(x)","text":"<p>\u5c06\u503c\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\u3002</p> <p>\u53c2\u6570\uff1a - <code>x</code> - \u8981\u8f6c\u6362\u7684\u503c</p> <p>\u8fd4\u56de\u503c\uff1a - \u8f6c\u6362\u540e\u7684\u5b57\u7b26\u4e32</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@util;\n\nresult = util.toString(123);\nshow(`Converted to string: `, result); !! \u8f93\u51fa: 123\n</code></pre>"},{"location":"libraries/util/#utiltypeofx","title":"util.typeof(x)","text":"<p>\u83b7\u53d6\u503c\u7684\u7c7b\u578b\u3002</p> <p>\u53c2\u6570\uff1a - <code>x</code> - \u8981\u68c0\u67e5\u7684\u503c</p> <p>\u8fd4\u56de\u503c\uff1a - \u503c\u7684\u7c7b\u578b\uff08'array'\u3001'number'\u3001'string' \u6216 'unknown'\uff09</p> <p>\u793a\u4f8b\uff1a</p> <pre><code>@util;\n\nresult1 = util.typeof(123);\nresult2 = util.typeof(`Hello`);\nresult3 = util.typeof(arr(1, 2, 3));\nshow(`Type of 123: `, result1); !! \u8f93\u51fa: number\nshow(`Type of 'Hello': `, result2); !! \u8f93\u51fa: string\nshow(`Type of arr(1, 2, 3): `, result3); !! \u8f93\u51fa: array\n</code></pre>"},{"location":"libraries/util/#_9","title":"\u793a\u4f8b\u4ee3\u7801","text":"<pre><code>@util;\n\n!! \u968f\u673a\u6570\u751f\u6210\nshow(`Random number: `, util.random());\nshow(`Random integer (1-100): `, util.randint(1, 100));\n\n!! \u6570\u5b66\u8ba1\u7b97\nshow(`Absolute value of -123: `, util.abs(-123));\nshow(`Round 3.14159: `, util.round(3.14159));\nshow(`Round 3.14159 to 2 decimals: `, util.round(3.14159, 2));\nshow(`Minimum of 10, 5, 20, 3: `, util.min(10, 5, 20, 3));\nshow(`Maximum of 10, 5, 20, 3: `, util.max(10, 5, 20, 3));\nshow(`Sum of 1, 2, 3, 4, 5: `, util.sum(1, 2, 3, 4, 5));\nshow(`Average of 1, 2, 3, 4, 5: `, util.average(1, 2, 3, 4, 5));\n\n!! \u7c7b\u578b\u68c0\u67e5\nshow(`Is 123 a number: `, util.isNumber(123));\nshow(`Is '123' a number: `, util.isNumber(`123`));\nshow(`Is 'abc' a number: `, util.isNumber(`abc`));\nshow(`Is 'Hello' a string: `, util.isString(`Hello`));\nshow(`Is 123 a string: `, util.isString(123));\nshow(`Is arr(1, 2, 3) an array: `, util.isArray(arr(1, 2, 3)));\n\n!! \u7c7b\u578b\u8f6c\u6362\nshow(`Convert '123' to number: `, util.toNumber(`123`));\nshow(`Convert 123 to string: `, util.toString(123));\n\n!! \u7c7b\u578b\u5224\u65ad\nshow(`Type of 123: `, util.typeof(123));\nshow(`Type of 'Hello': `, util.typeof(`Hello`));\nshow(`Type of arr(1, 2, 3): `, util.typeof(arr(1, 2, 3)));\n</code></pre>"},{"location":"libraries/util/#_10","title":"\u6ce8\u610f\u4e8b\u9879","text":"<ul> <li>\u6240\u6709\u5de5\u5177\u51fd\u6570\u90fd\u4e0d\u4f1a\u4fee\u6539\u539f\u59cb\u503c\uff0c\u800c\u662f\u8fd4\u56de\u65b0\u7684\u503c</li> <li>\u7c7b\u578b\u68c0\u67e5\u51fd\u6570\u4f1a\u5c1d\u8bd5\u8fdb\u884c\u5408\u7406\u7684\u7c7b\u578b\u5224\u65ad</li> <li>\u5bf9\u4e8e <code>isNumber</code> \u51fd\u6570\uff0c\u5b57\u7b26\u4e32\u5f62\u5f0f\u7684\u6570\u5b57\u4e5f\u4f1a\u88ab\u8ba4\u4e3a\u662f\u6570\u5b57</li> <li>\u5bf9\u4e8e <code>isArray</code> \u51fd\u6570\uff0c\u5b57\u7b26\u4e32\u5f62\u5f0f\u7684\u6570\u7ec4\u8868\u793a\u4e5f\u4f1a\u88ab\u8ba4\u4e3a\u662f\u6570\u7ec4</li> </ul>"},{"location":"tutorial/basic-syntax/","title":"\u57fa\u672c\u8bed\u6cd5","text":"<p>\u672c\u6559\u7a0b\u5c06\u8be6\u7ec6\u4ecb\u7ecd Oraset \u7f16\u7a0b\u8bed\u8a00\u7684\u57fa\u672c\u8bed\u6cd5\uff0c\u5305\u62ec\u53d8\u91cf\u3001\u6570\u636e\u7c7b\u578b\u3001\u8fd0\u7b97\u7b26\u3001\u8868\u8fbe\u5f0f\u7b49\u5185\u5bb9\u3002</p>"},{"location":"tutorial/basic-syntax/#_2","title":"\u6ce8\u91ca","text":"<p>Oraset \u4f7f\u7528\u4e24\u79cd\u6ce8\u91ca\u65b9\u5f0f\uff1a</p> <ul> <li>\u5355\u884c\u6ce8\u91ca\uff1a\u4f7f\u7528 <code>!!</code> \u5f00\u59cb</li> <li>\u591a\u884c\u6ce8\u91ca\uff1a\u4f7f\u7528 <code>!*</code> \u5f00\u59cb\uff0c<code>*!</code> \u7ed3\u675f</li> </ul> <pre><code>!! \u8fd9\u662f\u4e00\u4e2a\u5355\u884c\u6ce8\u91ca\n\n!* \u8fd9\u662f\u4e00\u4e2a\n\u591a\u884c\u6ce8\u91ca *!\n</code></pre>"},{"location":"tutorial/basic-syntax/#_3","title":"\u53d8\u91cf","text":""},{"location":"tutorial/basic-syntax/#_4","title":"\u53d8\u91cf\u58f0\u660e\u4e0e\u8d4b\u503c","text":"<p>Oraset \u4f7f\u7528 <code>=</code> \u8fdb\u884c\u53d8\u91cf\u8d4b\u503c\uff0c\u4e0d\u9700\u8981\u663e\u5f0f\u58f0\u660e\u53d8\u91cf\u7c7b\u578b\uff1a</p> <pre><code>!! \u53d8\u91cf\u8d4b\u503c\nname = `World`; !! \u5b57\u7b26\u4e32\nage = 20; !! \u6574\u6570\npi = 3.14159; !! \u6d6e\u70b9\u6570\nis_valid = true; !! \u5e03\u5c14\u503c\n</code></pre>"},{"location":"tutorial/basic-syntax/#_5","title":"\u53d8\u91cf\u547d\u540d\u89c4\u5219","text":"<ul> <li>\u53d8\u91cf\u540d\u53ea\u80fd\u5305\u542b\u5b57\u6bcd\u3001\u6570\u5b57\u548c\u4e0b\u5212\u7ebf</li> <li>\u53d8\u91cf\u540d\u4e0d\u80fd\u4ee5\u6570\u5b57\u5f00\u5934</li> <li>\u53d8\u91cf\u540d\u533a\u5206\u5927\u5c0f\u5199</li> <li>\u53d8\u91cf\u540d\u4e0d\u80fd\u4f7f\u7528\u5173\u952e\u5b57\uff08\u5982 <code>if</code>\u3001<code>else</code>\u3001<code>while</code>\u3001<code>def</code>\u3001<code>class</code> \u7b49\uff09</li> </ul>"},{"location":"tutorial/basic-syntax/#_6","title":"\u53d8\u91cf\u4f5c\u7528\u57df","text":"<ul> <li>\u5168\u5c40\u53d8\u91cf\uff1a\u5728\u51fd\u6570\u5916\u90e8\u5b9a\u4e49\u7684\u53d8\u91cf</li> <li>\u5c40\u90e8\u53d8\u91cf\uff1a\u5728\u51fd\u6570\u5185\u90e8\u5b9a\u4e49\u7684\u53d8\u91cf</li> </ul> <pre><code>!! \u5168\u5c40\u53d8\u91cf\nglobal_var = `Global`;\n\ndef test() {\n !! \u5c40\u90e8\u53d8\u91cf\n local_var = `Local`;\n show(global_var); !! \u53ef\u4ee5\u8bbf\u95ee\u5168\u5c40\u53d8\u91cf\n show(local_var); !! \u53ef\u4ee5\u8bbf\u95ee\u5c40\u90e8\u53d8\u91cf\n}\n\ntest();\nshow(global_var); !! \u53ef\u4ee5\u8bbf\u95ee\u5168\u5c40\u53d8\u91cf\n!! show(local_var); !! \u9519\u8bef\uff1a\u65e0\u6cd5\u8bbf\u95ee\u5c40\u90e8\u53d8\u91cf\n</code></pre>"},{"location":"tutorial/basic-syntax/#_7","title":"\u6570\u636e\u7c7b\u578b","text":""},{"location":"tutorial/basic-syntax/#_8","title":"\u6570\u5b57","text":"<p>Oraset \u652f\u6301\u6574\u6570\u548c\u6d6e\u70b9\u6570\uff1a</p> <pre><code>!! \u6574\u6570\ninteger = 123;\nnegative = -456;\n\n!! \u6d6e\u70b9\u6570\nfloat = 3.14;\nscientific = 1.23e4; !! 12300\n</code></pre>"},{"location":"tutorial/basic-syntax/#_9","title":"\u5b57\u7b26\u4e32","text":"<p>Oraset \u4f7f\u7528\u53cd\u5f15\u53f7 <code>`</code> \u8868\u793a\u5b57\u7b26\u4e32\uff1a</p> <pre><code>!! \u5b57\u7b26\u4e32\nstr1 = `Hello`;\nstr2 = `World`;\n\n!! \u5b57\u7b26\u4e32\u62fc\u63a5\ncombined = str1 + ` ` + str2;\nshow(combined); !! \u8f93\u51fa: Hello World\n</code></pre>"},{"location":"tutorial/basic-syntax/#_10","title":"\u6570\u7ec4","text":"<p>Oraset \u4f7f\u7528 <code>arr()</code> \u51fd\u6570\u521b\u5efa\u6570\u7ec4\uff1a</p> <pre><code>!! \u6570\u7ec4\nempty = arr();\nnumbers = arr(1, 2, 3, 4, 5);\nfruits = arr(`apple`, `banana`, `cherry`);\nmixed = arr(1, `hello`, 3.14);\n\n!! \u8bbf\u95ee\u6570\u7ec4\u5143\u7d20\nshow(numbers[0]); !! \u8f93\u51fa: 1\nshow(fruits[1]); !! \u8f93\u51fa: banana\n</code></pre>"},{"location":"tutorial/basic-syntax/#_11","title":"\u5e03\u5c14\u503c","text":"<p>Oraset \u652f\u6301\u5e03\u5c14\u503c <code>true</code> \u548c <code>false</code>\uff1a</p> <pre><code>!! \u5e03\u5c14\u503c\ntrue_value = true;\nfalse_value = false;\n\n!! \u5e03\u5c14\u8868\u8fbe\u5f0f\nis_greater = 5 &gt; 3; !! true\nis_equal = 5 == 3; !! false\n</code></pre>"},{"location":"tutorial/basic-syntax/#_12","title":"\u8fd0\u7b97\u7b26","text":""},{"location":"tutorial/basic-syntax/#_13","title":"\u7b97\u672f\u8fd0\u7b97\u7b26","text":"\u8fd0\u7b97\u7b26 \u63cf\u8ff0 \u793a\u4f8b <code>+</code> \u52a0\u6cd5 <code>a + b</code> <code>-</code> \u51cf\u6cd5 <code>a - b</code> <code>*</code> \u4e58\u6cd5 <code>a * b</code> <code>/</code> \u9664\u6cd5 <code>a / b</code> <code>%</code> \u53d6\u6a21 <code>a % b</code> <code>**</code> \u5e42\u8fd0\u7b97 <code>a ** b</code> <pre><code>!! \u7b97\u672f\u8fd0\u7b97\u7b26\na = 10;\nb = 3;\n\nshow(`a + b = `, a + b); !! 13\nshow(`a - b = `, a - b); !! 7\nshow(`a * b = `, a * b); !! 30\nshow(`a / b = `, a / b); !! 3.3333333333333335\nshow(`a % b = `, a % b); !! 1\nshow(`a ** b = `, a ** b); !! 1000\n</code></pre>"},{"location":"tutorial/basic-syntax/#_14","title":"\u6bd4\u8f83\u8fd0\u7b97\u7b26","text":"\u8fd0\u7b97\u7b26 \u63cf\u8ff0 \u793a\u4f8b <code>==</code> \u7b49\u4e8e <code>a == b</code> <code>!=</code> \u4e0d\u7b49\u4e8e <code>a != b</code> <code>&lt;</code> \u5c0f\u4e8e <code>a &lt; b</code> <code>&gt;</code> \u5927\u4e8e <code>a &gt; b</code> <code>&lt;=</code> \u5c0f\u4e8e\u7b49\u4e8e <code>a &lt;= b</code> <code>&gt;=</code> \u5927\u4e8e\u7b49\u4e8e <code>a &gt;= b</code> <pre><code>!! \u6bd4\u8f83\u8fd0\u7b97\u7b26\na = 5;\nb = 10;\n\nshow(`a == b: `, a == b); !! false\nshow(`a != b: `, a != b); !! true\nshow(`a &lt; b: `, a &lt; b); !! true\nshow(`a &gt; b: `, a &gt; b); !! false\nshow(`a &lt;= b: `, a &lt;= b); !! true\nshow(`a &gt;= b: `, a &gt;= b); !! false\n</code></pre>"},{"location":"tutorial/basic-syntax/#_15","title":"\u903b\u8f91\u8fd0\u7b97\u7b26","text":"\u8fd0\u7b97\u7b26 \u63cf\u8ff0 \u793a\u4f8b <code>&amp;&amp;</code> \u903b\u8f91\u4e0e <code>a &amp;&amp; b</code> <code>||</code> \u903b\u8f91\u6216 <code>a || b</code> <code>!</code> \u903b\u8f91\u975e <code>!a</code> <pre><code>!! \u903b\u8f91\u8fd0\u7b97\u7b26\nt = true;\nf = false;\n\nshow(`t &amp;&amp; f: `, t &amp;&amp; f); !! false\nshow(`t || f: `, t || f); !! true\nshow(`!t: `, !t); !! false\nshow(`!f: `, !f); !! true\n</code></pre>"},{"location":"tutorial/basic-syntax/#_16","title":"\u8d4b\u503c\u8fd0\u7b97\u7b26","text":"\u8fd0\u7b97\u7b26 \u63cf\u8ff0 \u793a\u4f8b <code>=</code> \u7b80\u5355\u8d4b\u503c <code>a = b</code> <code>+=</code> \u52a0\u8d4b\u503c <code>a += b</code> <code>-=</code> \u51cf\u8d4b\u503c <code>a -= b</code> <code>*=</code> \u4e58\u8d4b\u503c <code>a *= b</code> <code>/=</code> \u9664\u8d4b\u503c <code>a /= b</code> <code>%=</code> \u53d6\u6a21\u8d4b\u503c <code>a %= b</code> <pre><code>!! \u8d4b\u503c\u8fd0\u7b97\u7b26\na = 10;\nshow(`Initial a: `, a); !! 10\n\na += 5;\nshow(`a += 5: `, a); !! 15\n\na -= 3;\nshow(`a -= 3: `, a); !! 12\n\na *= 2;\nshow(`a *= 2: `, a); !! 24\n\na /= 4;\nshow(`a /= 4: `, a); !! 6\n\na %= 5;\nshow(`a %= 5: `, a); !! 1\n</code></pre>"},{"location":"tutorial/basic-syntax/#_17","title":"\u8868\u8fbe\u5f0f","text":"<p>\u8868\u8fbe\u5f0f\u662f\u7531\u53d8\u91cf\u3001\u5e38\u91cf\u3001\u8fd0\u7b97\u7b26\u548c\u51fd\u6570\u8c03\u7528\u7ec4\u6210\u7684\u7ec4\u5408\uff0c\u7528\u4e8e\u8ba1\u7b97\u503c\uff1a</p> <pre><code>!! \u8868\u8fbe\u5f0f\nresult = (10 + 5) * 2 / 3;\nshow(`Result: `, result); !! 10.0\n\n!! \u590d\u6742\u8868\u8fbe\u5f0f\na = 10;\nb = 5;\nc = 3;\nresult = (a + b) * c - (a / b);\nshow(`Result: `, result); !! 45.0\n</code></pre>"},{"location":"tutorial/basic-syntax/#_18","title":"\u8f93\u5165\u8f93\u51fa","text":""},{"location":"tutorial/basic-syntax/#_19","title":"\u8f93\u51fa","text":"<p>\u4f7f\u7528 <code>show</code> \u51fd\u6570\u8f93\u51fa\u5185\u5bb9\uff1a</p> <pre><code>!! \u8f93\u51fa\nshow(`Hello, World!`);\nshow(`The answer is: `, 42);\nshow(`Pi is approximately: `, 3.14159);\n</code></pre>"},{"location":"tutorial/basic-syntax/#_20","title":"\u8f93\u5165","text":"<p>\u4f7f\u7528 <code>input</code> \u51fd\u6570\u83b7\u53d6\u7528\u6237\u8f93\u5165\uff1a</p> <pre><code>!! \u8f93\u5165\nname = input(`What's your name? `);\nage = input(`How old are you? `);\nshow(`Hello, `, name, `! You are `, age, ` years old.`);\n</code></pre>"},{"location":"tutorial/basic-syntax/#_21","title":"\u8f6c\u4e49\u5b57\u7b26","text":"<p>Oraset \u652f\u6301\u4ee5\u4e0b\u8f6c\u4e49\u5b57\u7b26\uff1a</p> \u8f6c\u4e49\u5b57\u7b26 \u63cf\u8ff0 <code>\\n</code> \u6362\u884c <code>\\t</code> \u5236\u8868\u7b26 <code>\\r</code> \u56de\u8f66 <code>\\</code> \u53cd\u659c\u6760 <code>\\`</code> \u53cd\u5f15\u53f7 <pre><code>!! \u8f6c\u4e49\u5b57\u7b26\nshow(`Line 1\\nLine 2`);\nshow(`Name:\\tJohn`);\nshow(`Path: C:\\\\folder\\\\file.txt`);\nshow(`He said: \\`Hello!\\``);\n</code></pre>"},{"location":"tutorial/basic-syntax/#_22","title":"\u793a\u4f8b\u4ee3\u7801","text":"<pre><code>!! \u57fa\u672c\u8bed\u6cd5\u793a\u4f8b\n\n!! \u53d8\u91cf\u8d4b\u503c\nname = `Oraset`;\nage = 20;\npi = 3.14159;\n\n!! \u7b97\u672f\u8fd0\u7b97\nradius = 5;\narea = pi * radius ** 2;\nshow(`Area of circle: `, area);\n\n!! \u5b57\u7b26\u4e32\u64cd\u4f5c\ngreeting = `Hello, ` + name + `!`;\nshow(greeting);\n\n!! \u6570\u7ec4\u64cd\u4f5c\nnumbers = arr(1, 2, 3, 4, 5);\nsum = 0;\ni = 0;\n\nwhile (i &lt; 5) {\n sum = sum + numbers[i];\n i = i + 1;\n}\n\nshow(`Sum of numbers: `, sum);\n\n!! \u8f93\u5165\u8f93\u51fa\nuser_name = input(`What's your name? `);\nshow(`Nice to meet you, `, user_name, `!`);\n</code></pre>"},{"location":"tutorial/basic-syntax/#_23","title":"\u5c0f\u7ed3","text":"<p>\u672c\u6559\u7a0b\u4ecb\u7ecd\u4e86 Oraset \u7f16\u7a0b\u8bed\u8a00\u7684\u57fa\u672c\u8bed\u6cd5\uff0c\u5305\u62ec\uff1a</p> <ul> <li>\u6ce8\u91ca\u7684\u4f7f\u7528</li> <li>\u53d8\u91cf\u7684\u58f0\u660e\u548c\u8d4b\u503c</li> <li>\u6570\u636e\u7c7b\u578b\uff08\u6570\u5b57\u3001\u5b57\u7b26\u4e32\u3001\u6570\u7ec4\u3001\u5e03\u5c14\u503c\uff09</li> <li>\u5404\u79cd\u8fd0\u7b97\u7b26\uff08\u7b97\u672f\u3001\u6bd4\u8f83\u3001\u903b\u8f91\u3001\u8d4b\u503c\uff09</li> <li>\u8868\u8fbe\u5f0f\u7684\u4f7f\u7528</li> <li>\u8f93\u5165\u8f93\u51fa\u64cd\u4f5c</li> <li>\u8f6c\u4e49\u5b57\u7b26</li> </ul> <p>\u8fd9\u4e9b\u662f Oraset \u7f16\u7a0b\u7684\u57fa\u7840\uff0c\u638c\u63e1\u8fd9\u4e9b\u5185\u5bb9\u540e\uff0c\u4f60\u53ef\u4ee5\u5f00\u59cb\u7f16\u5199\u66f4\u590d\u6742\u7684\u7a0b\u5e8f\u3002</p>"},{"location":"tutorial/control-structures/","title":"\u63a7\u5236\u7ed3\u6784","text":"<p>\u672c\u6559\u7a0b\u5c06\u8be6\u7ec6\u4ecb\u7ecd Oraset \u7f16\u7a0b\u8bed\u8a00\u7684\u63a7\u5236\u7ed3\u6784\uff0c\u5305\u62ec\u6761\u4ef6\u8bed\u53e5\u548c\u5faa\u73af\u8bed\u53e5\uff0c\u5e2e\u52a9\u4f60\u638c\u63e1\u7a0b\u5e8f\u7684\u6d41\u7a0b\u63a7\u5236\u3002</p>"},{"location":"tutorial/control-structures/#_2","title":"\u6761\u4ef6\u8bed\u53e5","text":""},{"location":"tutorial/control-structures/#if","title":"if \u8bed\u53e5","text":"<p><code>if</code> \u8bed\u53e5\u7528\u4e8e\u6839\u636e\u6761\u4ef6\u6267\u884c\u4e0d\u540c\u7684\u4ee3\u7801\u5757\uff1a</p> <pre><code>!! if \u8bed\u53e5\nage = 18;\n\nif (age &gt;= 18) {\n show(`You are an adult.`);\n}\n</code></pre>"},{"location":"tutorial/control-structures/#if-else","title":"if-else \u8bed\u53e5","text":"<p><code>if-else</code> \u8bed\u53e5\u7528\u4e8e\u5728\u6761\u4ef6\u4e3a\u771f\u548c\u4e3a\u5047\u65f6\u6267\u884c\u4e0d\u540c\u7684\u4ee3\u7801\u5757\uff1a</p> <pre><code>!! if-else \u8bed\u53e5\nage = 16;\n\nif (age &gt;= 18) {\n show(`You are an adult.`);\n} else {\n show(`You are a minor.`);\n}\n</code></pre>"},{"location":"tutorial/control-structures/#if-else-if-else","title":"if-else if-else \u8bed\u53e5","text":"<p><code>if-else if-else</code> \u8bed\u53e5\u7528\u4e8e\u5904\u7406\u591a\u4e2a\u6761\u4ef6\uff1a</p> <pre><code>!! if-else if-else \u8bed\u53e5\nscore = 85;\n\nif (score &gt;= 90) {\n show(`Grade: A`);\n} else if (score &gt;= 80) {\n show(`Grade: B`);\n} else if (score &gt;= 70) {\n show(`Grade: C`);\n} else if (score &gt;= 60) {\n show(`Grade: D`);\n} else {\n show(`Grade: F`);\n}\n</code></pre>"},{"location":"tutorial/control-structures/#_3","title":"\u5d4c\u5957\u6761\u4ef6\u8bed\u53e5","text":"<p>\u6761\u4ef6\u8bed\u53e5\u53ef\u4ee5\u5d4c\u5957\u4f7f\u7528\uff1a</p> <pre><code>!! \u5d4c\u5957\u6761\u4ef6\u8bed\u53e5\nage = 20;\nhas_license = true;\n\nif (age &gt;= 18) {\n if (has_license) {\n show(`You can drive.`);\n } else {\n show(`You need a driver's license to drive.`);\n }\n} else {\n show(`You are too young to drive.`);\n}\n</code></pre>"},{"location":"tutorial/control-structures/#_4","title":"\u5faa\u73af\u8bed\u53e5","text":""},{"location":"tutorial/control-structures/#while","title":"while \u5faa\u73af","text":"<p><code>while</code> \u5faa\u73af\u7528\u4e8e\u91cd\u590d\u6267\u884c\u4ee3\u7801\u5757\uff0c\u76f4\u5230\u6761\u4ef6\u4e3a\u5047\uff1a</p> <pre><code>!! while \u5faa\u73af\ncount = 0;\n\nwhile (count &lt; 5) {\n show(`Count: `, count);\n count = count + 1;\n}\n</code></pre>"},{"location":"tutorial/control-structures/#_5","title":"\u65e0\u9650\u5faa\u73af","text":"<p>\u4f60\u53ef\u4ee5\u521b\u5efa\u65e0\u9650\u5faa\u73af\uff0c\u4f46\u9700\u8981\u6ce8\u610f\u5728\u9002\u5f53\u7684\u65f6\u5019\u4f7f\u7528 <code>break</code> \u8bed\u53e5\u9000\u51fa\u5faa\u73af\uff1a</p> <pre><code>!! \u65e0\u9650\u5faa\u73af\ni = 0;\n\nwhile (true) {\n show(`Iteration: `, i);\n i = i + 1;\n\n if (i &gt;= 5) {\n break; !! \u9000\u51fa\u5faa\u73af\n }\n}\n</code></pre>"},{"location":"tutorial/control-structures/#_6","title":"\u5faa\u73af\u63a7\u5236","text":""},{"location":"tutorial/control-structures/#break","title":"break \u8bed\u53e5","text":"<p><code>break</code> \u8bed\u53e5\u7528\u4e8e\u7acb\u5373\u9000\u51fa\u5faa\u73af\uff1a</p> <pre><code>!! break \u8bed\u53e5\ncount = 0;\n\nwhile (count &lt; 10) {\n show(`Count: `, count);\n\n if (count == 5) {\n show(`Breaking the loop.`);\n break;\n }\n\n count = count + 1;\n}\n</code></pre>"},{"location":"tutorial/control-structures/#continue","title":"continue \u8bed\u53e5","text":"<p><code>continue</code> \u8bed\u53e5\u7528\u4e8e\u8df3\u8fc7\u5f53\u524d\u5faa\u73af\u7684\u5269\u4f59\u90e8\u5206\uff0c\u76f4\u63a5\u8fdb\u5165\u4e0b\u4e00\u6b21\u5faa\u73af\uff1a</p> <pre><code>!! continue \u8bed\u53e5\ncount = 0;\n\nwhile (count &lt; 5) {\n count = count + 1;\n\n if (count == 3) {\n show(`Skipping count: `, count);\n continue;\n }\n\n show(`Count: `, count);\n}\n</code></pre>"},{"location":"tutorial/control-structures/#_7","title":"\u7efc\u5408\u793a\u4f8b","text":""},{"location":"tutorial/control-structures/#_8","title":"\u731c\u6570\u5b57\u6e38\u620f","text":"<pre><code>!! \u731c\u6570\u5b57\u6e38\u620f\n@math;\n\nsecret_number = math.randint(1, 100);\nguess = 0;\ntries = 0;\n\nshow(`I'm thinking of a number between 1 and 100.`);\nshow(`Can you guess what it is?`);\n\nwhile (guess != secret_number) {\n guess = input(`Enter your guess: `);\n guess = util.toNumber(guess);\n tries = tries + 1;\n\n if (guess &lt; secret_number) {\n show(`Too low!`);\n } else if (guess &gt; secret_number) {\n show(`Too high!`);\n } else {\n show(`Congratulations! You guessed the number in `, tries, ` tries.`);\n }\n}\n</code></pre>"},{"location":"tutorial/control-structures/#_9","title":"\u8ba1\u7b97\u6590\u6ce2\u90a3\u5951\u6570\u5217","text":"<pre><code>!! \u8ba1\u7b97\u6590\u6ce2\u90a3\u5951\u6570\u5217\nn = 10;\na = 0;\nb = 1;\ni = 0;\n\nshow(`Fibonacci sequence up to `, n, ` terms:`);\n\nwhile (i &lt; n) {\n show(a);\n next = a + b;\n a = b;\n b = next;\n i = i + 1;\n}\n</code></pre>"},{"location":"tutorial/control-structures/#_10","title":"\u7d20\u6570\u5224\u65ad","text":"<pre><code>!! \u7d20\u6570\u5224\u65ad\nnumber = input(`Enter a number: `);\nnumber = util.toNumber(number);\nis_prime = true;\n\nif (number &lt;= 1) {\n is_prime = false;\n} else {\n i = 2;\n while (i * i &lt;= number) {\n if (number % i == 0) {\n is_prime = false;\n break;\n }\n i = i + 1;\n }\n}\n\nif (is_prime) {\n show(number, ` is a prime number.`);\n} else {\n show(number, ` is not a prime number.`);\n}\n</code></pre>"},{"location":"tutorial/control-structures/#_11","title":"\u6ce8\u610f\u4e8b\u9879","text":"<ol> <li>\u62ec\u53f7\u4f7f\u7528\uff1a\u6761\u4ef6\u8bed\u53e5\u548c\u5faa\u73af\u8bed\u53e5\u7684\u6761\u4ef6\u5fc5\u987b\u7528\u62ec\u53f7 <code>()</code> \u5305\u56f4</li> <li>\u4ee3\u7801\u5757\uff1a\u4ee3\u7801\u5757\u5fc5\u987b\u7528\u5927\u62ec\u53f7 <code>{}</code> \u5305\u56f4</li> <li>\u7f29\u8fdb\uff1a\u867d\u7136\u7f29\u8fdb\u4e0d\u662f\u5f3a\u5236\u7684\uff0c\u4f46\u826f\u597d\u7684\u7f29\u8fdb\u53ef\u4ee5\u63d0\u9ad8\u4ee3\u7801\u53ef\u8bfb\u6027</li> <li>\u5206\u53f7\uff1a\u8bed\u53e5\u7ed3\u675f\u65f6\u4f7f\u7528\u5206\u53f7 <code>;</code></li> <li>\u6761\u4ef6\u8868\u8fbe\u5f0f\uff1a\u6761\u4ef6\u8868\u8fbe\u5f0f\u5fc5\u987b\u8fd4\u56de\u5e03\u5c14\u503c</li> </ol>"},{"location":"tutorial/control-structures/#_12","title":"\u7ec3\u4e60","text":"<ol> <li>\u7f16\u5199\u4e00\u4e2a\u7a0b\u5e8f\uff0c\u8f93\u5165\u4e00\u4e2a\u5e74\u4efd\uff0c\u5224\u65ad\u662f\u5426\u4e3a\u95f0\u5e74</li> <li>\u7f16\u5199\u4e00\u4e2a\u7a0b\u5e8f\uff0c\u8ba1\u7b97 1 \u5230 100 \u7684\u548c</li> <li>\u7f16\u5199\u4e00\u4e2a\u7a0b\u5e8f\uff0c\u6253\u5370\u4e58\u6cd5\u8868\uff081-9\uff09</li> <li>\u7f16\u5199\u4e00\u4e2a\u7a0b\u5e8f\uff0c\u8f93\u5165\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u5224\u65ad\u662f\u5426\u4e3a\u56de\u6587</li> </ol>"},{"location":"tutorial/control-structures/#_13","title":"\u5c0f\u7ed3","text":"<p>\u672c\u6559\u7a0b\u4ecb\u7ecd\u4e86 Oraset \u7f16\u7a0b\u8bed\u8a00\u7684\u63a7\u5236\u7ed3\u6784\uff0c\u5305\u62ec\uff1a</p> <ul> <li>\u6761\u4ef6\u8bed\u53e5\uff1a<code>if</code>\u3001<code>else if</code>\u3001<code>else</code></li> <li>\u5faa\u73af\u8bed\u53e5\uff1a<code>while</code></li> <li>\u5faa\u73af\u63a7\u5236\uff1a<code>break</code>\u3001<code>continue</code></li> <li>\u7efc\u5408\u793a\u4f8b\uff1a\u731c\u6570\u5b57\u6e38\u620f\u3001\u6590\u6ce2\u90a3\u5951\u6570\u5217\u3001\u7d20\u6570\u5224\u65ad</li> </ul> <p>\u8fd9\u4e9b\u63a7\u5236\u7ed3\u6784\u662f\u7f16\u5199\u590d\u6742\u7a0b\u5e8f\u7684\u57fa\u7840\uff0c\u638c\u63e1\u5b83\u4eec\u540e\uff0c\u4f60\u53ef\u4ee5\u7f16\u5199\u66f4\u7075\u6d3b\u3001\u66f4\u5f3a\u5927\u7684 Oraset \u7a0b\u5e8f\u3002</p>"},{"location":"tutorial/functions-and-classes/","title":"\u51fd\u6570\u548c\u7c7b","text":"<p>\u672c\u6559\u7a0b\u5c06\u8be6\u7ec6\u4ecb\u7ecd Oraset \u7f16\u7a0b\u8bed\u8a00\u7684\u51fd\u6570\u548c\u7c7b\uff0c\u5e2e\u52a9\u4f60\u638c\u63e1\u6a21\u5757\u5316\u7f16\u7a0b\u548c\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\u7684\u57fa\u672c\u6982\u5ff5\u3002</p>"},{"location":"tutorial/functions-and-classes/#_2","title":"\u51fd\u6570","text":""},{"location":"tutorial/functions-and-classes/#_3","title":"\u51fd\u6570\u5b9a\u4e49","text":"<p>\u4f7f\u7528 <code>def</code> \u5173\u952e\u5b57\u5b9a\u4e49\u51fd\u6570\uff1a</p> <pre><code>!! \u51fd\u6570\u5b9a\u4e49\ndef greet(name) {\n show(`Hello, `, name, `!`);\n}\n</code></pre>"},{"location":"tutorial/functions-and-classes/#_4","title":"\u51fd\u6570\u8c03\u7528","text":"<p>\u901a\u8fc7\u51fd\u6570\u540d\u548c\u53c2\u6570\u5217\u8868\u8c03\u7528\u51fd\u6570\uff1a</p> <pre><code>!! \u51fd\u6570\u8c03\u7528\ngreet(`Oraset`); !! \u8f93\u51fa: Hello, Oraset!\n</code></pre>"},{"location":"tutorial/functions-and-classes/#_5","title":"\u53c2\u6570","text":"<p>\u51fd\u6570\u53ef\u4ee5\u63a5\u53d7\u591a\u4e2a\u53c2\u6570\uff1a</p> <pre><code>!! \u591a\u53c2\u6570\u51fd\u6570\ndef add(a, b) {\n return a + b;\n}\n\nresult = add(10, 5);\nshow(`10 + 5 = `, result); !! \u8f93\u51fa: 15\n</code></pre>"},{"location":"tutorial/functions-and-classes/#_6","title":"\u8fd4\u56de\u503c","text":"<p>\u4f7f\u7528 <code>return</code> \u8bed\u53e5\u8fd4\u56de\u51fd\u6570\u7ed3\u679c\uff1a</p> <pre><code>!! \u5e26\u8fd4\u56de\u503c\u7684\u51fd\u6570\ndef multiply(a, b) {\n return a * b;\n}\n\nresult = multiply(10, 5);\nshow(`10 * 5 = `, result); !! \u8f93\u51fa: 50\n</code></pre>"},{"location":"tutorial/functions-and-classes/#_7","title":"\u65e0\u53c2\u6570\u51fd\u6570","text":"<p>\u51fd\u6570\u53ef\u4ee5\u4e0d\u63a5\u53d7\u4efb\u4f55\u53c2\u6570\uff1a</p> <pre><code>!! \u65e0\u53c2\u6570\u51fd\u6570\ndef say_hello() {\n show(`Hello, World!`);\n}\n\nsay_hello(); !! \u8f93\u51fa: Hello, World!\n</code></pre>"},{"location":"tutorial/functions-and-classes/#_8","title":"\u9ed8\u8ba4\u53c2\u6570","text":"<p>\u51fd\u6570\u53ef\u4ee5\u6709\u9ed8\u8ba4\u53c2\u6570\u503c\uff1a</p> <pre><code>!! \u9ed8\u8ba4\u53c2\u6570\ndef greet(name = `World`) {\n show(`Hello, `, name, `!`);\n}\n\ngreet(); !! \u8f93\u51fa: Hello, World!\ngreet(`Oraset`); !! \u8f93\u51fa: Hello, Oraset!\n</code></pre>"},{"location":"tutorial/functions-and-classes/#_9","title":"\u53ef\u53d8\u53c2\u6570","text":"<p>\u51fd\u6570\u53ef\u4ee5\u63a5\u53d7\u53ef\u53d8\u6570\u91cf\u7684\u53c2\u6570\uff1a</p> <pre><code>!! \u53ef\u53d8\u53c2\u6570\ndef sum(...args) {\n total = 0;\n i = 0;\n while (i &lt; args.length) {\n total = total + args[i];\n i = i + 1;\n }\n return total;\n}\n\nresult = sum(1, 2, 3, 4, 5);\nshow(`Sum: `, result); !! \u8f93\u51fa: 15\n</code></pre>"},{"location":"tutorial/functions-and-classes/#_10","title":"\u9012\u5f52\u51fd\u6570","text":"<p>\u51fd\u6570\u53ef\u4ee5\u9012\u5f52\u8c03\u7528\u81ea\u8eab\uff1a</p> <pre><code>!! \u9012\u5f52\u51fd\u6570\ndef factorial(n) {\n if (n &lt;= 1) {\n return 1;\n }\n return n * factorial(n - 1);\n}\n\nresult = factorial(5);\nshow(`5! = `, result); !! \u8f93\u51fa: 120\n</code></pre>"},{"location":"tutorial/functions-and-classes/#_11","title":"\u533f\u540d\u51fd\u6570","text":"<p>Oraset \u652f\u6301\u533f\u540d\u51fd\u6570\uff08\u4e5f\u79f0\u4e3a lambda \u51fd\u6570\uff09\uff1a</p> <pre><code>!! \u533f\u540d\u51fd\u6570\ndouble = lambda x: x * 2;\nshow(`Double of 5: `, double(5)); !! \u8f93\u51fa: 10\n\nadd = lambda a, b: a + b;\nshow(`10 + 5 = `, add(10, 5)); !! \u8f93\u51fa: 15\n</code></pre>"},{"location":"tutorial/functions-and-classes/#_12","title":"\u7c7b","text":""},{"location":"tutorial/functions-and-classes/#_13","title":"\u7c7b\u5b9a\u4e49","text":"<p>\u4f7f\u7528 <code>class</code> \u5173\u952e\u5b57\u5b9a\u4e49\u7c7b\uff1a</p> <pre><code>!! \u7c7b\u5b9a\u4e49\nclass Person {\n name = `Unknown`;\n age = 0;\n\n def __init__(self, name, age) {\n self.name = name;\n self.age = age;\n }\n\n def greet(self) {\n show(`Hello, my name is `, self.name, ` and I am `, self.age, ` years old.`);\n }\n\n def celebrate_birthday(self) {\n self.age = self.age + 1;\n show(`Happy birthday! I am now `, self.age, ` years old.`);\n }\n}\n</code></pre>"},{"location":"tutorial/functions-and-classes/#_14","title":"\u7c7b\u7684\u5b9e\u4f8b\u5316","text":"<p>\u521b\u5efa\u7c7b\u7684\u5b9e\u4f8b\uff1a</p> <pre><code>!! \u7c7b\u7684\u5b9e\u4f8b\u5316\nperson = Person(`John`, 30);\nperson.greet(); !! \u8f93\u51fa: Hello, my name is John and I am 30 years old.\n</code></pre>"},{"location":"tutorial/functions-and-classes/#_15","title":"\u7c7b\u7684\u65b9\u6cd5","text":"<p>\u8c03\u7528\u7c7b\u7684\u65b9\u6cd5\uff1a</p> <pre><code>!! \u8c03\u7528\u7c7b\u7684\u65b9\u6cd5\nperson = Person(`John`, 30);\nperson.greet();\nperson.celebrate_birthday(); !! \u8f93\u51fa: Happy birthday! I am now 31 years old.\nperson.greet(); !! \u8f93\u51fa: Hello, my name is John and I am 31 years old.\n</code></pre>"},{"location":"tutorial/functions-and-classes/#_16","title":"\u7c7b\u7684\u5c5e\u6027","text":"<p>\u8bbf\u95ee\u548c\u4fee\u6539\u7c7b\u7684\u5c5e\u6027\uff1a</p> <pre><code>!! \u8bbf\u95ee\u548c\u4fee\u6539\u7c7b\u7684\u5c5e\u6027\nperson = Person(`John`, 30);\nshow(`Name: `, person.name); !! \u8f93\u51fa: John\nshow(`Age: `, person.age); !! \u8f93\u51fa: 30\n\nperson.name = `Jane`;\nperson.age = 25;\nshow(`Name: `, person.name); !! \u8f93\u51fa: Jane\nshow(`Age: `, person.age); !! \u8f93\u51fa: 25\n</code></pre>"},{"location":"tutorial/functions-and-classes/#_17","title":"\u7ee7\u627f","text":"<p>\u7c7b\u53ef\u4ee5\u7ee7\u627f\u5176\u4ed6\u7c7b\u7684\u5c5e\u6027\u548c\u65b9\u6cd5\uff1a</p> <pre><code>!! \u7ee7\u627f\nclass Student(Person) {\n student_id = ``;\n\n def __init__(self, name, age, student_id) {\n super().__init__(name, age);\n self.student_id = student_id;\n }\n\n def study(self) {\n show(`I am studying. My student ID is `, self.student_id);\n }\n}\n\nstudent = Student(`Alice`, 18, `S12345`);\nstudent.greet(); !! \u8f93\u51fa: Hello, my name is Alice and I am 18 years old.\nstudent.study(); !! \u8f93\u51fa: I am studying. My student ID is S12345\n</code></pre>"},{"location":"tutorial/functions-and-classes/#_18","title":"\u9759\u6001\u65b9\u6cd5","text":"<p>\u7c7b\u53ef\u4ee5\u6709\u9759\u6001\u65b9\u6cd5\uff0c\u4e0d\u9700\u8981\u5b9e\u4f8b\u5316\u5c31\u53ef\u4ee5\u8c03\u7528\uff1a</p> <pre><code>!! \u9759\u6001\u65b9\u6cd5\nclass MathUtils {\n @staticmethod\n def add(a, b) {\n return a + b;\n }\n\n @staticmethod\n def multiply(a, b) {\n return a * b;\n }\n}\n\nresult1 = MathUtils.add(10, 5);\nresult2 = MathUtils.multiply(10, 5);\nshow(`10 + 5 = `, result1); !! \u8f93\u51fa: 15\nshow(`10 * 5 = `, result2); !! \u8f93\u51fa: 50\n</code></pre>"},{"location":"tutorial/functions-and-classes/#_19","title":"\u7efc\u5408\u793a\u4f8b","text":""},{"location":"tutorial/functions-and-classes/#_20","title":"\u8ba1\u7b97\u5668\u7c7b","text":"<pre><code>!! \u8ba1\u7b97\u5668\u7c7b\nclass Calculator {\n def add(self, a, b) {\n return a + b;\n }\n\n def subtract(self, a, b) {\n return a - b;\n }\n\n def multiply(self, a, b) {\n return a * b;\n }\n\n def divide(self, a, b) {\n if (b == 0) {\n show(`Error: Division by zero`);\n return null;\n }\n return a / b;\n }\n\n def power(self, a, b) {\n result = 1;\n i = 0;\n while (i &lt; b) {\n result = result * a;\n i = i + 1;\n }\n return result;\n }\n}\n\n!! \u4f7f\u7528\u8ba1\u7b97\u5668\ncalc = Calculator();\nshow(`2 + 3 = `, calc.add(2, 3));\nshow(`5 - 2 = `, calc.subtract(5, 2));\nshow(`4 * 6 = `, calc.multiply(4, 6));\nshow(`10 / 2 = `, calc.divide(10, 2));\nshow(`2 ^ 3 = `, calc.power(2, 3));\n</code></pre>"},{"location":"tutorial/functions-and-classes/#_21","title":"\u56fe\u4e66\u7ba1\u7406\u7cfb\u7edf","text":"<pre><code>!! \u56fe\u4e66\u7ba1\u7406\u7cfb\u7edf\nclass Book {\n title = ``;\n author = ``;\n isbn = ``;\n available = true;\n\n def __init__(self, title, author, isbn) {\n self.title = title;\n self.author = author;\n self.isbn = isbn;\n }\n\n def borrow(self) {\n if (self.available) {\n self.available = false;\n return true;\n }\n return false;\n }\n\n def return_book(self) {\n self.available = true;\n }\n\n def get_info(self) {\n status = self.available ? `Available` : `Borrowed`;\n return `Title: ` + self.title + `, Author: ` + self.author + `, ISBN: ` + self.isbn + `, Status: ` + status;\n }\n}\n\nclass Library {\n books = arr();\n\n def add_book(self, book) {\n self.books = array.push(self.books, book);\n }\n\n def find_book_by_title(self, title) {\n i = 0;\n while (i &lt; array.length(self.books)) {\n book = self.books[i];\n if (book.title == title) {\n return book;\n }\n i = i + 1;\n }\n return null;\n }\n\n def list_books(self) {\n i = 0;\n while (i &lt; array.length(self.books)) {\n book = self.books[i];\n show(book.get_info());\n i = i + 1;\n }\n }\n}\n\n!! \u4f7f\u7528\u56fe\u4e66\u7ba1\u7406\u7cfb\u7edf\nlibrary = Library();\n\n!! \u6dfb\u52a0\u56fe\u4e66\nlibrary.add_book(Book(`The Great Gatsby`, `F. Scott Fitzgerald`, `978-0743273565`));\nlibrary.add_book(Book(`To Kill a Mockingbird`, `Harper Lee`, `978-0061120084`));\nlibrary.add_book(Book(`1984`, `George Orwell`, `978-0451524935`));\n\n!! \u5217\u51fa\u6240\u6709\u56fe\u4e66\nshow(`All books:`);\nlibrary.list_books();\n\n!! \u501f\u9605\u56fe\u4e66\nbook = library.find_book_by_title(`1984`);\nif (book) {\n if (book.borrow()) {\n show(`Successfully borrowed: `, book.title);\n } else {\n show(`Book not available: `, book.title);\n }\n}\n\n!! \u518d\u6b21\u5217\u51fa\u56fe\u4e66\nshow(`\\nBooks after borrowing:`);\nlibrary.list_books();\n</code></pre>"},{"location":"tutorial/functions-and-classes/#_22","title":"\u6ce8\u610f\u4e8b\u9879","text":"<ol> <li>\u51fd\u6570\u547d\u540d\uff1a\u51fd\u6570\u540d\u5e94\u8be5\u4f7f\u7528\u5c0f\u5199\u5b57\u6bcd\uff0c\u591a\u4e2a\u5355\u8bcd\u4e4b\u95f4\u4f7f\u7528\u4e0b\u5212\u7ebf</li> <li>\u7c7b\u547d\u540d\uff1a\u7c7b\u540d\u5e94\u8be5\u4f7f\u7528\u9a7c\u5cf0\u547d\u540d\u6cd5\uff08\u9996\u5b57\u6bcd\u5927\u5199\uff09</li> <li>\u65b9\u6cd5\u547d\u540d\uff1a\u65b9\u6cd5\u540d\u5e94\u8be5\u4f7f\u7528\u5c0f\u5199\u5b57\u6bcd\uff0c\u591a\u4e2a\u5355\u8bcd\u4e4b\u95f4\u4f7f\u7528\u4e0b\u5212\u7ebf</li> <li>\u53c2\u6570\u4f20\u9012\uff1a\u53c2\u6570\u6309\u503c\u4f20\u9012\uff0c\u5bf9\u4e8e\u6570\u7ec4\u7b49\u590d\u6742\u7c7b\u578b\uff0c\u4f20\u9012\u7684\u662f\u5f15\u7528</li> <li>self \u53c2\u6570\uff1a\u7c7b\u7684\u65b9\u6cd5\u7b2c\u4e00\u4e2a\u53c2\u6570\u5fc5\u987b\u662f <code>self</code>\uff0c\u8868\u793a\u5b9e\u4f8b\u672c\u8eab</li> <li>super()\uff1a\u5728\u7ee7\u627f\u4e2d\uff0c\u4f7f\u7528 <code>super()</code> \u8c03\u7528\u7236\u7c7b\u7684\u65b9\u6cd5</li> </ol>"},{"location":"tutorial/functions-and-classes/#_23","title":"\u7ec3\u4e60","text":"<ol> <li>\u7f16\u5199\u4e00\u4e2a\u51fd\u6570\uff0c\u8ba1\u7b97\u4e24\u4e2a\u6570\u7684\u6700\u5927\u516c\u7ea6\u6570</li> <li>\u7f16\u5199\u4e00\u4e2a\u51fd\u6570\uff0c\u5224\u65ad\u4e00\u4e2a\u5b57\u7b26\u4e32\u662f\u5426\u4e3a\u56de\u6587</li> <li>\u7f16\u5199\u4e00\u4e2a\u7c7b\uff0c\u8868\u793a\u4e00\u4e2a\u94f6\u884c\u8d26\u6237\uff0c\u5305\u542b\u5b58\u6b3e\u3001\u53d6\u6b3e\u548c\u67e5\u8be2\u4f59\u989d\u7684\u65b9\u6cd5</li> <li>\u7f16\u5199\u4e00\u4e2a\u7c7b\uff0c\u8868\u793a\u4e00\u4e2a\u77e9\u5f62\uff0c\u5305\u542b\u8ba1\u7b97\u9762\u79ef\u548c\u5468\u957f\u7684\u65b9\u6cd5</li> </ol>"},{"location":"tutorial/functions-and-classes/#_24","title":"\u5c0f\u7ed3","text":"<p>\u672c\u6559\u7a0b\u4ecb\u7ecd\u4e86 Oraset \u7f16\u7a0b\u8bed\u8a00\u7684\u51fd\u6570\u548c\u7c7b\uff0c\u5305\u62ec\uff1a</p> <ul> <li>\u51fd\u6570\u5b9a\u4e49\u548c\u8c03\u7528</li> <li>\u51fd\u6570\u53c2\u6570\u548c\u8fd4\u56de\u503c</li> <li>\u9012\u5f52\u51fd\u6570\u548c\u533f\u540d\u51fd\u6570</li> <li>\u7c7b\u7684\u5b9a\u4e49\u548c\u5b9e\u4f8b\u5316</li> <li>\u7c7b\u7684\u65b9\u6cd5\u548c\u5c5e\u6027</li> <li>\u7ee7\u627f\u548c\u9759\u6001\u65b9\u6cd5</li> <li>\u7efc\u5408\u793a\u4f8b\uff1a\u8ba1\u7b97\u5668\u7c7b\u548c\u56fe\u4e66\u7ba1\u7406\u7cfb\u7edf</li> </ul> <p>\u638c\u63e1\u8fd9\u4e9b\u6982\u5ff5\u540e\uff0c\u4f60\u53ef\u4ee5\u7f16\u5199\u66f4\u6a21\u5757\u5316\u3001\u66f4\u53ef\u7ef4\u62a4\u7684 Oraset \u7a0b\u5e8f\u3002</p>"},{"location":"tutorial/quickstart/","title":"\u5feb\u901f\u5f00\u59cb","text":"<p>\u672c\u6559\u7a0b\u5c06\u5e2e\u52a9\u4f60\u5feb\u901f\u4e0a\u624b Oraset \u7f16\u7a0b\u8bed\u8a00\uff0c\u5305\u62ec\u5b89\u88c5\u3001\u7f16\u5199\u7b2c\u4e00\u4e2a\u7a0b\u5e8f\u4ee5\u53ca\u57fa\u672c\u7684\u4f7f\u7528\u65b9\u6cd5\u3002</p>"},{"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\u6e90\u7801</li> <li>\u8bbf\u95ee GitHub \u4ed3\u5e93 \u514b\u9686\u6216\u4e0b\u8f7d\u6e90\u7801\u5230\u672c\u5730</li> <li> <p>\u89e3\u538b\u5230\u4efb\u610f\u76ee\u5f55</p> </li> <li> <p>\u7cfb\u7edf\u8981\u6c42</p> </li> <li>Python 3.6 \u6216\u66f4\u9ad8\u7248\u672c</li> <li> <p>\u652f\u6301 Windows \u548c Linux \u64cd\u4f5c\u7cfb\u7edf</p> </li> <li> <p>\u8fd0\u884c Oraset</p> </li> <li>\u8fdb\u5165 Oraset \u76ee\u5f55</li> <li>\u76f4\u63a5\u8fd0\u884c <code>oraset.py</code> \u6587\u4ef6\uff1a <pre><code>python oraset.py\n</code></pre></li> </ol>"},{"location":"tutorial/quickstart/#_3","title":"\u4ece\u4e8c\u8fdb\u5236\u5b89\u88c5","text":"<ol> <li>\u4e0b\u8f7d\u4e8c\u8fdb\u5236\u6587\u4ef6</li> <li>\u8bbf\u95ee Oraset \u5b98\u7f51 \u4e0b\u8f7d\u5bf9\u5e94\u5e73\u53f0\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6</li> <li> <p>Windows \u4e3a <code>.exe</code> \u6587\u4ef6\uff0cLinux \u4e3a\u53ef\u6267\u884c\u6587\u4ef6</p> </li> <li> <p>\u5b89\u88c5</p> </li> <li>\u89e3\u538b\u5230\u4efb\u610f\u76ee\u5f55</li> <li> <p>\u5c06\u53ef\u6267\u884c\u6587\u4ef6\u6240\u5728\u76ee\u5f55\u6dfb\u52a0\u5230\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\uff08\u53ef\u9009\uff09</p> </li> <li> <p>\u8fd0\u884c Oraset</p> </li> <li>\u76f4\u63a5\u8fd0\u884c\u53ef\u6267\u884c\u6587\u4ef6\uff1a <pre><code>oraset\n</code></pre></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":"<p>\u4f7f\u7528\u6e90\u7801\u8fd0\u884c\uff1a</p> <pre><code>python oraset.py hello.oraset\n</code></pre> <p>\u4f7f\u7528\u4e8c\u8fdb\u5236\u6587\u4ef6\u8fd0\u884c\uff1a</p> <pre><code>oraset hello.oraset\n</code></pre>"},{"location":"tutorial/quickstart/#_7","title":"\u67e5\u770b\u8f93\u51fa","text":"<p>\u4f60\u5c06\u770b\u5230\u8f93\u51fa\uff1a</p> <pre><code>Hello, Oraset!\n</code></pre>"},{"location":"tutorial/quickstart/#_8","title":"\u57fa\u672c\u8bed\u6cd5\u793a\u4f8b","text":""},{"location":"tutorial/quickstart/#_9","title":"\u53d8\u91cf\u8d4b\u503c","text":"<pre><code>!! \u53d8\u91cf\u8d4b\u503c\nname = `World`;\nage = 20;\npi = 3.14159;\n\nshow(`Name: `, name);\nshow(`Age: `, age);\nshow(`PI: `, pi);\n</code></pre>"},{"location":"tutorial/quickstart/#_10","title":"\u6570\u5b66\u8868\u8fbe\u5f0f","text":"<pre><code>!! \u6570\u5b66\u8868\u8fbe\u5f0f\na = 10;\nb = 5;\n\nshow(`a + b = `, a + b);\nshow(`a - b = `, a - b);\nshow(`a * b = `, a * b);\nshow(`a / b = `, a / b);\nshow(`a % b = `, a % b);\n</code></pre>"},{"location":"tutorial/quickstart/#_11","title":"\u6761\u4ef6\u8bed\u53e5","text":"<pre><code>!! \u6761\u4ef6\u8bed\u53e5\nage = 18;\n\nif (age &gt;= 18) {\n show(`Adult`);\n} else {\n show(`Minor`);\n}\n</code></pre>"},{"location":"tutorial/quickstart/#_12","title":"\u5faa\u73af\u8bed\u53e5","text":"<pre><code>!! \u5faa\u73af\u8bed\u53e5\ncount = 0;\n\nwhile (count &lt; 5) {\n show(`Count: `, count);\n count = count + 1;\n}\n</code></pre>"},{"location":"tutorial/quickstart/#_13","title":"\u51fd\u6570\u5b9a\u4e49","text":"<pre><code>!! \u51fd\u6570\u5b9a\u4e49\ndef greet(name) {\n show(`Hello, `, name, `!`);\n}\n\ngreet(`Oraset`);\n</code></pre>"},{"location":"tutorial/quickstart/#_14","title":"\u6570\u7ec4\u64cd\u4f5c","text":"<pre><code>!! \u6570\u7ec4\u64cd\u4f5c\nfruits = arr(`apple`, `banana`, `cherry`);\nshow(`Fruits: `, fruits);\nshow(`First fruit: `, fruits[0]);\n</code></pre>"},{"location":"tutorial/quickstart/#_15","title":"\u5e93\u7684\u4f7f\u7528","text":""},{"location":"tutorial/quickstart/#_16","title":"\u5bfc\u5165\u5e93","text":"<pre><code>!! \u5bfc\u5165\u6570\u5b66\u5e93\n@math;\n\n!! \u4f7f\u7528\u6570\u5b66\u51fd\u6570\nshow(`PI: `, math.pi());\nshow(`sin(90): `, math.sin(90));\n</code></pre>"},{"location":"tutorial/quickstart/#_17","title":"\u6253\u5305\u7a0b\u5e8f","text":"<p>\u4f60\u53ef\u4ee5\u5c06 Oraset \u4ee3\u7801\u6253\u5305\u4e3a\u52a0\u5bc6\u7684 <code>.osp</code> \u6587\u4ef6\uff1a</p> <pre><code>python oraset.py pack hello.oraset\n</code></pre> <p>\u8fd9\u5c06\u751f\u6210 <code>hello.osp</code> \u6587\u4ef6\uff0c\u4f60\u53ef\u4ee5\u76f4\u63a5\u8fd0\u884c\u5b83\uff1a</p> <pre><code>python oraset.py -osp hello.osp\n</code></pre>"},{"location":"tutorial/quickstart/#_18","title":"\u5e38\u89c1\u95ee\u9898","text":""},{"location":"tutorial/quickstart/#_19","title":"\u4e3a\u4ec0\u4e48\u6211\u7684\u7a0b\u5e8f\u6ca1\u6709\u8f93\u51fa\uff1f","text":"<ul> <li>\u786e\u4fdd\u4f60\u4f7f\u7528\u4e86 <code>show</code> \u51fd\u6570\u6765\u8f93\u51fa\u5185\u5bb9</li> <li>\u68c0\u67e5\u662f\u5426\u6709\u8bed\u6cd5\u9519\u8bef</li> </ul>"},{"location":"tutorial/quickstart/#_20","title":"\u5982\u4f55\u5904\u7406\u8f93\u5165\uff1f","text":"<ul> <li>Oraset \u652f\u6301 <code>input</code> \u51fd\u6570\u6765\u83b7\u53d6\u7528\u6237\u8f93\u5165\uff1a <pre><code>name = input(`What's your name? `);\nshow(`Hello, `, name, `!`);\n</code></pre></li> </ul>"},{"location":"tutorial/quickstart/#_21","title":"\u5982\u4f55\u8c03\u8bd5\u7a0b\u5e8f\uff1f","text":"<ul> <li>\u4f7f\u7528 <code>show</code> \u51fd\u6570\u6253\u5370\u53d8\u91cf\u503c</li> <li>\u68c0\u67e5\u9519\u8bef\u4fe1\u606f\uff0cOraset \u4f1a\u663e\u793a\u8be6\u7ec6\u7684\u9519\u8bef\u4f4d\u7f6e\u548c\u539f\u56e0</li> </ul>"},{"location":"tutorial/quickstart/#_22","title":"\u4e0b\u4e00\u6b65","text":"<ul> <li>\u57fa\u672c\u8bed\u6cd5\u6559\u7a0b - \u5b66\u4e60 Oraset \u7684\u57fa\u672c\u8bed\u6cd5</li> <li>\u63a7\u5236\u7ed3\u6784\u6559\u7a0b - \u5b66\u4e60\u6761\u4ef6\u8bed\u53e5\u548c\u5faa\u73af</li> <li>\u51fd\u6570\u548c\u7c7b\u6559\u7a0b - \u5b66\u4e60\u51fd\u6570\u548c\u7c7b\u7684\u4f7f\u7528</li> <li>\u5e93\u53c2\u8003 - \u4e86\u89e3 Oraset \u7684\u5185\u7f6e\u5e93</li> </ul>"}]}