5 months ago
I have an array of structs that I want to iterate through in Cairo, how can I achieve this?
ㅤ This question was originally posted on Triality
You can do this through recursion. A key difference between iterating through an array of structs vs an array of felts is that each recursive call should increase the array index by
<YourStruct>.SIZE , vs. just incrementing it by
1 for an array of felts. For example:
member x : felt
member y : felt
func yourFunc(points: Point*, points_len : felt):
if points_len == 0:
let p: Point = points
# do whatever you wish with p
# recursively call yourFunc, but increase the location in the array by Point.SIZE
yourFunc(points + Point.SIZE, points_len - 1)
ㅤ This answer was originally posted on Triality
6 months ago
Which is this extension that shows you errors before compilation ser?
Revoked References exercise from Cairo-lang
How many time does it take for stark to eth starkgate bridge process?
Cairo: let vs tempvar what is the difference?
Is there a Cairo equivalent to Keccak256(abi.encode(parameters))?
Is it possible to import local python files into hints?
How do I create AX (ArgentX) contract using starknetjs?