Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

7.2 wrong start #17

Open
b10s opened this issue Jul 15, 2017 · 0 comments
Open

7.2 wrong start #17

b10s opened this issue Jul 15, 2017 · 0 comments

Comments

@b10s
Copy link

b10s commented Jul 15, 2017

https://github.com/xfbs/PiL3/blob/master/07Iterators/fromtostep.lua
Hey, again : )

your code gives:

> for i in fromto(3,7,2) do print(i) end
4
6

but should be:

> for i in fromto(3,7,2) do print(i) end
3
5
7

my code:

function fromto(f,t,s)                                                              
    local iter; iter = function(s)                                                  
        s[1] = s[1] + s[3]                                                          
        if s[1]<=s[2] then                                                          
            return s[1]                                                             
        else                                                                        
            return nil                                                              
        end                                                                         
    end                                                                             
    return iter, {f-s,t,s}                                                          
end  

https://github.com/xfbs/PiL3/blob/master/07Iterators/fromtostep.lua#L26
min-1 should be min-step i guess

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant