{"id":15510672,"url":"https://github.com/dalen/puppet-defn","last_synced_at":"2025-04-05T07:24:17.322Z","repository":{"id":13696818,"uuid":"16390666","full_name":"dalen/puppet-defn","owner":"dalen","description":"Puppet function to define Puppet functions in Puppet","archived":false,"fork":false,"pushed_at":"2014-10-28T12:08:00.000Z","size":156,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-10T15:15:19.727Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","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/dalen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-30T20:57:21.000Z","updated_at":"2014-10-28T12:08:00.000Z","dependencies_parsed_at":"2022-09-10T12:10:18.967Z","dependency_job_id":null,"html_url":"https://github.com/dalen/puppet-defn","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalen%2Fpuppet-defn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalen%2Fpuppet-defn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalen%2Fpuppet-defn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalen%2Fpuppet-defn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dalen","download_url":"https://codeload.github.com/dalen/puppet-defn/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247301791,"owners_count":20916581,"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":[],"created_at":"2024-10-02T09:50:20.391Z","updated_at":"2025-04-05T07:24:17.294Z","avatar_url":"https://github.com/dalen.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"A Puppet function to define Puppet functions in Puppet\n======================================================\n\nRequires the future parser to work.\n\nExample:\n--------\n\n    defn(higher) |$a,$b| { if $a \u003e $b { $a } else { $b } }\n    notice(higher(3,2))\n\n*Output:* 3\n\nQuicksort example:\n------------------\n\n```puppet\nclass quicksort {\n  $size=lambda() |$list| {\n    reduce($list,0) |$a,$b| {\n      $a+1\n    }\n  }\n  $sort=lambda() |$list| {\n    if apply($size,[$list]) \u003e 2 {\n      $pivot=$list[apply($size,[$list])/2]\n      apply($sort,[filter($list) |$i| { $i \u003c $pivot }]) + $same + apply($sort,[])\n      $low=filter($list) |$i| {\n        $i \u003c $pivot\n      }\n      $high=filter($list) |$i| {\n        $i \u003e $pivot\n      }\n      $same=filter($list) |$i| {\n        $i == $pivot\n      }\n    } elsif apply($size,[$list]) == 2 {\n      if $list[0] \u003e $list[1] {\n        [$list[1], $list[0]]\n      } else {\n        $list\n      }\n    } else {\n      $list\n    }\n  }\n}\n\ninclude quicksort\napply($quicksort::sort, [[3,7,4,8,6]]).each |$i| { notice($i) }\n```\n\nKnown issues\n------------\n\nNesting defn statements or referencing variables from outside of the block can\nlead to undefined behaviour.\n\nAlso closures aren't supported by Puppet with lambdas.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdalen%2Fpuppet-defn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdalen%2Fpuppet-defn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdalen%2Fpuppet-defn/lists"}