in reply to Equilateral Pascal's Triangle in perltex

This might help you:

Pascal's Triangle. It has a couple of interactive versions that'll help you visualize what's going on.

Update: I've been looking for a couple of hours, just to satisfy my curiosity, and I finally found it. See Tie::Math under the "How about Pascal's Triangle" section:

#!/usr/bin/perl use Tie::Math qw(f X Y); my %pascal; tie %pascal, 'Tie::Math', sub { if( X <= Y and Y > 0 and X > 0 ) { f(X,Y) = f(X-1,Y-1) + f(X,Y-1); } else { f(X,Y) = 0; } }, sub { f(1,1) = 1; f(1,2) = 1; f(2,2) = 1; }; #'# my $height = 5; for my $y (1..$height) { print " " x ($height - $y); for my $x (1..$y) { print $pascal{$x,$y}; } print "\n"; }

Update: fixed, added comma after "Tie::Math" line 6 and right curly on line 12.

Replies are listed 'Best First'.
Re^2: Equilateral Pascal's Triangle in perltex
by Coach (Initiate) on Jun 02, 2009 at 04:33 UTC
    Thank you everyone for your helpful advice! However, I am still struggling. I should have perhaps made my level of abilities more clear: when it comes to perl, I know absolutely nothing! The only thing I know is, that one is supposed stick the code into a text editor, stick the LaTeX commands around it, and then run it with perltex. Evidently, with code posted by Perlbotics, I am supposed to do something far more advanced?
      Back to my suggestion of using an advanced Canvas type widget.........

      On most canvases you can rotate items, so imagine this construction technique for equilateral triangles.

      Create 3 identical line segments, stacked right on top of each other. Leave the bottom segment as is. The next segment is then rotated around its left end point, x degrees, in a counterclockwise direction. The last segment is rotated clockwise around its right endpoint, x degrees.

      The whole segment set can be a "group", and the resulting triangle can be translated (moved) as a group, and rotated to any angle.

      Calculating the x degree value depends on the original line segment lengths chosen, and can be calculated with some simple trig. Of course, for an equilateral triangle, it's just 60 degrees.

      BTW, Coach, are you trying to find a way to make "play diagrams" for a team? :-) If so, you might want to check out Tk Patio/Office layout designer


      I'm not really a human, but I play one on earth.
      Old Perl Programmer Haiku
        No, I'm just a really lost high school math student struggling to complete my maths paper. Thank you all for your contributions. I managed to get the triangle to work, but now the page is not large enough to fit all of the fifteen rows.
        zentara++. It works great, and its the simplest way that I've found to make equilateral triangles.