Browse Source

auto: update Clarity references JSONs from stacks-blockchain@63d24b1185bca6a35988aa90667bc5f0a226acb9

friedger-patch-7
PR Robot 3 years ago
committed by Patrick Gray
parent
commit
e6cd8cd4a3
  1. 68
      src/_data/clarity-reference.json

68
src/_data/clarity-reference.json

@ -170,19 +170,19 @@
},
{
"name": "map",
"input_type": "Function(A, B, ..., N) -> X, (list A1 A2 ... Am), (list B1 B2 ... Bm), ..., (list N1 N2 ... Nm)",
"input_type": "Function(A, B, ..., N) -> X, sequence_A, sequence_B, ..., sequence_N",
"output_type": "(list X)",
"signature": "(map func list-A list-B ... list-N)",
"description": "The `map` function applies the input function `func` to each element of the\ninput lists, and outputs a list containing the _outputs_ from those function applications.",
"example": "\n(map not (list true false true false)) ;; Returns (false true false true)\n(map + (list 1 2 3) (list 1 2 3) (list 1 2 3)) ;; Returns (3 6 9)"
"signature": "(map func sequence_A sequence_B ... sequence_N)",
"description": "The `map` function applies the function `func` to each corresponding element of the input sequences,\nand outputs a _list_ of the same type containing the outputs from those function applications.\nApplicable sequence types are `(list A)`, `buff`, `string-ascii` and `string-utf8`,\nfor which the corresponding element types are, respectively, `A`, `(buff 1)`, `(string-ascii 1)` and `(string-utf8 1)`.\nThe `func` argument must be a literal function name.\nAlso, note that, no matter what kind of sequences the inputs are, the output is always a list.",
"example": "\n(map not (list true false true false)) ;; Returns (false true false true)\n(map + (list 1 2 3) (list 1 2 3) (list 1 2 3)) ;; Returns (3 6 9)\n(define-private (a-or-b (char (string-utf8 1))) (if (is-eq char u\"a\") u\"a\" u\"b\"))\n(map a-or-b u\"aca\") ;; Returns (u\"a\" u\"b\" u\"a\")\n(define-private (zero-or-one (char (buff 1))) (if (is-eq char 0x00) 0x00 0x01))\n(map zero-or-one 0x000102) ;; Returns (0x00 0x01 0x01)\n"
},
{
"name": "fold",
"input_type": "Function(A, B) -> B, (list A), B",
"input_type": "Function(A, B) -> B, sequence_A, B",
"output_type": "B",
"signature": "(fold func list initial-value)",
"description": "The `fold` special form applies the input function `func` to each element of the\ninput list _and_ the output of the previous application of the `fold` function. When invoked on\nthe first list element, it uses the `initial-value` as the second input. `fold` returns the last\nvalue returned by the successive applications. Note that the first argument is not evaluated thus\nhas to be a literal function name.",
"example": "(fold * (list 2 2 2) 1) ;; Returns 8\n(fold * (list 2 2 2) 0) ;; Returns 0\n;; calculates (- 11 (- 7 (- 3 2)))\n(fold - (list 3 7 11) 2) ;; Returns 5 \n(define-private (concat-string (a (string-ascii 20)) (b (string-ascii 20))) (unwrap-panic (as-max-len? (concat a b) u20)))\n(fold concat-string \"cdef\" \"ab\") ;; Returns \"fedcab\"\n(fold concat-string (list \"cd\" \"ef\") \"ab\") ;; Returns \"efcdab\""
"signature": "(fold func sequence_A initial_B)",
"description": "The `fold` function condenses `sequence_A` into a value of type\n`B` by recursively applies the function `func` to each element of the\ninput sequence _and_ the output of a previous application of `func`.\n\n`fold` uses `initial_B` in the initial application of `func`, along with the\nfirst element of `sequence_A`. The resulting value of type `B` is used for the\nnext application of `func`, along with the next element of `sequence_A` and so\non. `fold` returns the last value of type `B` returned by these successive\napplications `func`.\n\nApplicable sequence types are `(list A)`, `buff`, `string-ascii` and `string-utf8`,\nfor which the corresponding element types are, respectively, `A`, `(buff 1)`, `(string-ascii 1)` and `(string-utf8 1)`.\nThe `func` argument must be a literal function name.\n",
"example": "\n(fold * (list 2 2 2) 1) ;; Returns 8\n(fold * (list 2 2 2) 0) ;; Returns 0\n;; calculates (- 11 (- 7 (- 3 2)))\n(fold - (list 3 7 11) 2) ;; Returns 5 \n(define-private (concat-string (a (string-ascii 20)) (b (string-ascii 20))) (unwrap-panic (as-max-len? (concat a b) u20)))\n(fold concat-string \"cdef\" \"ab\") ;; Returns \"fedcab\"\n(fold concat-string (list \"cd\" \"ef\") \"ab\") ;; Returns \"efcdab\"\n(define-private (concat-buff (a (buff 20)) (b (buff 20))) (unwrap-panic (as-max-len? (concat a b) u20)))\n(fold concat-buff 0x03040506 0x0102) ;; Returns 0x060504030102\n"
},
{
"name": "append",
@ -194,43 +194,43 @@
},
{
"name": "concat",
"input_type": "(buff, buff)|(list, list)",
"output_type": "buff|list",
"signature": "(concat buff-a buff-b)",
"description": "The `concat` function takes two buffers or two lists with the same entry type,\nand returns a concatenated buffer or list of the same entry type, with max_len = max_len_a + max_len_b.",
"example": "(concat \"hello \" \"world\") ;; Returns \"hello world\""
"input_type": "sequence_A, sequence_A",
"output_type": "sequence_A",
"signature": "(concat sequence1 sequence2)",
"description": "The `concat` function takes two sequences of the same type,\nand returns a concatenated sequence of the same type, with the resulting\nsequence_len = sequence1_len + sequence2_len.\nApplicable sequence types are `(list A)`, `buff`, `string-ascii` and `string-utf8`.\n",
"example": "\n(concat (list 1 2) (list 3 4)) ;; Returns (1 2 3 4)\n(concat \"hello \" \"world\") ;; Returns \"hello world\"\n(concat 0x0102 0x0304) ;; Returns 0x01020304\n"
},
{
"name": "as-max-len?",
"input_type": "buff|list, uint",
"output_type": "(optional buff|list)",
"signature": "(as-max-len? buffer u10)",
"description": "The `as-max-len?` function takes a length N (must be a literal) and a buffer or list argument, which must be typed as a list\nor buffer of length M and outputs that same list or buffer, but typed with max length N.\n\nThis function returns an optional type with the resulting sequence. If the input sequence is less than\nor equal to the supplied max-len, it returns `(some <sequence>)`, otherwise it returns `none`.",
"example": "(as-max-len? (list 2 2 2) u3) ;; Returns (some (2 2 2))\n(as-max-len? (list 1 2 3) u2) ;; Returns none"
"input_type": "sequence_A, uint",
"output_type": "sequence_A",
"signature": "(as-max-len? sequence max_length)",
"description": "The `as-max-len?` function takes a sequence argument and a uint-valued, literal length argument.\nThe function returns an optional type. If the input sequence length is less than\nor equal to the supplied max_length, this returns `(some sequence)`, otherwise it returns `none`.\nApplicable sequence types are `(list A)`, `buff`, `string-ascii` and `string-utf8`.\n",
"example": "\n(as-max-len? (list 2 2 2) u3) ;; Returns (some (2 2 2))\n(as-max-len? (list 1 2 3) u2) ;; Returns none\n(as-max-len? \"hello\" u10) ;; Returns (some \"hello\")\n(as-max-len? 0x010203 u10) ;; Returns (some 0x010203)\n"
},
{
"name": "len",
"input_type": "buff|list",
"input_type": "sequence_A",
"output_type": "uint",
"signature": "(len buffer)",
"description": "The `len` function returns the length of a given buffer or list.",
"example": "(len \"blockstack\") ;; Returns u10\n(len (list 1 2 3 4 5)) ;; Returns u5\n"
"signature": "(len sequence)",
"description": "The `len` function returns the length of a given sequence.\nApplicable sequence types are `(list A)`, `buff`, `string-ascii` and `string-utf8`.\n ",
"example": "\n(len \"blockstack\") ;; Returns u10\n(len (list 1 2 3 4 5)) ;; Returns u5\n(len 0x010203) ;; Returns u3\n"
},
{
"name": "element-at",
"input_type": "buff|list A, uint",
"output_type": "(optional buff|A)",
"input_type": "sequence_A, uint",
"output_type": "(optional A)",
"signature": "(element-at sequence index)",
"description": "The `element-at` function returns the element at `index` in the provided sequence.\nIf `index` is greater than or equal to `(len sequence)`, this function returns `none`.\nFor strings and buffers, this function will return 1-length strings or buffers.",
"example": "(element-at \"blockstack\" u5) ;; Returns (some \"s\")\n(element-at (list 1 2 3 4 5) u5) ;; Returns none\n(element-at (list 1 2 3 4 5) (+ u1 u2)) ;; Returns (some 4)\n(element-at \"abcd\" u1) ;; Returns (some \"b\")\n(element-at 0xfb01 u1) ;; Returns (some 0x01)\n"
"description": "The `element-at` function returns the element at `index` in the provided sequence.\nApplicable sequence types are `(list A)`, `buff`, `string-ascii` and `string-utf8`,\nfor which the corresponding element types are, respectively, `A`, `(buff 1)`, `(string-ascii 1)` and `(string-utf8 1)`.\n",
"example": "\n(element-at \"blockstack\" u5) ;; Returns (some \"s\")\n(element-at (list 1 2 3 4 5) u5) ;; Returns none\n(element-at (list 1 2 3 4 5) (+ u1 u2)) ;; Returns (some 4)\n(element-at \"abcd\" u1) ;; Returns (some \"b\")\n(element-at 0xfb01 u1) ;; Returns (some 0x01)\n"
},
{
"name": "index-of",
"input_type": "buff|list A, buff|A",
"input_type": "sequence_A, A",
"output_type": "(optional uint)",
"signature": "(index-of sequence item)",
"description": "The `index-of` function returns the first index at which `item` can be\nfound in the provided sequence (using `is-eq` checks).\n\nIf this item is not found in the sequence (or an empty string/buffer is supplied), this\nfunction returns `none`.",
"example": "(index-of \"blockstack\" \"b\") ;; Returns (some u0)\n(index-of \"blockstack\" \"k\") ;; Returns (some u4)\n(index-of \"blockstack\" \"\") ;; Returns none\n(index-of (list 1 2 3 4 5) 6) ;; Returns none\n(index-of 0xfb01 0x01) ;; Returns (some u1)\n"
"description": "The `index-of` function returns the first index at which `item` can be\nfound, using `is-eq` checks, in the provided sequence.\nApplicable sequence types are `(list A)`, `buff`, `string-ascii` and `string-utf8`,\nfor which the corresponding element types are, respectively, `A`, `(buff 1)`, `(string-ascii 1)` and `(string-utf8 1)`.\nIf the target item is not found in the sequence (or if an empty string or buffer is\nsupplied), this function returns `none`.\n",
"example": "\n(index-of \"blockstack\" \"b\") ;; Returns (some u0)\n(index-of \"blockstack\" \"k\") ;; Returns (some u4)\n(index-of \"blockstack\" \"\") ;; Returns none\n(index-of (list 1 2 3 4 5) 6) ;; Returns none\n(index-of 0xfb01 0x01) ;; Returns (some u1)\n"
},
{
"name": "list",
@ -554,11 +554,11 @@
},
{
"name": "filter",
"input_type": "Function(A) -> bool, (list A)",
"output_type": "(list A)",
"signature": "(filter func list)",
"description": "The `filter` function applies the input function `func` to each element of the\ninput list, and returns the same list with any elements removed for which the `func` returned `false`.",
"example": "(filter not (list true false true false)) ;; Returns (false false)"
"input_type": "Function(A) -> bool, sequence_A",
"output_type": "sequence_A",
"signature": "(filter func sequence)",
"description": "The `filter` function applies the input function `func` to each element of the\ninput sequence, and returns the same sequence with any elements removed for which `func` returned `false`.\nApplicable sequence types are `(list A)`, `buff`, `string-ascii` and `string-utf8`,\nfor which the corresponding element types are, respectively, `A`, `(buff 1)`, `(string-ascii 1)` and `(string-utf8 1)`.\nThe `func` argument must be a literal function name.\n",
"example": "\n(filter not (list true false true false)) ;; Returns (false false)\n(define-private (is-a (char (string-utf8 1))) (is-eq char u\"a\"))\n(filter is-a u\"acabd\") ;; Returns u\"aa\"\n(define-private (is-zero (char (buff 1))) (is-eq char 0x00))\n(filter is-zero 0x00010002) ;; Returns 0x0000\n"
},
{
"name": "ft-get-balance",

Loading…
Cancel
Save