Skip to content

Examples of returning a mutable reference to a sequence #3492

Closed Locked Answered by adsharma
adsharma asked this question in Q&A
Discussion options

You must be logged in to vote
fn bubble_sort(owned seq: GenericArray[Int]) raises -> GenericArray[Int]:
    var L = seq.size
    for _ in range(L):
        for n in range(1, L):
            if seq[(n)] < seq[(n - 1)]:
                seq[(n - 1)], seq[(n)] = seq[n], seq[(n - 1)]
    return seq^

works ok.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by adsharma
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant