p2-fox

Download the raw code.

#
# point in polygon test 
# here I'm using a ray casting algorithm adapted(read perl6-ed) from
# the implementation of W. Randolph Franklin:
# http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
#

my @points = gather for $*IN.get.split(/\s+/) -> $p { take [$p.split(/\,/)] };
my ($x, $y) = $*IN.get.split(/\,/);

exit say "invalid input" unless @points > 0 and $x.defined and $y.defined;

say
( [+] gather for @points Z @points[1..*-1,0] -> $a, $b {
        take 1
        if ($a[1] > $y xor $b[1] > $y) and
                ($x < ($b[0]-$a[0]) * ($y-$a[1]) / ($b[1]-$a[1]) + $a[0])
}) % 2 ?? "yes" !! "no"

Readability

The code is easy to take in.

Consistency

To the extent it's applicable, yes.

Clarity of intent

I'm pretty sure the reasoning around lines 17-18 is correct, but... it's not self-documenting. Good thing the web page mentioned has a bit more.

Algorithmic efficiency

Not really a concern with this task. It's fast enough, OK?

Idiomatic use of Perl 6

It might look like gather might automatically constitute an idiomatic use of Perl 6... but the first (line 9) looks to me like it should have been a map, and the second (line 15) a grep.

The [+] on line 15 is nice, but... slightly overkill. All we want is the number of elements, because these are all 1.

Brevity

Again, fox is way ahead in this particular regard.