Sclipting
Sclipting is a stack-based golf language, inspired by GolfScript, that uses Chinese characters for instructions and Hangul syllables for data (strings and integers). The basic idea is that to minimise the number of characters in a program, the language should provide as many single-character instructions as possible. It was invented by Timwi in 2011.
Sclipting is not considered finished as it can trivially be extended with more and more instructions assigned to new Chinese characters.
Semantics
Execution
Sclipting is stack-based. Most instructions execute by popping a certain number of elements from the stack and pushing a result. Some instructions, however, operate on the top item without popping it. Yet other instructions may shuffle the stack around almost arbitrarily.
At the begining of the program, the input (e.g. STDIN) is placed on the stack as a single string.
At the end of execution, the 併 instruction is executed once, which generates a string from all or part of the stack contents. This string then forms the program’s output.
Byte-array literals
The most common literal in Sclipting is the byte array (also called a buffer). It is encoded in the source as a sequence of Hangeul syllables in the following way:
- Encode three bytes at a time. Three bytes are 24 bits. Take the first 12 bits and add U+AC00 (that’s your first character), then the rest and add U+AC00 (that’s the second character). If the byte array length is divisible by 3, you are done.
- If there is one byte left, encode it in a single character by shifting it left by 4 bits and adding U+AC00.
- If there are two bytes left, generate the first character from the first 12 bits the same way as above, while the second character is U+BC00 plus the remaining 4 bits of the second byte.
Examples:
Example input | Sclipting byte-array literal |
---|---|
00 | 가 U+AC00 |
2A 2F | 꺢및 U+AEA2 U+BC0F |
2A 2F 00 | 꺢묀 U+AEA2 U+BB00 |
“Sclipting” in UTF-8 53 63 6C 69 70 74 69 6E 67 |
넶꽬늗건늖멧 U+B136 U+AF6C U+B297 U+AC74 U+B296 U+BA67 |
“ДЖ” in UTF-16 (Little Endian) 14 04 16 04 |
굀뀖걀 U+AD40 U+B016 U+AC40 |
Number literals
Positive numbers are expressed as a (big-endian) byte array. This allows arbitrary-size integers.
7076 Hangeul syllables can be used to express a negative integer (U+BC00 = −1 to U+D7A3 = −7076). The range overlaps with that used by byte array literals, but there is no ambiguity because byte array literals always start with a character in the range U+AC00-U+BBFF. Thus, if the program contains a U+BC0x with no character in that range preceding it, it encodes a negative number.
If you need a negative number less than −7076, write it as a positive number and then negate it.
Data types
Sclipting knows the following data types:
- Byte array: A sequence of bytes of a certain length.
- String: A sequence of Unicode characters of a certain length.
- Integer: An arbitrary-size signed integer.
- Float: A double-precision (IEEE) floating-point number. Possible values include ±∞ and NaN.
- List: A list of items of a certain length. Each item can be of any of these datatypes, including another list.
- Mark: A special item (generated by 標) that marks a position in the stack (and occupies a stack slot of its own). Currently only 并 and 併 make use of this.
- Function: An anonymous function (lambda) that can be pushed to and popped from the stack and executed.
Conversions
The following describes implicit conversions that are performed by instructions that expect a certain input data type. However, some instructions may override some of the behaviours described here.
Conversion to byte array
Items never convert implicitly to a byte array. Instructions that generate byte arrays specify in their documentation how they generate it.
Conversion to string
- Byte arrays are decoded as UTF-8.
- Integers/floats are rendered into strings by using the invariant culture.
- Lists are converted to strings by converting each element to a string and concatenating them all. If the list contains further lists, this applies recursively.
- Marks and functions convert to the empty string.
Conversion to integer
- Byte arrays are assumed to be in big-endian order and converted to a positive integer as if it were a base-256 number.
- Floats are rounded toward 0. The floats ±∞ and NaN are all converted to 0.
- Strings are parsed as integers (in decimal) using the invariant culture. If the string is not a valid integer, it is converted to 0.
- Lists are converted to integers by converting each element to an integer and then computing the sum. If the list contains further lists, this applies recursively. If any item in the structure is a float, the sum operation is floating-point and the resulting float is then converted to an integer.
- Marks and functions are converted to 0.
Conversion to float
All items that aren’t already floats convert to a float in the same way that they convert to integers, except of course that the result of a list sum is not rounded.
Conversion to list
Items never convert implicitly to a list. Instructions that operate on lists or iterate over them specify in their documentation what they do when the input is not a list.
Many list operations convert any non-list to a string and then operate on that as if it were a list of characters; however, they generally return the result as a string, not a list of characters. This difference is significant: when converting to an integer, the string “47” converts to 47, but the list { “4”, “7” } converts to 4 + 7 = 11.
Booleans
Some instructions treat an item as a boolean. These generally convert them to an integer and then compare against 0. 0 is considered false, everything else true. Note this has the following consequences:
- All floats greater than -1 and less than 1 are considered false, as are NaN and ±∞.
- Almost all strings are false. The only strings that are true are those that encode a valid non-zero integer.
- A list containing items that add up to 0 is also considered false, even if those items are not themselves all false (for example, the list { −1, 1 }).
Instructions
Syntactically, there are four types of instructions:
- Singular instruction: A singular instruction is a lexical unit. The instruction syntactically stands by itself and does not form a structure with other instructions. Every instruction that is not explicitly marked otherwise is a singular instruction.
- Block head instruction: These instructions start a block, which is a nested sequence of instructions that may be executed conditionally or repeatedly. The block must ultimately be terminated by a block-end instruction (終), although there may be multiple blocks separated by a condition-block instruction (況) or an else instruction (不 or 逆).
- Condition-block instruction: The 況 instruction can be used to specify code to execute at the beginning of every iteration of a while loop (generally used to compute a terminating condition). This instruction terminates the condition block and starts the primary block. For example, in the code 套 c 況 p 不 e 終, the c block is executed at the beginning of every iteration; p is the primary block, only executed if c returned true; and e is the else block, only executed if c returned false already in the first iteration.
- Else-block instruction: Most block instructions may have an else block which executes only if the first block was not executed. A block instruction is allowed to have such an else block unless explicitly stated otherwise. The else instruction terminates the primary block and starts the else block, which must be terminated by the block-end instruction (終).
- Block-end instruction: The 終 instruction, which lexically terminates a block.
It is a compile-time error to have a block head instruction or an else instruction without a matching end instruction.
Block structure
Sclipting | Unicode | Engrish | Meaning |
---|---|---|---|
況 | U+6CC1 | condition | Marks the lexical end of a block that computes a terminating condition and the start of the primary block. This can only be used with one of the while loops (套/要/迄/到/滿/充). |
不 | U+4E0D | no | Marks the lexical end of a block and the start of a new block which is executed only if the first block wasn’t. In general, the difference is that 不 pops an item and 逆 doesn’t, but the exact semantics depend on the block’s head instruction. |
逆 | U+9006 | opposite | |
終 | U+7D42 | end | Marks the lexical end of a block. An item may be pushed depending on the block’s head instruction. |
Stack manipulation
Discard instructions
Sclipting | Unicode | Engrish | Stack transition | Meaning |
---|---|---|---|---|
丟 | U+4E1F | discard | (X) → () | Pops an item. |
棄 | U+68C4 | abandon | (X, X) → () | Pops two items. |
Additional stack manipulation instructions
Sclipting | Unicodes | Meaning |
---|---|---|
① ... ⑳, ㉑ ... ㉟, ㊱ ... ㊿ |
U+2460 .. U+2473, U+3251 .. U+325F, U+32B1 .. U+32BF |
Pushes a copy of the item at the specified location from the bottom of the stack (1-based counting). |
❶ ... ❿, ⓫ ... ⓴ |
U+2776 .. U+277F, U+24EB .. U+24F4 |
Pushes a copy of the item at the specified location from the top of the stack (1-based counting). |
⑴ ... ⒇ | U+2474 .. U+2487 | Moves the item at the specified location from the bottom of the stack (1-based counting) to the top. |
⓵ ... ⓾ | U+24F5 .. U+24FE | Moves the item at the specified location from the top of the stack (1-based counting) to the top. Note this implies ⓵ is a no-op. |
⒈ ... ⒛ | U+2488 .. U+249B | Swaps the item at the specified location from the bottom of the stack with the top item. |
Loops and conditionals
The instructions listed in this table are all block instructions which cause their associated block to be executed conditionally or repeatedly. Block instructions in this list may optionally have either type of else block unless explicitly stated otherwise.
Where these descriptions describe an item as true or false, they refer to the boolean value of an item as described in the section “Conversions”. An item is empty if it is either the empty list, or it is not a list and converts to the empty string. This means the mark (標) is empty, but integers and floats are not.
Sclipting | Unicode | Engrish | Stack transition | Meaning |
---|---|---|---|---|
是 | U+662F | yes | (X) → () | If: Executes the block only if the top item is true (是/倘), false (沒/毋) or non-empty (夠/含). 是/沒/夠 pop the item while 倘/毋/含 do not. If the item is false/true/empty and there is an else block, the else instruction overrides the popping behaviour. |
倘 | U+5018 | if | (X) → (X) | |
沒 | U+6C92 | not | (X) → () | |
毋 | U+6BCB | not | (X) → (X) | |
夠 | U+5920 | enough | (X) → () | |
含 | U+542B | contain | (X) → (X) | |
套 | U+5957 | loop | (X) → () | While loop: Repeatedly, 1. if there is a condition block (況), it is executed; 2. the top item is popped (套/迄/滿) or merely examined (要/到/充); 3. the primary block is executed if the item is true (套/要)/false (迄/到)/non-empty (滿/充). This is repeated until the item is false (套/要)/true (迄/到)/empty (滿/充). If the first item examined is already false (套/要)/true (迄/到)/empty (滿/充), and there is an else block, the else block is executed and its instruction overrides the popping behaviour. |
要 | U+8981 | necessity | (X) → (X) | |
迄 | U+8FC4 | until | (X) → () | |
到 | U+5230 | arrive | (X) → (X) | |
滿 | U+6EFF | full | (X) → () | |
充 | U+5145 | be full | (X) → (X) | |
上 | U+4E0A | up | (I, I) → (I) | For loop: Pops two integers start and end and iterates over the integers in that range. The integer start is pushed and the block executed. Then start + 1 (上) or start − 1 (下) is pushed and the block executed again, etc. The block is executed a total of end − start + 1 (上)/start − end + 1 (下) times. There may be a 不 block that is executed if end < start (上)/end > start (下). A 逆 block is not allowed. |
下 | U+4E0B | down | (I, I) → (I) | |
各 | U+5404 | each | (X) → (X) | For-each loop: Iterates over the items in a list, the characters in a string, or the bytes in a byte array. 各 pops the item while 每 does not. Each item is pushed and the block executed. If the list is empty and there is an else block, the else instruction overrides the popping behaviour. (If the top item is a byte array containing UTF-8 text and you wish to iterate over the characters, you will have to convert it to a string first, e.g. by using 併.) |
每 | U+6BCF | every | (X) → (X, X) |
Arithmetic
These instructions generally take integers or floats as arguments. When they encounter any other datatype, they will convert items to floats or integers as described in the section “Conversions”. In the following descriptions, “number” (and N in the stack transition) means “integer or float”. If the description and stack transition mention only “integer”, floats are accepted but are rounded toward zero.
Divisions by zero (including modulo zero) return NaN.
Sclipting | Unicode | Engrish | Stack transition | Meaning |
---|---|---|---|---|
加 | U+52A0 | add | (N, N) → (N) | Addition: Pops a and b and pushes a + b. |
減 | U+6E1B | subtract | (N, N) → (N) | Subtraction: Pops a and b and pushes a − b. |
縮 | U+7E2E | reduce | (N, N) → (N) | Subtraction: Pops a and b and pushes b − a. |
乘 | U+4E58 | multiply | (N, N) → (N) | Multiplication: Pops a and b and pushes a × b. |
除 | U+9664 | divide | (N, N) → (N) | Float division: Pops a and b and pushes a ÷ b as a float, even if both operands are integers. |
分 | U+5206 | divide | (I, I) → (I) | Integer division: Pops integers a and b and pushes a ÷ b as an integer that is rounded toward 0. |
剩 | U+5269 | leftovers | (I, I) → (I) | Modulo: Pops a and b and pushes the remainder. The result is always between 0 and b − 1, even if a is negative. |
重 | U+91CD | double | (N) → (N) | Double: Pops a and pushes a × 2. |
半 | U+534A | half | (N) → (N) | Half: Pops a and pushes a ÷ 2 as a float (半) or as an integer rounded toward 0 (隔). |
隔 | U+9694 | separate | (I) → (I) | |
方 | U+65B9 | power | (N, N) → (N) | Exponentiation: Pops a and b and pushes ab. If a is an integer and b is a non-negative integer, the result is an integer, otherwise a float. |
平 | U+5E73 | flat | (N) → (N) | Square: Pops a and pushes a². |
根 | U+6839 | root | (N) → (N) | Square root: Pops a and pushes √a. |
圜 | U+571C | circle | (F) → (I) | Round: Rounds a number towards 0. |
圍 | U+570D | circle | (F) → (I) | Round: Rounds a number away from 0. |
團 | U+5718 | sphere | (F) → (I) | Round: Rounds a number down. |
圓 | U+5713 | surround | (F) → (I) | Round: Rounds a number up. |
繞 | U+7E5E | surround | (F) → (I) | Round: Rounds a number to the nearest integer (halves are rounded away from zero). |
輪 | U+8F2A | wheel | (F) → (I) | Round: Rounds a number to the nearest integer (halves are rounded to even). |
負 | U+8CA0 | negative | (N) → (N) | Negative: Pops a and pushes −a. |
對 | U+5C0D | correct | (N) → (N) | Absolute value: Pops a and pushes |a|. |
增 | U+589E | increase | (I) → (I) | Increment: Pops integer a and pushes a + 1. (Note this rounds floats toward 0 before the increment.) |
貶 | U+8CB6 | decrease | (I) → (I) | Decrement: Pops integer a and pushes a − 1. (Note this rounds floats toward 0 before the decrement.) |
數 | U+6578 | number | (F) → (F) | Logarithm: Calculates the log to base e. |
位 | U+4F4D | position | (F) → (F) | Logarithm: Calculates the log to base 10. |
級 | U+7D1A | level | (F) → (F) | Logarithm: Calculates the log to base 2. |
左 | U+5DE6 | left | (I, I) → (I) | Shift left: Pops a and b and pushes a << b. b can be negative in which case a is shifted to the right instead. |
右 | U+53F3 | right | (I, I) → (I) | Shift right: Pops a and b and pushes a >> b. b can be negative in which case a is shifted to the left instead. |
雙 | U+96D9 | both | (I, I) → (I) | Bitwise and: Pops a and b and pushes a & b. |
另 | U+53E6 | other | (I, I) → (I) | Bitwise or: Pops a and b and pushes a | b. |
倆 | U+5006 | clever | (I, I) → (I) | Bitwise xor: Pops a and b and pushes a ^ b. |
無 | U+7121 | not | (I) → (I) | Bitwise not: Pops a and pushes ~a. |
啃 | U+5543 | gnaw | (I, I) → (I, I) | Bit split: Pops a and b. Let c = a & ~(−1 << b) (the bottom b bits of a) and d = a >> b (the rest of the number). 啃 pushes c then d; 嚙 pushes d then c. |
嚙 | U+5699 | bite | (I, I) → (I, I) | |
沌 | U+6C8C | chaotic | () → (I) | Random integer: Pushes a random integer between 0 (inclusive) and 2³² (exclusive). |
紛 | U+7D1B | disarray | (I) → (I) | Random integer: Pushes a random integer between 0 (inclusive) and the specified maximum (exclusive). |
胡 | U+80E1 | wild | (I, I) → (I) | Random integer: Pushes a random integer between the specified minimum (inclusive) and maximum (exclusive). |
亂 | U+4E82 | chaos | () → (F) | Random float: Pushes a random float between 0 (inclusive) and 1 (exclusive). |
野 | U+91CE | wild | (F) → (F) | Random float: Pushes a random float between 0 (inclusive) and the specified maximum (exclusive). |
猖 | U+7316 | wild | (F, F) → (F) | Random float: Pushes a random float between the specified minimum (inclusive) and maximum (exclusive). |
Logic
These instructions generally deal with boolean logic. Descriptions that refer to true or false refer to the boolean value of an item as described in “Conversions”.
Sclipting | Unicode | Engrish | Stack transition | Meaning |
---|---|---|---|---|
小 | U+5C0F | small | (N, N) → (I) | Less than: Pops a and b and pushes 1 if a < b, otherwise 0. |
大 | U+5927 | great | (N, N) → (I) | Greater than: Pops a and b and pushes 1 if a > b, otherwise 0. |
少 | U+5C11 | less | (N, N) → (I) | Less than or equal to: Pops a and b and pushes 1 if a ≤ b, otherwise 0. |
瀰 | U+7030 | overflow | (N, N) → (I) | Greater than or equal to: Pops a and b and pushes 1 if a ≥ b, otherwise 0. |
同 | U+540C | same | (X, X) → (I) | Equality: Pops two items and pushes 1 (同)/0 (差) if they are exactly the same thing (integer 0, float 0, character ‘0’ and byte array 0x00 are considered different), otherwise 0 (同)/1 (差). |
差 | U+5DEE | different | (X, X) → (I) | |
侔 | U+4F94 | equal | (I, I) → (I) | Integer equality: Pops two items and pushes 1 (侔)/0 (异) if they convert to the same integer, otherwise pushes 0 (侔)/1 (异). |
异 | U+5F02 | different | (I, I) → (I) | |
肖 | U+8096 | resemble | (S, S) → (I) | String equality: Pops two items and pushes 1 (肖)/0 (殊) if they convert to the same string, otherwise pushes 0 (肖)/1 (殊). |
殊 | U+6B8A | different | (S, S) → (I) | |
與 | U+8207 | and | (I, I) → (I) | Logical and: Pops a and b and pushes 1 if both are non-zero, otherwise 0. |
或 | U+6216 | or | (I, I) → (I) | Logical or: Pops a and b and pushes 1 if either or both are non-zero, otherwise 0. |
隻 | U+96BB | one of pair | (I, I) → (I) | Logical xor: Pops a and b and pushes 1 if one is non-zero (but not both), otherwise 0. |
非 | U+975E | not | (I) → (I) | Logical not: Pops a and pushes 1 if a is 0, otherwise 0. |
嗎 | U+55CE | is it? | (I, X, X) → (X) | Conditional operator: Pops q, y and n and pushes y if q is non-zero, otherwise pushes n. |
Lambda function instructions
Instructions marked with a “█” are block head instructions; all others are singular instructions.
Block | Sclipting | Unicode | Engrish | Stack transition | Meaning |
---|---|---|---|---|---|
█ | 塊 | U+584A | block | () → (F) | Introduces an anonymous function (lambda expression) consisting of the instructions within the block. The function is pushed onto the stack and not executed. 掳 additionally pops an item and stores it with the function; a copy of that item is pushed every time the function starts to execute. |
█ | 掳 | U+63B3 | capture | (X) → (F) | |
開 | U+958B | initiate | (F) → () | Pops an item. If the item popped is a function, it is executed. | |
辦 | U+8FA6 | handle | (F) → (F) | Pops an item, executes it if it is a function, and then pushes it back. | |
演 | U+6F14 | perform | (F) → (F) | If the top item on the stack is a function, executes it without popping it. Note this means that the function will “see” itself on the stack. |
Lists and strings
These instructions all operate on a list or a string. Anything that is not a list or string is converted to a string as described in the section “Conversions”.
Instructions to operate on a specific index
The following instructions all operate on a specific item in a list or character in a string, identified by an index counting either forward from the start or backward from the end of the list/string. The semantics of each instruction are the same as those listed under “see also” at the end of the table except that those take an index from the stack.
Element | Retrieve (pop)
|
Retrieve (no pop)
|
Insert
|
Delete
|
Retrieve + delete
|
Replace
|
Exchange
|
---|---|---|---|---|---|---|---|
first | 一 U+4E00 one
|
壹 U+58F9 one
|
氫 U+6C2B hydrogen
|
鈧 U+9227 scandium
|
鈮 U+922E niobium
|
鉕 U+9255 promethium
|
鉈 U+9248 thallium
|
2nd | 二 U+4E8C two
|
貳 U+8CB3 two
|
氦 U+6C26 helium
|
鈦 U+9226 titanium
|
鉬 U+926C molybdenum
|
釤 U+91E4 samarium
|
鉛 U+925B lead
|
3rd | 三 U+4E09 three
|
叁 U+53C1 three
|
鋰 U+92F0 lithium
|
釩 U+91E9 vanadium
|
鎝 U+939D technetium
|
銪 U+92AA europium
|
鉍 U+924D bismuth
|
4th | 四 U+56DB four
|
肆 U+8086 four
|
鈹 U+9239 beryllium
|
鉻 U+927B chromium
|
釕 U+91D5 ruthenium
|
釓 U+91D3 gadolinium
|
釙 U+91D9 polonium
|
5th | 五 U+4E94 five
|
伍 U+4F0D five
|
硼 U+787C boron
|
錳 U+9333 manganese
|
銠 U+92A0 rhodium
|
鋱 U+92F1 terbium
|
砈 U+7808 astatine
|
6th | 六 U+516D six
|
陸 U+9678 six
|
碳 U+78B3 carbon
|
鐵 U+9435 iron
|
鈀 U+9200 palladium
|
鏑 U+93D1 dysprosium
|
氡 U+6C21 radon
|
7th | 七 U+4E03 seven
|
柒 U+67D2 seven
|
氮 U+6C2E nitrogen
|
鈷 U+9237 cobalt
|
銀 U+9280 silver
|
鈥 U+9225 holmium
|
鍅 U+9345 francium
|
8th | 八 U+516B eight
|
捌 U+634C eight
|
氧 U+6C27 oxygen
|
鎳 U+93B3 nickel
|
鎘 U+9398 cadmium
|
鉺 U+927A erbium
|
鐳 U+9433 radium
|
9th | 九 U+4E5D nine
|
玖 U+7396 nine
|
氟 U+6C1F fluorine
|
銅 U+9285 copper
|
銦 U+92A6 indium
|
銩 U+92A9 thulium
|
錒 U+9312 actinium
|
10th | 十 U+5341 ten
|
拾 U+62FE ten
|
氖 U+6C16 neon
|
鋅 U+92C5 zinc
|
錫 U+932B tin
|
鐿 U+943F ytterbium
|
釷 U+91F7 thorium
|
last | 乾 U+4E7E sky
|
首 U+9996 head
|
鈉 U+9209 sodium
|
鎵 U+93B5 gallium
|
銻 U+92BB antimony
|
鎦 U+93A6 lutetium
|
鏷 U+93F7 protactinium
|
2nd-last | 兌 U+514C lake
|
跟 U+8DDF follow
|
鎂 U+9382 magnesium
|
鍺 U+937A germanium
|
碲 U+78B2 tellurium
|
鉿 U+927F hafnium
|
鈾 U+923E uranium
|
3rd-last | 離 U+96E2 fire
|
副 U+526F supplement
|
鋁 U+92C1 aluminium
|
砷 U+7837 arsenic
|
碘 U+7898 iodine
|
鉭 U+926D tantalum
|
錼 U+933C neptunium
|
4th-last | 震 U+9707 thunder
|
矩 U+77E9 square
|
矽 U+77FD silicon
|
硒 U+7852 selenium
|
氙 U+6C19 xenon
|
鎢 U+93A2 tungsten
|
鈽 U+923D plutonium
|
5th-last | 巽 U+5DFD wind
|
手 U+624B hand
|
磷 U+78F7 phosphorus
|
溴 U+6EB4 bromine
|
銫 U+92AB caesium
|
錸 U+9338 rhenium
|
鋂 U+92C2 americium
|
6th-last | 坎 U+574E water
|
蟜 U+87DC insect
|
硫 U+786B sulfur
|
氪 U+6C2A krypton
|
鋇 U+92C7 barium
|
鋨 U+92E8 osmium
|
鋦 U+92E6 curium
|
7th-last | 艮 U+826E mountain
|
週 U+9031 week
|
氯 U+6C2F chlorine
|
銣 U+92A3 rubidium
|
鑭 U+946D lanthanum
|
銥 U+92A5 iridium
|
鉳 U+9273 berkelium
|
8th-last | 坤 U+5764 earth
|
蛛 U+86DB spider
|
氬 U+6C2C argon
|
鍶 U+9376 strontium
|
鈰 U+9230 cerium
|
鉑 U+9251 platinum
|
鉲 U+9272 californium
|
9th-last | 陰 U+9670 yin
|
貓 U+8C93 cat
|
鉀 U+9240 potassium
|
釔 U+91D4 yttrium
|
鐠 U+9420 praseodymium
|
金 U+91D1 gold
|
鑀 U+9440 einsteinium
|
10th-last | 陽 U+967D yang
|
指 U+6307 finger
|
鈣 U+9223 calcium
|
鋯 U+92EF zirconium
|
釹 U+91F9 neodymium
|
汞 U+6C5E mercury
|
鐨 U+9428 fermium
|
see also | 掘 U+6398 excavate 掊 U+638A dig
|
挖 U+6316 dig out 采 U+91C7 collect
|
栽 U+683D cultivate 種 U+7A2E seed
|
殲 U+6BB2 annihilate 摧 U+6467 destroy
|
裒 U+88D2 take out 抽 U+62BD pull out
|
插 U+63D2 insert 恢 U+6062 restore
|
混 U+6DF7 mix 拌 U+62CC mix
|
Other list/string manipulation instructions
Instructions in this table marked with a “█” are block head instructions; all others are singular instructions.
Block | Sclipting | Unicode | Engrish | Stack transition | Meaning |
---|---|---|---|---|---|
掘 | U+6398 | excavate | (X, I) → (X) | Pushes the ith (掘/挖) or ith-last (掊/采) item/character within a list/string (starts at zero), or the empty string if i is out of range. 掘/掊 pop the list/string, 挖/采 do not. | |
掊 | U+638A | dig | (X, I) → (X) | ||
挖 | U+6316 | dig out | (X, I) → (X, X) | ||
采 | U+91C7 | collect | (X, I) → (X, X) | ||
栽 | U+683D | cultivate | (X, I, X) → (X) | Inserts an item/character into a list/string at a specified forward (栽) or backward (種) index, shifting later items/characters to the right (padding as necessary). | |
種 | U+7A2E | seed | (X, I, X) → (X) | ||
殲 | U+6BB2 | annihilate | (X, I) → (X) | Deletes the ith (殲) or ith-last (摧) item/character within a list/string. If i is negative or out of range, nothing happens. | |
摧 | U+6467 | destroy | (X, I) → (X) | ||
裒 | U+88D2 | take out | (X, I) → (X, X) | Pushes the ith (裒) or ith-last (抽) item/character within a list/string (starts at zero), or the empty string if i is out of range, and then removes that item/character from the list/string. | |
抽 | U+62BD | pull out | (X, I) → (X, X) | ||
插 | U+63D2 | insert | (X, I, X) → (X) | Replaces the ith (插) or ith-last (恢) item/character within a list/string with a new item (padding as necessary). | |
恢 | U+6062 | restore | (X, I, X) → (X) | ||
混 | U+6DF7 | mix | (X, I, X) → (X, X) | Exchanges the ith (混) or ith-last (拌) item/character within a list/string with an item on the stack (padding as necessary). | |
拌 | U+62CC | mix | (X, I, X) → (X, X) | ||
匱 | U+5331 | lack | () → (L) | Pushes the empty list. | |
虛 | U+865B | empty | () → (S) | Pushes the empty string. | |
長 | U+9577 | length | (X) → (I) | Pushes the number of items/characters in a list/string. 長 pops the list/string, 梴 does not. | |
梴 | U+68B4 | long | (X) → (X, I) | ||
疊 | U+758A | repeat | (X, I) → (L) | Pushes a list containing i repetitions of the item x. | |
張 | U+5F35 | stretch | (I, X) → (L) | ||
復 | U+5FA9 | repeat | (X, I) → (X) | Pops a list/string/byte array x and an integer i and pushes a new list/string/byte array containing i concatenated repetitions of x. | |
伸 | U+4F38 | extend | (I, X) → (X) | ||
標 | U+6A19 | mark | () → (M) | Pushes a mark (used by 并 and 併). | |
并 | U+5E76 | combine | (M, ...) → (L) | Pops all items from the topmost mark to the top of the stack and pushes a list containing those items (并) or converts them to strings and pushes the result as a single concatenated string (併). | |
併 | U+4F75 | combine | (M, ...) → (S) | ||
合 | U+5408 | combine | (X, X) → (X) | Concatenates two lists or two strings. If either item is not a list, converts both to a string before concatenating. 合 concatenates in stack order, 融 in the reverse order. | |
融 | U+878D | blend | (X, X) → (X) | ||
子 | U+5B50 | child | (X, I, I) → (X) | Substring/sublist: Returns the substring/list of the specified index and count. 子 pops the input, 部 does not. | |
部 | U+90E8 | part | (X, I, I) → (X, X) | ||
昉 | U+6609 | start | (X, I) → (X) | Left substring/sublist: Returns the first n (昉/俶) or length − n (始/初) characters/items. 昉/始 pop the input, 俶/初 do not. | |
俶 | U+4FF6 | start | (X, I) → (X, X) | ||
始 | U+59CB | begin | (X, I) → (X) | ||
初 | U+521D | beginning | (X, I) → (X, X) | ||
末 | U+672B | final | (X, I) → (X) | Right substring/sublist: Returns the last n (末/尾) or length − n (端/止) characters/items. 末/端 pop the input, 尾/止 do not. | |
尾 | U+5C3E | tail | (X, I) → (X, X) | ||
端 | U+7AEF | end | (X, I) → (X) | ||
止 | U+6B62 | stop | (X, I) → (X, X) | ||
反 | U+53CD | reverse | (X) → (X) | Reverses a list or string. | |
捃 | U+6343 | sort | (X) → (X) | Sorts the items in a list (by converting each item to a string for the purpose of the comparison) or the characters in a string (according to the invariant culture). | |
訂 | U+8A02 | arrange | (X) → (X) | Sorts the items in a list (by converting each item to an integer for the purpose of the comparison) or the characters in a string (by their Unicode codepoint value). | |
█ | 折 | U+6298 | snap | (X) → (X, X) | Take-until/skip-until: Splits a list or string into two as follows. Iterates over the items in a list or the characters in a string in forward (折/破) or backward (擘/断) order. Each item is pushed and the block executed; at the end of each iteration, an item is popped. If that item is true, the iteration is halted. At the end, two lists/strings are pushed: the original list or string, split at the position where the block returned true. 折/擘 pop the original list/string; 破/断 do not. If the list/string is empty and an else block exists, no results are pushed and the else instruction overrides the popping behaviour; however, if no else block exists, two empty lists/strings are pushed. |
█ | 破 | U+7834 | rupture | (X) → (X, X, X) | |
█ | 擘 | U+64D8 | break | (X) → (X, X) | |
█ | 断 | U+65AD | sever | (X) → (X, X, X) | |
會 | U+6703 | assemble | (X) → (X) | Join: Concatenate all the strings in a list into a single string while interspersing them with the specified separator. If the input is not a list, it is converted to a string and the separator interspersed between every character. | |
癲 | U+7672 | mad | (I, X) → (X) | Pushes a random list or string of the specified length by picking items/characters from the specified list/string. | |
癡 | U+7661 | silly | (X, I) → (X) | ||
繓 | U+7E53 | shuffle | (X) → (X) | Randomly shuffles the items in a list or the characters in a string. |
String manipulation only (no lists)
Sclipting has built-in support for regular expressions. All regular expression instructions in Sclipting default to the behaviour normally referred to as “single-line mode” (Perl modifier s), which means that the . operator matches any character. The behaviour can be altered within a regular expression by using the (?-s:...) construct to disable “single-line mode” (so . matches anything but newlines). The same construct can be used to enable “multi-line mode” (m; alters the meanings of ^ and $ to match the beginning/end of a line within the string instead of the beginning/end of the whole string), “ignore case” (i) and “ignore whitespace” (x).
Instructions in this list marked with a “█” are block head instructions. Instructions marked with a “ʘ” can only be used within the main block of one of those block instructions. If several blocks are nested, the “ʘ” instructions apply only to the innermost block.
Block | Sclipting | Unicode | Engrish | Stack transition | Meaning |
---|---|---|---|---|---|
講 | U+8B1B | explain | (S) → (I) | Converts a character to its Unicode codepoint. If the item popped is not a character, it is converted to a string and its first character used. If the string is empty, NaN is pushed. | |
字 | U+5B57 | character | (I) → (S) | Converts a Unicode codepoint to its character. Note the result may be two characters because of UTF-16 encoding. If the codepoint is out of range, the empty string is pushed. | |
移 | U+79FB | change | (S, S, S) → (S) | Pops h, n, r. Replaces all occurrences of n within h with r. 變 is case-sensitive, 改 is case-insensitive, and 移 takes n to be a regular expression. | |
變 | U+8B8A | change | (S, S, S) → (S) | ||
改 | U+6539 | change | (S, S, S) → (S) | ||
█ | 換 | U+63DB | substitute | (S, S) → (S) | Finds matches of a regular expression (換/代/替/更), a case-sensitive substring (取/挐/拿/拏) or a case-insensitive substring (用/喫/買/進) (top item) in a string (item below) and executes the block for the first match (換/代/取/挐/用/喫) or all matches (替/更/拿/拏/買/進) found. At the end of each iteration, the last item is popped and used as the replacement string for this match. After the last iteration, the string resulting from all those replacements is pushed. — The regular expression or substring is always popped. 換/替/取/拿/用/買 pop the input string as well, 代/更/挐/拏/喫/進 do not. If there is no match and there is an else block, the else block is executed. If it is a 不 block, the input string is popped, but is pushed back again at the end of the block. If it is a 逆 block, the input string is left alone and not popped or pushed. |
█ | 代 | U+4EE3 | replace | (S, S) → (S, S) | |
█ | 替 | U+66FF | replace | (S, S) → (S) | |
█ | 更 | U+66F4 | replace | (S, S) → (S, S) | |
█ | 取 | U+53D6 | take | (S, S) → (S) | |
█ | 挐 | U+6310 | hold | (S, S) → (S, S) | |
█ | 拿 | U+62FF | take | (S, S) → (S) | |
█ | 拏 | U+62CF | hold | (S, S) → (S, S) | |
█ | 用 | U+7528 | use | (S, S) → (S) | |
█ | 喫 | U+55AB | eat | (S, S) → (S, S) | |
█ | 買 | U+8CB7 | buy | (S, S) → (S) | |
█ | 進 | U+9032 | advance | (S, S) → (S, S) | |
ʘ | 現 | U+73FE | appear | () → (S) | Pushes the current match. |
坼 | U+577C | split | (S, S) → (L) | Splits a string at every match of a regular expression and pushes the result as a list of strings. If the regular expression includes capturing parentheses, their matches are included in the list as well. The regular expression is always popped; 坼 pops the input string as well, 裂 does not. | |
裂 | U+88C2 | split | (S, S) → (S, L) | ||
壯 | U+58EF | big | (S) → (S) | Converts a string to upper-case (壯), lower-case (微) or title-case (題). If the item is a list, this operation is applied recursively to every element in the list. | |
微 | U+5FAE | tiny | (S) → (S) | ||
題 | U+984C | title | (S) → (S) | ||
瘋 | U+760B | crazy | (I) → (S) | Pushes a random string of the specified length. Characters are picked from the set a-z, A-Z (瘋) or a-z, A-Z, 0-9 (狂). | |
狂 | U+72C2 | insane | (I) → (S) |
Regular expression capturing group instructions
Block | Sclipting | Unicodes | Meaning |
---|---|---|---|
ʘ | Ⓐ .. Ⓩ | U+24B6 .. U+24CF | Pushes the part of the current match corresponding to the specified capturing group within the regular expression. |
Examples
Hello, World!
丟낆녬닆묬긅덯댦롤긐
99 bottles of beer on the wall
丟눰標下標❷❶냦및嗎긆깯덇끬뉐❷貶是댰終긆뭦긆깥뉗긠닶먠덆둥긇덡닆렬겠 併標❸❶냦및嗎긆깯덇끬뉐❷貶是댰終긆뭦긆깥뉗긮겠併❸녆굫뉒걯닦넠뉆뭷닢렠댆굳댲걩덂걡댦뭵닦뀬겠 ⓵끶묠덆묠덆둥긇꽴닷깥껂걢덗딠댶뭭뉒걭닷깥껀밊嗎⓸倘貶不꾓밉終倘긆깯덇끬뉐 ❷貶是댰終不냦묠눦뭴덆롥댰終긆뭦긆깥뉗긠닶먠덆둥긇덡닆렮겠밊終
Interpreter
- Sclipting is implemented in Esoteric IDE.