🗐 QuickList - Making Lua tables better

You should adopt the JavaScript approach and make dictionaries a separate thing. In JavaScript you have three “table-like” classes: Object, Array, and Map (Set not included*) They’re done this way because some methods may only apply nicely to arrays and not dictionaries/maps. They seemingly are the same while also being vastly different at the same time. It is worth noting a Map should be able to be converted into an Array and keep its data.

Object is the closest relative to Lua tables, but iterator functions have to pretty much be pre-defined and they always feel inferior to use over the other two.

Yup, I wanted to make it as seemless as possible (somewhat). And making different objects would make it slightly annoying to work with.

Mostly because it would be annoying to keep everything in a single module, and using it outside of Roblox would be slightly harder.

Also the fact that everything (arrays, dictionaries, maps) is a table in lua would be a bit annoying.

I wouldn’t be focusing on dictionaries at all but I wanted to try it. QuickList is still 90% for arrays though.

One more thing I wanted to address was sending ql objects through remote events.
Just use ql.get_table() as the argument, and remake the QuickList after in the connection.

Client (LocalScript)

local RemoteEvent = game.ReplicatedStorage.RE
local _ = require('QuickList')

local myTable = {"Hello", "World"}
RemoteEvent:FireServer(myTable.get_table()) -- Convert QuickList into a table

Server (Script)

local RemoteEvent = game.ReplicatedStorage.RE
local _ = require('QuickList')

RemoteEvent.OnServerEvent:Connect(function(player, myTable)
    local QL_myTable = _(myTable) -- Convert the table into a quicklist
    print(QL_myTable)
end)
1 Like

Another update!

  • I will change the __tostring() method and fix it to actually work better for dictionaries.
  • Added removeIf(func)
myTable.removeIf(function(i, v)
    if v == "hi" then
        return 1
    end
    return false
end)

If the function returns a true-type value then it will delete the instance, it loops through the entire list and returns a copy of it.

hey there, sorry for bumping but you should definetly add this to wally

1 Like

Good idea, and thanks.

Wally Integration

You can now use the Wally package manager to install quicklist.

Steps

  • initialize wally using wally init
  • in the wally.toml file, add this:
quicklist = "creepersaur/quicklist@^1.0"
  • run wally install

You’ll have installed quicklist. (Version number may vary, github may still have the latest version.)

As long as the versions are published to the Wally Registry, You can use Semver versions such as ^1.0 and Wally will adhere to it.

As such, the Package Version should adhere to the one from Source, even if that means bumping the current version

1 Like

Ah okay, so I can publish different versions to the same creepersaur/quicklist and it’ll automatically pickup?

That’s cool.

New Quicklist logo!

Quicklist_logo
GitHub | Library | Wally

1 Like

Is the aim for this module to make Lua tables more like Python tables?

Personally can’t see a use case for myself but i’m curious to know more about the design that went into it

1 Like

Roblox (lua) tables are pretty lacking, and also each table method has to be called using the original table class, rather than calling it directly.

Quicklist solves this issue by just wrapping the table in a metatable and adding a bunch of extra built-in features on top of that. Python’s datatypes let you call their methods directly using dot notation, and hence the same for quicklist. Also I was inspired a little by javascript for some things too.

Take for example, the random, sum and average methods. These aren’t in the table class, and it just helps to have them all in one place and to be able to call them directly. A bunch of QuickList’s methods return a copy of the list, which is also useful.

TL;DR: Making Lua Tables Better.

v1.0.4

A lot of changes. I don’t remember most of them. :sweat_smile:

- retain(func) function:

local my_list: ql.Quicklist = ql {
    1, 2, 3, 4
}

my_list.retain(function(i: number, v: any)
    if v % 2 == 0 then
        return true
    end
end)

print(my_list) -- Will print `{2, 4}` since it retained any even number.

And more! :white_check_mark:

GitHub | Library | Wally

2 Likes

Any other features that should be added into quicklist?
(Also please report bugs you may find)

1 Like

Update

  • added execN
  • added setEach
  • added first
  • added last

(Only added to the source code, if you want the latest version copy paste / download Quicklist.lua from the source code, NOT THE RELEASES)

1 Like