"description":"Returns the power to which the number 2 must be raised to to obtain the value `n`, rounded down to the nearest integer. Fails on a negative numbers.",
"description":"The `let` function accepts a list of `variable name` and `expression` pairs,\nevaluating each expression and _binding_ it to the corresponding variable name. The _context_\ncreated by this set of bindings is used for evaluating its body expressions. The let expression returns the value of the last such body expression.",
"description":"The `let` function accepts a list of `variable name` and `expression` pairs,\nevaluating each expression and _binding_ it to the corresponding variable name.\n`let` bindings are sequential: when a `let` binding is evaluated, it may refer to prior binding.\nThe _context_ created by this set of bindings is used for evaluating its body expressions.\n The let expression returns the value of the last such body expression.\nNote: intermediary statements returning a response type must be checked",
"example":"(let ((a 2) (b (+ 5 6 7))) (print a) (print b) (+ a b)) ;; Returns 20"
"example":"(let ((a 2) (b (+ 5 6 7))) (print a) (print b) (+ a b)) ;; Returns 20\n(let ((a 5) (c (+ a 1)) (d (+ c 1)) (b (+ a c d))) (print a) (print b) (+ a b)) ;; Returns 23"
"description":"The `map` function applies the input function `func` to each element of the\ninput list, and outputs a list containing the _outputs_ from those function applications.",
"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.",
"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.",
"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`.",
"description":"The `map-get?` function looks up and returns an entry from a contract's data map.\nThe value is looked up using `key-tuple`.\nIf there is no value associated with that key in the data map, the function returns a `none` option. Otherwise,\nit returns `(some value)`.",
"description":"The `map-get?` function looks up and returns an entry from a contract's data map.\nThe value is looked up using `key-tuple`.\nIf there is no value associated with that key in the data map, the function returns a `none` option. Otherwise,\nit returns `(some value)`.",
"example":"(define-map names-map ((name (string-ascii 10))) ((id int)))\n(map-set names-map { name: \"blockstack\" } { id: 1337 })\n(map-get? names-map (tuple (name \"blockstack\"))) ;; Returns (some (tuple (id 1337)))\n(map-get? names-map ((name \"blockstack\"))) ;; Same command, using a shorthand for constructing the tuple\n"
"example":"(define-map names-map { name: (string-ascii 10) } { id: int })\n(map-set names-map { name: \"blockstack\" } { id: 1337 })\n(map-get? names-map (tuple (name \"blockstack\"))) ;; Returns (some (tuple (id 1337)))\n(map-get? names-map { name: \"blockstack\" }) ;; Same command, using a shorthand for constructing the tuple\n"
"description":"The `map-set` function sets the value associated with the input key to the\ninputted value. This function performs a _blind_ update; whether or not a value is already associated\nwith the key, the function overwrites that existing association.\n\nNote: the `value-tuple` requires 1 additional byte for storage in the materialized blockchain state,\nand therefore the maximum size of a value that may be inserted into a map is MAX_CLARITY_VALUE - 1.",
"description":"The `map-set` function sets the value associated with the input key to the\ninputted value. This function performs a _blind_ update; whether or not a value is already associated\nwith the key, the function overwrites that existing association.\n\nNote: the `value-tuple` requires 1 additional byte for storage in the materialized blockchain state,\nand therefore the maximum size of a value that may be inserted into a map is MAX_CLARITY_VALUE - 1.",
"example":"(define-map names-map ((name (string-ascii 10))) ((id int)))\n(map-set names-map { name: \"blockstack\" } { id: 1337 }) ;; Returns true\n(map-set names-map ((name \"blockstack\")) ((id 1337))) ;; Same command, using a shorthand for constructing the tuple\n"
"example":"(define-map names-map { name: (string-ascii 10) } { id: int })\n(map-set names-map { name: \"blockstack\" } { id: 1337 }) ;; Returns true\n(map-set names-map (tuple (name \"blockstack\")) (tuple (id 1337))) ;; Same command, using a shorthand for constructing the tuple\n"
"description":"The `map-insert` function sets the value associated with the input key to the\ninputted value if and only if there is not already a value associated with the key in the map.\nIf an insert occurs, the function returns `true`. If a value already existed for\nthis key in the data map, the function returns `false`.\n\nNote: the `value-tuple` requires 1 additional byte for storage in the materialized blockchain state,\nand therefore the maximum size of a value that may be inserted into a map is MAX_CLARITY_VALUE - 1.",
"description":"The `map-insert` function sets the value associated with the input key to the\ninputted value if and only if there is not already a value associated with the key in the map.\nIf an insert occurs, the function returns `true`. If a value already existed for\nthis key in the data map, the function returns `false`.\n\nNote: the `value-tuple` requires 1 additional byte for storage in the materialized blockchain state,\nand therefore the maximum size of a value that may be inserted into a map is MAX_CLARITY_VALUE - 1.",
"example":"(define-map names-map ((name (string-ascii 10))) ((id int)))\n(map-insert names-map { name: \"blockstack\" } { id: 1337 }) ;; Returns true\n(map-insert names-map { name: \"blockstack\" } { id: 1337 }) ;; Returns false\n(map-insert names-map ((name \"blockstack\")) ((id 1337))) ;; Same command, using a shorthand for constructing the tuple\n"
"example":"(define-map names-map { name: (string-ascii 10) } { id: int })\n(map-insert names-map { name: \"blockstack\" } { id: 1337 }) ;; Returns true\n(map-insert names-map { name: \"blockstack\" } { id: 1337 }) ;; Returns false\n(map-insert names-map (tuple (name \"blockstack\")) (tuple (id 1337))) ;; Same command, using a shorthand for constructing the tuple\n"
},
},
{
{
"name":"map-delete",
"name":"map-delete",
@ -262,7 +286,7 @@
"output_type":"bool",
"output_type":"bool",
"signature":"(map-delete map-name key-tuple)",
"signature":"(map-delete map-name key-tuple)",
"description":"The `map-delete` function removes the value associated with the input key for\nthe given map. If an item exists and is removed, the function returns `true`.\nIf a value did not exist for this key in the data map, the function returns `false`.",
"description":"The `map-delete` function removes the value associated with the input key for\nthe given map. If an item exists and is removed, the function returns `true`.\nIf a value did not exist for this key in the data map, the function returns `false`.",
"example":"(define-map names-map ((name (string-ascii 10))) ((id int)))\n(map-insert names-map { name: \"blockstack\" } { id: 1337 }) ;; Returns true\n(map-delete names-map { name: \"blockstack\" }) ;; Returns true\n(map-delete names-map { name: \"blockstack\" }) ;; Returns false\n(map-delete names-map ((name \"blockstack\"))) ;; Same command, using a shorthand for constructing the tuple\n"
"example":"(define-map names-map { name: (string-ascii 10) } { id: int })\n(map-insert names-map { name: \"blockstack\" } { id: 1337 }) ;; Returns true\n(map-delete names-map { name: \"blockstack\" }) ;; Returns true\n(map-delete names-map { name: \"blockstack\" }) ;; Returns false\n(map-delete names-map (tuple (name \"blockstack\"))) ;; Same command, using a shorthand for constructing the tuple\n"
},
},
{
{
"name":"tuple",
"name":"tuple",
@ -278,14 +302,22 @@
"output_type":"A",
"output_type":"A",
"signature":"(get key-name tuple)",
"signature":"(get key-name tuple)",
"description":"The `get` function fetches the value associated with a given key from the supplied typed tuple.\nIf an `Optional` value is supplied as the inputted tuple, `get` returns an `Optional` type of the specified key in\nthe tuple. If the supplied option is a `(none)` option, get returns `(none)`.",
"description":"The `get` function fetches the value associated with a given key from the supplied typed tuple.\nIf an `Optional` value is supplied as the inputted tuple, `get` returns an `Optional` type of the specified key in\nthe tuple. If the supplied option is a `(none)` option, get returns `(none)`.",
"description":"The `begin` function evaluates each of its input expressions, returning the\nreturn value of the last such expression.",
"description":"The `begin` function evaluates each of its input expressions, returning the\nreturn value of the last such expression.\nNote: intermediary statements returning a response type must be checked.",
"description":"The `default-to` function attempts to 'unpack' the second argument: if the argument is\na `(some ...)` option, it returns the inner value of the option. If the second argument is a `(none)` value,\n`default-to` it returns the value of `default-value`.",
"description":"The `default-to` function attempts to 'unpack' the second argument: if the argument is\na `(some ...)` option, it returns the inner value of the option. If the second argument is a `(none)` value,\n`default-to` it returns the value of `default-value`.",
"description":"The `unwrap!` function attempts to 'unpack' the first argument: if the argument is\nan option type, and the argument is a `(some ...)` option, `unwrap!` returns the inner value of the\noption. If the argument is a response type, and the argument is an `(ok ...)` response, `unwrap!` returns\n the inner value of the `ok`. If the supplied argument is either an `(err ...)` or a `(none)` value,\n`unwrap!` _returns_ `thrown-value` from the current function and exits the current control-flow.",
"description":"The `unwrap!` function attempts to 'unpack' the first argument: if the argument is\nan option type, and the argument is a `(some ...)` option, `unwrap!` returns the inner value of the\noption. If the argument is a response type, and the argument is an `(ok ...)` response, `unwrap!` returns\n the inner value of the `ok`. If the supplied argument is either an `(err ...)` or a `(none)` value,\n`unwrap!` _returns_ `thrown-value` from the current function and exits the current control-flow.",
"description":"The `unwrap` function attempts to 'unpack' its argument: if the argument is\nan option type, and the argument is a `(some ...)` option, this function returns the inner value of the\noption. If the argument is a response type, and the argument is an `(ok ...)` response, it returns\n the inner value of the `ok`. If the supplied argument is either an `(err ...)` or a `(none)` value,\n`unwrap` throws a runtime error, aborting any further processing of the current transaction.",
"description":"The `unwrap` function attempts to 'unpack' its argument: if the argument is\nan option type, and the argument is a `(some ...)` option, this function returns the inner value of the\noption. If the argument is a response type, and the argument is an `(ok ...)` response, it returns\n the inner value of the `ok`. If the supplied argument is either an `(err ...)` or a `(none)` value,\n`unwrap` throws a runtime error, aborting any further processing of the current transaction.",
"description":"The `try!` function attempts to 'unpack' the first argument: if the argument is\nan option type, and the argument is a `(some ...)` option, `try!` returns the inner value of the\noption. If the argument is a response type, and the argument is an `(ok ...)` response, `try!` returns\n the inner value of the `ok`. If the supplied argument is either an `(err ...)` or a `none` value,\n`try!` _returns_ either `none` or the `(err ...)` value from the current function and exits the current control-flow.",
"description":"The `try!` function attempts to 'unpack' the first argument: if the argument is\nan option type, and the argument is a `(some ...)` option, `try!` returns the inner value of the\noption. If the argument is a response type, and the argument is an `(ok ...)` response, `try!` returns\n the inner value of the `ok`. If the supplied argument is either an `(err ...)` or a `none` value,\n`try!` _returns_ either `none` or the `(err ...)` value from the current function and exits the current control-flow.",
"description":"`define-map` is used to define a new datamap for use in a smart contract. Such\nmaps are only modifiable by the current smart contract.\n\nMaps are defined with a key tuple type and value tuple type. These are defined using a list\nof name and type pairs, e.g., a key type might be `((id int))`, which is a tuple with a single \"id\"\nfield of type `int`.\n\nLike other kinds of definition statements, `define-map` may only be used at the top level of a smart contract\ndefinition (i.e., you cannot put a define statement in the middle of a function body).",
"description":"`define-map` is used to define a new datamap for use in a smart contract. Such\nmaps are only modifiable by the current smart contract.\n\nMaps are defined with a key tuple type and value tuple type. These are defined using a list\nof name and type pairs, e.g., a key type might be `((id int))`, which is a tuple with a single \"id\"\nfield of type `int`.\n\nLike other kinds of definition statements, `define-map` may only be used at the top level of a smart contract\ndefinition (i.e., you cannot put a define statement in the middle of a function body).",