{"id":21470738,"url":"https://github.com/nhpip/variadic-elixir","last_synced_at":"2025-03-17T06:44:44.933Z","repository":{"id":39704608,"uuid":"374821366","full_name":"nhpip/variadic-elixir","owner":"nhpip","description":"A simple implementation of Variadic functions in Elixir","archived":false,"fork":false,"pushed_at":"2022-06-24T20:36:28.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-23T16:13:48.113Z","etag":null,"topics":["elixir","variadic-function"],"latest_commit_sha":null,"homepage":"","language":"Elixir","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/nhpip.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":"2021-06-07T23:02:45.000Z","updated_at":"2022-06-24T20:09:03.000Z","dependencies_parsed_at":"2022-08-24T01:30:52.885Z","dependency_job_id":null,"html_url":"https://github.com/nhpip/variadic-elixir","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nhpip%2Fvariadic-elixir","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nhpip%2Fvariadic-elixir/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nhpip%2Fvariadic-elixir/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nhpip%2Fvariadic-elixir/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nhpip","download_url":"https://codeload.github.com/nhpip/variadic-elixir/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243988956,"owners_count":20379649,"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":["elixir","variadic-function"],"created_at":"2024-11-23T09:28:53.398Z","updated_at":"2025-03-17T06:44:44.911Z","avatar_url":"https://github.com/nhpip.png","language":"Elixir","readme":"# Variadic\n\nSimulates Variadic functions in Elixir (i.e functions with an unknown number of arguments)\n\nArguments will named `arg1, arg2....argN` where `N` is `@max_arity`.\n\nUninitialized arguments are set to the atom :no_args_at_this_position\n\n**NOTE:** Currently doesn't support guards in the function head\n\n## Example:\n\n```\n  defmodule MyTestModule do\n\n    import Variadic\n\n    ##\n    ## Functions are defined as defv (they will be public)\n    ##\n    defv :test_function do\n      # If arguments needed as a list or need arity then binding() should be the first thing called\n      arguments = args_to_list(binding())\n      work = arg1 + arg2\n      {arg1, arg2, arg3, arg4, work, arguments}\n    end\n\n    defv :other_function do\n      binding = binding()\n      ## Do work\n      x = 1 + 2 + 3\n      arguments = args_to_list(binding)\n      arity = get_arity(binding)\n      {arg1, arg2, x, [arity: arity, arguments: arguments]}\n    end\n  end\n```\nFrom the shell:\n```\n  Pass 3 arguments (note arg4 is nil):\n    iex(2)\u003e MyModule.test_function(1, 2, :hello)\n    {1, 2, :hello, :no_args_at_this_position, 3, [1, 2, :hello]}\n\n  Pass 10 arguments:\n    iex(3)\u003e MyModule.test_function(1, 2, :hello, 4, 5, 6, :bye, %{key: 123}, [771,\"something\"], 10)\n    {1, 2, :hello, 4, 3, [1, 2, :hello, 4, 5, 6, :bye, %{key: 123}, [771, \"something\"], 10]}\n\n  Show binding\n    iex(10)\u003e MyModule.other_function(777, 888, 999)\n    {777, 888, 6, [arity: 3, arguments: [777, 888, 999]]}\n```\n\nHelper functions: `get_arity/1` and `args_to_list/1`\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnhpip%2Fvariadic-elixir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnhpip%2Fvariadic-elixir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnhpip%2Fvariadic-elixir/lists"}