[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Infinity as index
- From: Sean Conner <sean@...>
- Date: Thu, 24 Apr 2014 23:17:19 -0400
It was thus said that the Great Lukas Prokop once stated:
> > On Thu, Apr 24, 2014 at 11:22 AM, Thiago L. <fakedme@gmail.com> wrote:
> >> On 24/04/2014 12:41, steve donovan wrote:
> >>> [...]
> >> Well something like what I said... I would actually expect str:sub(inf)
> >> to expand to str:sub(#str+1) and str:sub(-inf,inf) to expand to
> >> str:sub(0,#str+1)... or something...
> >
> > This is a really basic question (maybe so much so as to be off-topic):
> >
> > What is all of this useful for? Where do you guys come across this in real
> > life?
>
> For my part, I was developing on the markdown parser and had a pattern
> like this:
>
> [[ Parsing recursive HTML5 tag structures ]]
> 1. Initialize "from, to = 1, 1/0"
You could do
from, to = 1, math.huge
as math.huge is +inf. But seeing how that doesn't work with string.sub(),
how about?
from, to = 1 , 2^31-1
(at least for Lua <= 5.2).
> x = "1234567890"
> y = x:sub(1,2^31-1)
> print(y)
1234567890
>
-spc