NEWTON

NEWTON


Popular tags

    Cairo: Iterating through arrays

    Asked

    6 months ago

    10

    views


    0

    I have an array in Cairo

    let (myArr : felt*) = alloc()

    How do I set the 1st and 2nd term and get the first and second term?

    This question was originally posted on Triality

      cairocairo-lang

    1 answers

    0

    You can set the terms of the felt* to 1 and 3 respectively like this:

    assert [myArr] = 1

    assert [myArr + 1] = 3

    Then if you want to access the first term, then the second, you would have the following instructions

    let val1 = [myArr] # = 1

    let val2 = [myArr + 1] # = 3

    This answer was originally posted on Triality

    answered

    6 months ago

    Your answer

    NEWTON

    NEWTON