Skip to content

Instantly share code, notes, and snippets.

@awwaiid
Created February 10, 2014 19:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awwaiid/8922231 to your computer and use it in GitHub Desktop.
Save awwaiid/8922231 to your computer and use it in GitHub Desktop.
use HOI::Match;
psub point_extract =>
"point (x _) :: r" => sub { my %args = @_; $args{x} + point_extract($args{r}) },
"nil" => sub { 0 };
point_extract(
[
{"type" => "point", "val" => [ 1, 2 ]},
{"type" => "point", "val" => [ 2, 4 ]},
{"type" => "point", "val" => [ 3, 6 ]},
]
) # we will get 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment