Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

Fibonacci array #5

Open
0xLucqs opened this issue Jan 17, 2023 · 1 comment · May be fixed by #63
Open

Fibonacci array #5

0xLucqs opened this issue Jan 17, 2023 · 1 comment · May be fixed by #63

Comments

@0xLucqs
Copy link
Contributor

0xLucqs commented Jan 17, 2023

Description

Compile a sierra fib implementation that uses an array into an llvm IR file

fn fib(n: u128) -> (Array::<felt>, felt, u128) {
    let mut arr = array_new::<felt>();
    array_append::<felt>(arr, 1);
    array_append::<felt>(arr, 1);
    let mut arr = fib_inner(n, arr);
    let len = array_len::<felt>(arr);
    let last = unchecked_array_at(arr, len - 1_u128);
    return (arr, last, len);
}

fn fib_inner(n: u128, mut arr: Array::<felt>) -> Array::<felt> {
    let length = array_len::<felt>(arr);
    if n <= length {
        return arr;
    }
    array_append::<felt>(
        arr, unchecked_array_at(arr, length - 1_u128) + unchecked_array_at(arr, length - 2_u128)
    );
    fib_inner(n, arr)
}

Acceptance criteria

  • Shenlong should compile the sierra file into an LLVM IR file
  • The compiled fib should return the right value
@github-actions
Copy link

There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.
Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a 👍
Because this issue is marked as stale, it will be closed and locked in 7 days if no further activity occurs.
Thank you for your contributions!

@github-actions github-actions bot added the stale label Feb 17, 2023
@0xLucqs 0xLucqs removed the stale label Feb 24, 2023
@0xLucqs 0xLucqs linked a pull request Mar 6, 2023 that will close this issue
10 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
No open projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

1 participant