{"id":15374209,"url":"https://github.com/moteus/lua-vararg","last_synced_at":"2025-07-11T06:35:45.821Z","repository":{"id":8228446,"uuid":"9668571","full_name":"moteus/lua-vararg","owner":"moteus","description":"Library for manipulation of variable arguements of functions","archived":false,"fork":false,"pushed_at":"2021-01-07T19:54:04.000Z","size":39,"stargazers_count":25,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-30T19:52:12.910Z","etag":null,"topics":["lua","varargs"],"latest_commit_sha":null,"homepage":null,"language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/moteus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-04-25T09:45:04.000Z","updated_at":"2023-05-23T04:32:41.000Z","dependencies_parsed_at":"2022-08-06T23:00:23.852Z","dependency_job_id":null,"html_url":"https://github.com/moteus/lua-vararg","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/moteus/lua-vararg","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moteus%2Flua-vararg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moteus%2Flua-vararg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moteus%2Flua-vararg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moteus%2Flua-vararg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moteus","download_url":"https://codeload.github.com/moteus/lua-vararg/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moteus%2Flua-vararg/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264748946,"owners_count":23658103,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lua","varargs"],"created_at":"2024-10-01T13:57:42.752Z","updated_at":"2025-07-11T06:35:45.770Z","avatar_url":"https://github.com/moteus.png","language":"Lua","readme":"## Unofficial repositary of [vararg](http://www.tecgraf.puc-rio.br/~maia/lua/vararg)\n[![Licence](http://img.shields.io/badge/Licence-MIT-brightgreen.svg)](LICENSE)\n[![Build Status](https://travis-ci.org/moteus/lua-vararg.png?branch=master)](https://travis-ci.org/moteus/lua-vararg)\n[![Build status](https://ci.appveyor.com/api/projects/status/8lo89111mnndhdmx?svg=true)](https://ci.appveyor.com/project/moteus/lua-vararg)\n[![Coverage Status](https://coveralls.io/repos/moteus/lua-vararg/badge.png?branch=master)](https://coveralls.io/r/moteus/lua-vararg?branch=master)\n\n`vararg` is a Lua library for manipulation of variable arguements (vararg) of\nfunctions. These functions basically allow you to do things with vararg that\ncannot be efficiently done in pure Lua but can be easily done through the C API.\n\nActually, the main motivation for this library was the 'pack' function, which\nis an elegant alternative for the possible new standard function 'table.pack'\nand the praised 'apairs'. Also 'pack' allows an interesting implementaiton of\ntuples in pure Lua.\n\n## Changes since official `vararg` v1.1\n\n* C version supports Lua 5.2/5.3\n* Fix bugs on Lua version. Now it pass all tests.\n* Lua and C version are fully compatible (excapt error messages).\n* Use call metamethod as alias for pack method (`vararg(...)` is same as `vararg.pack(...)`)\n* Add `va.count` function\n* Add `va.at` function\n\n## pack\n\n`args = pack(...)`\n\n|    vararg           |      lua                  |\n|---------------------|---------------------------|\n| args()              | ...                       |\n| args(\"#\")           | select(\"#\", ...)          |\n| args(i)             | (select(i, ...))          |\n| args(i, j)          | unpack({...}, i, j)       |\n| for i,v in args do  | for i,v in ipairs{...} do |\n\n## vararg methods\n\nAssume this shortcuts\n```lua\ntremove = function(t, i)    table.remove(t, i)    return t end\ntinsert = function(t, i, v) table.insert(t, i, v) return t end\ntset    = function(t, i, v) t[i] = v              return t end\ntappend = function(t, v)    t[#t+1] = v           return t end\n```\n\n|    vararg          |      lua                                                 |\n|--------------------|----------------------------------------------------------|\n| count(...)         | select(\"#\", ...)                                         |\n| range(i, j, ...)   | unpack({...}, i, j)                                      |\n| at(i, ...)         | range(i, i, ...)                                         |\n| remove(i, ...)     | unpack(tremove({...},i),1,count(...)-1)                  |\n| insert(v, i, ...)  | unpack(tinsert({...},i,v),1,count(...)+1)                |\n| replace(v, i, ...) | unpack(tset({...}, i, v) t,1,count(...))                 |\n| append(v, ...)     | unpack(tappend({...},v),1,count(...)+1)                  |\n| map(f, ...)        | t={} for i, arg in pack(...) do t[i]=f(arg) end unpack(t)|\n| concat(f1,f2,...)  | return all the values returned by functions 'f1,f2,...'  |\n\n## Examples\n\nImplement basic `bind` function\n\n```Lua\nfunction bind(f, ...)\n  local args = va(...)\n  return function(...)\n    return f(va.concat(args, va(...))\n  end\nend\ndebug_print = bint(print, '[debug]')\ndebug_print('hello')\n```\n\nPack in to array returned values from several functions\n\n```Lua\nfunction f(...) return ... end\n\nt = {va.concat(\n  va(f(1,2,3)),\n  va(f(4,5,6)),\n)}\n\n-- t = {1,2,3,4,5,6}\n```\n\nWrite to stdout but convert values to string.\n```Lua\nfunction write(...)\n  return io.write(va.map(tostring, ...))\nend\n\nlocal hello = setmetatable({},{__tostring = function() return \"Hello\" end})\n\nwrite(hello, \" world!!! \", nil, '\\n')\n```\n\nParse IPv4 address\n```Lua\nlocal n1,n2,n3,n4 = va.map(tonumber, string.match(ip, \"^(%d+)%.(%d+)%.(%d+)%.(%d+)$\"))\n-- test nX as number\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoteus%2Flua-vararg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoteus%2Flua-vararg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoteus%2Flua-vararg/lists"}