You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A repeat function can generate a list of identical items repeated a given number of times.
Lists of explicitly repeated items are used in many Clarity contracts, typically with map and fold. For illustration, here is a function to increment integers in a list with an integer incremental `n':
(define-read-only (inc-many (items (list20int)) (nint))
(map + items (list n n n n n n n n n n n n n n n n n n n n)))
A
repeat
function can generate a list of identical items repeated a given number of times.Lists of explicitly repeated items are used in many Clarity contracts, typically with
map
andfold
. For illustration, here is a function to increment integers in a list with an integer incremental `n':Using
repeat
simplifies this to:The cost of using
repeat
should be the same or less than having explicitly repeated items in the contract.The text was updated successfully, but these errors were encountered: