Acme-Pythonic
view release on metacpan or search on metacpan
- Documentation fixes.
- Added mention to Filter::ExtractSource in documentation.
0.40 Thu Jul 8 15:12:51 2004
- Documentation fixes and improvements.
- Tested in perl 5.8.4 (Mac OS X).
- LIMITATIONS revised.
0.33
- Minor documentation improvements.
- The section about labels was rewritten.
- Added Acme::Dot to SEE ALSO.
0.32 Sat Jun 19 16:09:44 2004
- Added OVERVIEW to POD.
- Minor documentation enhancements.
0.31 Sat Jun 12 14:58:32 2004
- Test::More required version relaxed to 0.45.
- Perl required version relaxed to 5.8.0.
# stuff
kind of constructions.
- Supports backslashes before a trailing comment, which is
more in the line of Perl forgiveness IMHO.
0.14
- "while:" is now correctly converted to "while ()"
- Added support for &-prototyped subroutines
0.13 Sun May 30 00:37:12 2004
- Added manhattan_intersection() implementation to t/algorithms.t
- Fixed: Broken code was being generated in lines with comments
following a Pythonic colon.
- Better conformance to perlstyle in some foreach patterns.
- Handling of continuation lines simplified.
0.12 Sat May 29 02:23:53 2004
- Added bubblesort in t/algorithms.t
- The code that inserts " {"s was breaking $#array, fixed.
- Changed SYNOPSIS.
- Fixed the documentation about backslashes in lines with comments.
t/algorithms.t view on Meta::CPAN
$$tree_link = $found->{right}
# ----------------------------------------------------------------------
#
# Now I will port the next subroutines meticulously from the listings in
# the book, respecting comments, whitespace, etc. Except in one place.
#
# ----------------------------------------------------------------------
# manhattan_intersection( @lines )
# Find the intersection of strictly horizontal and vertical lines.
# Requires basic_tree_add(), basic_tree_del(), and basic_tree_find(),
# all defined in Chapter 3, Advanced Data Structures
sub manhattan_intersection:
my @op # The coordinates are transformed here as operations.
while @_:
my @line = splice @_, 0, 4
if $line[1] == $line[3]: # Horizontal.
push @op, [ @line, \&range_check_tree ]
else:
# Swap if upside down.
@line = @line[0, 3, 2, 1] if $line[1] > $line[3]
push @op, [ @line[0, 1, 2, 1], \&basic_tree_add ]
push @op, [ @line[0, 3, 2, 3], \&basic_tree_del ]
my $x_tree # The range check tree.
# The x coordinate comparison routine.
my $compare_x = sub { $_[0]->[0] <=> $_[1]->[0] }
my @intersect # The intersections.
# We don't reproduce the multi-line here because parens are not put correctly.
foreach my $op in sort { $a->[1] <=> $b->[1] || $a->[4] == \&range_check_tree || $a->[0] <=> $b->[0] } @op:
if $op->[4] == \&range_check_tree:
push @intersect, $op->[4]->( \$x_tree, $op, $compare_x )
else: # Add or delete.
$op->[4]->( \$x_tree, $op, $compare_x )
return @intersect
#
# The implementation of range_check_tree() in the book is buggy, I
# submitted the bug to the authors.
#
# range_check_tree( $tree_link, $horizontal, $compare )
#
# Returns the list of tree nodes that are within the limits
t/algorithms.t view on Meta::CPAN
if $compare->( $horizontal_lo, $vertical_x ) <= 0 && \
$compare->( $horizontal_hi, $vertical_x ) >= 0
push @range, range_check_tree( \$node->{right}, $horizontal,
$compare ) \
if defined $node->{right}
return @range
my @lines = (0, 0, 0, 1)
is_deeply [manhattan_intersection(@lines)], []
@lines = (0, 0, 1, 0)
is_deeply [manhattan_intersection(@lines)], []
@lines = (0, 0, 1, 0, 0, 1, 1, 1, 0, 2, 1, 2)
is_deeply [manhattan_intersection(@lines)], []
@lines = (0, 0, 0, 1, 1, 0, 1, 1, 2, 0, 2, 1)
is_deeply [manhattan_intersection(@lines)], []
@lines = (0, 1, 2, 1, 1, 0, 1, 2)
is_deeply [manhattan_intersection(@lines)], [1, 1]
# This is the example in the book.
@lines = ( 1, 6, 1, 3, 1, 2, 3, 2, 1, 1, 4, 1,
2, 4, 7, 4, 3, 0, 3, 6, 4, 3, 4, 7,
5, 7, 5, 4, 5, 2, 7, 2 )
# And this is the correct answer, check Figure 10-10, which is right.
is_deeply [manhattan_intersection(@lines)], [3, 1, 3, 2, 5, 4, 4, 4, 3, 4]
( run in 0.692 second using v1.01-cache-2.11-cpan-39bf76dae61 )