Skip to content

Instantly share code, notes, and snippets.

@gfldex
Created October 13, 2024 03:24
Show Gist options
  • Save gfldex/c54be3c0967ba8c173ac65eb1bb3a2b8 to your computer and use it in GitHub Desktop.
Save gfldex/c54be3c0967ba8c173ac65eb1bb3a2b8 to your computer and use it in GitHub Desktop.
use v6.d;
enum Meat <Chicken Beef Pork Fish Veggie>;
enum Ingredient <Cheese Rice Beans Salsa Guacamole SourCream Lettuce Tomato Onion Cilantro PicoDeGallo>;
subset Burritoish where Meat | Ingredient;
sub return-burrito($meat, @ingredients) {
$meat, @ingredients
}
sub tortilla {
return-burrito(Veggie, [])
}
sub add-meat(Meat $meat, [$, @ingredients]) {
$meat, @ingredients
}
sub add-mission-burrito-ingredients([$meat, @ingredients]) {
$meat, ( (Cheese, Rice, Beans) ∪ @ingredients ).keys.Array
}
sub add-ingredient($ingredient, ($meat, @ingredients)) {
$meat, (@ingredients ∪ $ingredient).keys.Array
}
sub hold-the($ingredient, [$meat, @ingredients]) {
$meat, (@ingredients ∖ $ingredient).keys.Array
}
multi infix:«>>=»(\burrito, &f) is looser(&infix:<,>) {
}
tortilla()
==> add-meat Chicken
==> add-mission-burrito-ingredients()
==> hold-the Cheese
==> add-ingredient Salsa
==> put();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment