{"id":21951864,"url":"https://github.com/oodler577/p5-dispatch-fu","last_synced_at":"2025-03-22T17:48:14.816Z","repository":{"id":183388079,"uuid":"670057765","full_name":"oodler577/p5-Dispatch-Fu","owner":"oodler577","description":"O(1)ish solution to Perl's given/when or match/case, convert familiar static hash-key based dispatch","archived":false,"fork":false,"pushed_at":"2024-02-19T00:17:29.000Z","size":332,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-03T22:39:06.378Z","etag":null,"topics":["perl"],"latest_commit_sha":null,"homepage":"https://metacpan.org/dist/Dispatch-Fu","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oodler577.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-07-24T07:48:07.000Z","updated_at":"2024-08-26T07:03:03.000Z","dependencies_parsed_at":"2023-10-01T00:22:36.928Z","dependency_job_id":"76242212-3248-45ce-91fa-d1e392013787","html_url":"https://github.com/oodler577/p5-Dispatch-Fu","commit_stats":null,"previous_names":["oodler577/p5-dispatch-fu"],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oodler577%2Fp5-Dispatch-Fu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oodler577%2Fp5-Dispatch-Fu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oodler577%2Fp5-Dispatch-Fu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oodler577%2Fp5-Dispatch-Fu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oodler577","download_url":"https://codeload.github.com/oodler577/p5-Dispatch-Fu/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244999230,"owners_count":20544866,"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":["perl"],"created_at":"2024-11-29T06:17:46.702Z","updated_at":"2025-03-22T17:48:14.790Z","avatar_url":"https://github.com/oodler577.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"# p5-Dispatch-Fu\n\nThis is currently the proof of concept of an idea I had to solve\ngenerally the given/when or so-called \"smart match' problem by offering\na syntax (thanks again to Perl's prototype coercions) that semantically\nallow one to deduce any set of values into a static key according to\na custom reduction operation they create; then use that key to do an O(1)\ndispatch.\n\nThe solution is tiny and uses the accumlator nature of prototypes. All\ncomplexity is offloaded to the custom implemention of the `fu` block.\nAssuming the `fu` block is fast, the entire dispatch will be fast.\n\n```\nuse strict;\nuse warnings;\nuse Dispatch::Fu;    # exports 'fu' and 'on'\n\nmy $bar = [qw/1 2 3 4 5/];\n\nfu {\n    # here, give a reference $bar of any kind,\n    # you compute a static string that is added\n    # via the 'on' keyword; result will be\n    # 'bucket' + some number in in 0-5\n\n    my $baz = shift;\n    return ( scalar @$baz \u003e 5 )\n      ? q{bucket5}\n      : sprintf qq{bucket%d}, scalar @$baz;\n}\n$bar,\n  on bucket0 =\u003e sub { print qq{bucket 0\\n} },\n  on bucket1 =\u003e sub { print qq{bucket 1\\n} },\n  on bucket2 =\u003e sub { print qq{bucket 2\\n} },\n  on bucket3 =\u003e sub { print qq{bucket 3\\n} },\n  on bucket4 =\u003e sub { print qq{bucket 4\\n} },\n  on bucket5 =\u003e sub { print qq{bucket 5\\n} };\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foodler577%2Fp5-dispatch-fu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foodler577%2Fp5-dispatch-fu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foodler577%2Fp5-dispatch-fu/lists"}