|
| 25 Aug 2015 03:23 AM |
It starts at 0 and continues until it's numbered every value in the table. How would I go about doing this?
Example:
_tab = {1,2,3,4,5} _count = {} for i,v in pairs(_tab) --Whatever it does print(_count[i]) end
--> 0 --> 1 --> 01 --> 10 --> 11 |
|
|
| Report Abuse |
|
|
|
| 25 Aug 2015 03:27 AM |
| http://stackoverflow.com/questions/9079853/lua-print-integer-as-a-binary |
|
|
| Report Abuse |
|
|
|
| 25 Aug 2015 03:27 AM |
| No joke I did this this morning for fun |
|
|
| Report Abuse |
|
|
|
| 25 Aug 2015 03:46 AM |
THANK YOU SO MUCH!
That worked perfectly! |
|
|
| Report Abuse |
|
|
| |
|
|
| 25 Aug 2015 05:55 AM |
Well, pretty much what I said; I wanted to take a table and add a binary count to it. It's for one of my encryption methods. It was supposed to be a branched tree kinda table, but I don't know if I could index it properly, so I just defaulted to manually indexing every value. I didn't want to do /all/ of it by hand, because there're about 50 characters in the table, so I used a script and printed a new table with string keys that index the letter and its corresponding binary value.
It pretty much does the same thing as the branched tree pattern would; the most common characters get the lowest values. "e" and "space" are the two most common values, so they get the lowest binary representation of 0 and 1 respectively. The least common character, "}" has a much longer value (something like 00101100).
I might be making things a little more complex than they need to be, but it's quite effective. |
|
|
| Report Abuse |
|
|