[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [NoW] Missing things from Lua
- From: Paul K <paul@...>
- Date: Thu, 16 May 2019 08:58:16 -0700
Hi Dirk,
> for p, c in string.bytes(s) do body end
> will iterate over all bytes in string s, with p being the position.
> This is surprisingly clumsy in pure Lua, unless I am missing a trick.
`s:gmatch("()(.)")`? Or am I missing something?
Paul.
On Thu, May 16, 2019 at 8:52 AM Dirk Laurie <dirk.laurie@gmail.com> wrote:
>
> I'm latching to the subject, not the post. Some time ago I posted:
> ~~~
> By analogy to the function utf8.codes, it would be nice to have a
> function string.bytes so that the construction
>
> for p, c in string.bytes(s) do body end
>
> will iterate over all bytes in string s, with p being the position.
> This is surprisingly clumsy in pure Lua, unless I am missing a trick.
> ~~~
> in reply to which somebody was kind enough to post Lua code
> illustrating my point.
>
> -- Dirk
>