Sclipting

From Esolang
Jump to navigation Jump to search

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 endstart + 1 (上)/startend + 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 ab.
U+7E2E reduce (N, N) → (N) Subtraction: Pops a and b and pushes ba.
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 ab, otherwise 0.
U+7030 overflow (N, N) → (I) Greater than or equal to: Pops a and b and pushes 1 if ab, 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 lengthn (始/初) 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 lengthn (端/止) 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