Moose:...::Code(3pm)

πŸ“¦
version 0.16 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Moose:...::Code(3pm) πŸ’–

okay so bestie, you're reading a page from the User Contributed Perl Documentation collection, and the star of the show is Moose::...::Code. pull up a chair, grab a boba, we're doing this πŸ§‹βœ¨


🌸 NAME 🌸

Moose::Autobox::Code β€” it's the Code role, periodt πŸ’…


✨ VERSION ✨

version 0.16 β€” she's vintage, she's iconic, she's been here πŸ‘‘


πŸ¦‹ SYNOPSIS πŸ¦‹

here's the vibe, copy-paste-able and everything:

use Moose::Autobox;

my $adder = sub { $_[0] + $_[1] };
my $add_2 = $adder->curry(2);

$add_2->(2); # returns 4

# create a recursive subroutine
# using the Y combinator
*factorial = sub {
    my $f = shift;
    sub {
        my $n = shift;
        return 1 if $n < 2;
        return $n * $f->($n - 1);
    }
}->y;

factorial(10) # returns 3628800

not the Y combinator making factorial(10) pop off with 3628800 😭πŸ”₯ math ate and left no crumbs fr fr


🌈 DESCRIPTION 🌈

so basically? this is a role β€” and what it does is describe operations on the Code type. that's the whole assignment. she's a role about Code things. slay πŸ’œ


πŸŽ€ METHODS πŸŽ€

here's the full roster, no skips, no cuts, we love a complete list:

  • "curry (@values)"
  • "rcurry (@values)"
  • "conjoin (\&sub)"
  • "disjoin (\&sub)"
  • "compose (@subs)" β€” okay so THIS one comes with lore: it takes a list of @subs and composes them all into a single subroutine, where the output of one sub becomes the input of another. it's giving assembly line but make it fancy 🏭✨
  • "y" β€” this implements the Y combinator. yes, that Y combinator. main character energy fr 🫢
  • "u" β€” and this one implements the U combinator. the sequel nobody asked for but everybody needed πŸ’€
  • "meta" β€” that's it. that's the method. she said "meta" and left πŸ™ˆ
ngl bestie, the source page keeps it cute and mysterious for a few of these β€” the names are all we get, so I'm not gonna sit here and make stuff up about them. iykyk 😌

⭐ SEE ALSO ⭐

go touch some grass, but like, scholarly grass:


πŸ’œ SUPPORT πŸ’œ

got bugs? first of all, relatable. second of all, here's where they go:

come hang, we don't bite 🫢


🌸 AUTHOR 🌸

Stevan Little <stevan.little@iinteractive.com> β€” thank you for your service, king πŸ‘‘


This software is copyright (c) 2006 by Infinity Interactive, Inc.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


and that's the whole page, bestie!! this one was rendered under perl v5.34.0, dated 2022-06-15, and the page itself is Moose:...::Code(3pm) β€” same energy, same facts, just with way better vibes πŸ’–βœ¨ mwah, go write some curried subs, ily πŸ«ΆπŸŽ€
πŸ“¦ where this page comes from