Skip to main content

Tuple, List, and Null primitives

TVM Instructions Content List

OpcodeFift syntaxStackDescriptionGas
Please enter a search query
No results found

Tuple, List, and Null primitives

xxxxxxx
Opcode
xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Fift syntax
xxxxxxxxxxxxxxxxx
Stack
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Description
xxxx
Gas
6DNULL
PUSHNULL
- nullPushes the only value of type Null.18
6EISNULLx - ?Checks whether x is a Null, and returns -1 or 0 accordingly.18
6F0n[n] TUPLEx_1 ... x_n - tCreates a new Tuple t=(x_1, … ,x_n) containing n values x_1,..., x_n.
0 <= n <= 15
26+n
6F00NIL- tPushes the only Tuple t=() of length zero.26
6F01SINGLEx - tCreates a singleton t:=(x), i.e., a Tuple of length one.27
6F02PAIR
CONS
x y - tCreates pair t:=(x,y).28
6F03TRIPLEx y z - tCreates triple t:=(x,y,z).29
6F1k[k] INDEXt - xReturns the k-th element of a Tuple t.
0 <= k <= 15.
26
6F10FIRST
CAR
t - xReturns the first element of a Tuple.26
6F11SECOND
CDR
t - yReturns the second element of a Tuple.26
6F12THIRDt - zReturns the third element of a Tuple.26
6F2n[n] UNTUPLEt - x_1 ... x_nUnpacks a Tuple t=(x_1,...,x_n) of length equal to 0 <= n <= 15.
If t is not a Tuple, or if \|t\| != n, a type check exception is thrown.
26+n
6F21UNSINGLEt - xUnpacks a singleton t=(x).27
6F22UNPAIR
UNCONS
t - x yUnpacks a pair t=(x,y).28
6F23UNTRIPLEt - x y zUnpacks a triple t=(x,y,z).29
6F3k[k] UNPACKFIRSTt - x_1 ... x_kUnpacks first 0 <= k <= 15 elements of a Tuple t.
If \|t\|<k, throws a type check exception.
26+k
6F30CHKTUPLEt -Checks whether t is a Tuple. If not, throws a type check exception.26
6F4n[n] EXPLODEt - x_1 ... x_m mUnpacks a Tuple t=(x_1,...,x_m) and returns its length m, but only if m <= n <= 15. Otherwise throws a type check exception.26+m
6F5k[k] SETINDEXt x - t'Computes Tuple t' that differs from t only at position t'_{k+1}, which is set to x.
0 <= k <= 15
If k >= \|t\|, throws a range check exception.
26+\|t\|
6F50SETFIRSTt x - t'Sets the first component of Tuple t to x and returns the resulting Tuple t'.26+\|t\|
6F51SETSECONDt x - t'Sets the second component of Tuple t to x and returns the resulting Tuple t'.26+\|t\|
6F52SETTHIRDt x - t'Sets the third component of Tuple t to x and returns the resulting Tuple t'.26+\|t\|
6F6k[k] INDEXQt - xReturns the k-th element of a Tuple t, where 0 <= k <= 15. In other words, returns x_{k+1} if t=(x_1,...,x_n). If k>=n, or if t is Null, returns a Null instead of x.26
6F60FIRSTQ
CARQ
t - xReturns the first element of a Tuple.26
6F61SECONDQ
CDRQ
t - yReturns the second element of a Tuple.26
6F62THIRDQt - zReturns the third element of a Tuple.26
6F7k[k] SETINDEXQt x - t'Sets the k-th component of Tuple t to x, where 0 <= k < 16, and returns the resulting Tuple t'.
If \|t\| <= k, first extends the original Tuple to length n’=k+1 by setting all new components to Null. If the original value of t is Null, treats it as an empty Tuple. If t is not Null or Tuple, throws an exception. If x is Null and either \|t\| <= k or t is Null, then always returns t'=t (and does not consume tuple creation gas).
26+\|t’\|
6F70SETFIRSTQt x - t'Sets the first component of Tuple t to x and returns the resulting Tuple t'.26+\|t’\|
6F71SETSECONDQt x - t'Sets the second component of Tuple t to x and returns the resulting Tuple t'.26+\|t’\|
6F72SETTHIRDQt x - t'Sets the third component of Tuple t to x and returns the resulting Tuple t'.26+\|t’\|
6F80TUPLEVARx_1 ... x_n n - tCreates a new Tuple t of length n similarly to TUPLE, but with 0 <= n <= 255 taken from the stack.26+n
6F81INDEXVARt k - xSimilar to k INDEX, but with 0 <= k <= 254 taken from the stack.26
6F82UNTUPLEVARt n - x_1 ... x_nSimilar to n UNTUPLE, but with 0 <= n <= 255 taken from the stack.26+n
6F83UNPACKFIRSTVARt n - x_1 ... x_nSimilar to n UNPACKFIRST, but with 0 <= n <= 255 taken from the stack.26+n
6F84EXPLODEVARt n - x_1 ... x_m mSimilar to n EXPLODE, but with 0 <= n <= 255 taken from the stack.26+m
6F85SETINDEXVARt x k - t'Similar to k SETINDEX, but with 0 <= k <= 254 taken from the stack.26+\|t’\|
6F86INDEXVARQt k - xSimilar to n INDEXQ, but with 0 <= k <= 254 taken from the stack.26
6F87SETINDEXVARQt x k - t'Similar to k SETINDEXQ, but with 0 <= k <= 254 taken from the stack.26+\|t’\|
6F88TLENt - nReturns the length of a Tuple.26
6F89QTLENt - n or -1Similar to TLEN, but returns -1 if t is not a Tuple.26
6F8AISTUPLEt - ?Returns -1 or 0 depending on whether t is a Tuple.26
6F8BLASTt - xReturns the last element of a non-empty Tuple t.26
6F8CTPUSH
COMMA
t x - t'Appends a value x to a Tuple t=(x_1,...,x_n), but only if the resulting Tuple t'=(x_1,...,x_n,x) is of length at most 255. Otherwise throws a type check exception.26+\|t’\|
6F8DTPOPt - t' xDetaches the last element x=x_n from a non-empty Tuple t=(x_1,...,x_n), and returns both the resulting Tuple t'=(x_1,...,x_{n-1}) and the original last element x.26+\|t’\|
6FA0NULLSWAPIFx - x or null xPushes a Null under the topmost Integer x, but only if x!=0.26
6FA1NULLSWAPIFNOTx - x or null xPushes a Null under the topmost Integer x, but only if x=0. May be used for stack alignment after quiet primitives such as PLDUXQ.26
6FA2NULLROTRIFx y - x y or null x yPushes a Null under the second stack entry from the top, but only if the topmost Integer y is non-zero.26
6FA3NULLROTRIFNOTx y - x y or null x yPushes a Null under the second stack entry from the top, but only if the topmost Integer y is zero. May be used for stack alignment after quiet primitives such as LDUXQ.26
6FA4NULLSWAPIF2x - x or null null xPushes two nulls under the topmost Integer x, but only if x!=0.
Equivalent to NULLSWAPIF NULLSWAPIF.
26
6FA5NULLSWAPIFNOT2x - x or null null xPushes two nulls under the topmost Integer x, but only if x=0.
Equivalent to NULLSWAPIFNOT NULLSWAPIFNOT.
26
6FA6NULLROTRIF2x y - x y or null null x yPushes two nulls under the second stack entry from the top, but only if the topmost Integer y is non-zero.
Equivalent to NULLROTRIF NULLROTRIF.
26
6FA7NULLROTRIFNOT2x y - x y or null null x yPushes two nulls under the second stack entry from the top, but only if the topmost Integer y is zero.
Equivalent to NULLROTRIFNOT NULLROTRIFNOT.
26
6FBij[i] [j] INDEX2t - xRecovers x=(t_{i+1})_{j+1} for 0 <= i,j <= 3.
Equivalent to [i] INDEX [j] INDEX.
26
6FB4CADRt - xRecovers x=(t_2)_1.26
6FB5CDDRt - xRecovers x=(t_2)_2.26
6FE_ijk[i] [j] [k] INDEX3t - xRecovers x=t_{i+1}_{j+1}_{k+1}.
0 <= i,j,k <= 3
Equivalent to [i] [j] INDEX2 [k] INDEX.
26
6FD4CADDRt - xRecovers x=t_2_2_1.26
6FD5CDDDRt - xRecovers x=t_2_2_2.26

TVM Instructions Content List