[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: string.pack with bit resolution
- From: bil til <flyer31@...>
- Date: Mon, 21 Oct 2019 11:21:29 -0700 (MST)
In my format option spec (Oct. 20, 9:23 blog above), I extended the table
formatting options t, T, |(pre-char for index part), :(pre-char for key
part), *(pre-char for index+key part).
Further I specifed q(=q1) to be used for boolean values, and Q(=Q1) for int
values.
E. g. if t is a boolean table, then you can use the following commands for
optimum packing:
string.pack( "|q", t) (for the index part of t)
string.pack( ":q", t) (for the key part of t)
string.pack( "*q", t) (for the key part of t)
Further these "linear table format options (t, |, :, *) (NOT the nested
option T) will allow very easy de-composition of tables into key lists:
str_kv= string.pack( ":N", t) (or "t2" instead of ":N", this is equivalent)
can then be very easily split into two indexed tables of keys and values:
t_keys, t_values= string.unpack( "|N|N", str)
... this is somehow a nice and powerful new application for pack and unpack,
which hopefully many people will love.
--
Sent from: http://lua.2524044.n2.nabble.com/Lua-l-f2524044.html
- References:
- Re: string.pack with bit resolution, bil til
- Re: string.pack with bit resolution, Sean Conner
- Re: string.pack with bit resolution, bil til
- Re: string.pack with bit resolution, bil til
- Re: string.pack with bit resolution, Sean Conner
- Re: string.pack with bit resolution, bil til
- Re: string.pack with bit resolution, Sean Conner
- Re: string.pack with bit resolution, bil til
- Re: string.pack with bit resolution, Sean Conner
- Re: string.pack with bit resolution, bil til