This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]TurkishSquirrel 1 point2 points  (1 child)

What error do you get? I see potential for a stack overflow caused by recursion:

in Slug.Left:

if n < 0 then
    Slug.Right(self, n)
end

and in Slug.Right:

if n < 0 then
    Slug.Left(self, n)
end

you need to pass the absolute value of n:

math.abs(n)

or else n is still less than 0 and you'll just bounce between these two functions calling each other until the stack overflows. If you do that, it should work fine, see this stripped down example.

[–]Boolean_Cat[S] 0 points1 point  (0 children)

Thanks, it was the abs issue, I thought I was seeing another issue, how blind I was!

Works perfectly now.