Difference between revisions of "ZCubes/Pascal vs Sierpinski Triangle"

From ZCubes Wiki
Jump to navigation Jump to search
Line 7: Line 7:
 
{{#ev:youtube|9w1SL6y46wA|480|left|Pascal vs Sierpinski Triangle}}
 
{{#ev:youtube|9w1SL6y46wA|480|left|Pascal vs Sierpinski Triangle}}
 
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
 
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
 +
 +
==Code==
 +
m=10;
 +
pt=PASCALTRIANGLE(m);
 +
a=pt
 +
    .map(
 +
    function(r,i)
 +
    {
 +
          var prefix=(REPEATCHAR(" ",(2*m-(2*i+1))/2).split(""));
 +
            return(
 +
                prefix
 +
                  .concat(r.join(", ,").split(","))
 +
                  .concat(prefix)
 +
            )
 +
      }
 +
    );
 +
(a);
 +
 +
 +
m=32;
 +
pt=PASCALTRIANGLE(m);
 +
 +
m=10;
 +
pt=PASCALTRIANGLE(m).$(x=>x%2)
 +
a=pt
 +
    .map(
 +
    function(r,i)
 +
    {
 +
          var prefix=(REPEATCHAR(" ",(2*m-(2*i+1))/2).split(""));
 +
            return(
 +
                prefix
 +
                  .concat(r.join(", ,").split(","))
 +
                  .concat(prefix)
 +
            )
 +
      }
 +
    );
 +
(a);
 +
 +
m=32;
 +
 +
m=64;
  
 
==Code==
 
==Code==

Revision as of 04:39, 18 August 2020

Pascal vs Sierpinski Triangle


This video demonstrates how to generate Pascal triangle in Z and derive Sierpinski triangle from Pascal triangle in ZCubes.

Video


Pascal vs Sierpinski Triangle














Code

m=10; pt=PASCALTRIANGLE(m); a=pt

   .map(
    function(r,i)
    {
         var prefix=(REPEATCHAR(" ",(2*m-(2*i+1))/2).split(""));
           return(
                prefix
                 .concat(r.join(", ,").split(","))
                 .concat(prefix)
           )
      }
   );

(a);


m=32; pt=PASCALTRIANGLE(m);

m=10; pt=PASCALTRIANGLE(m).$(x=>x%2) a=pt

   .map(
    function(r,i)
    {
         var prefix=(REPEATCHAR(" ",(2*m-(2*i+1))/2).split(""));
           return(
                prefix
                 .concat(r.join(", ,").split(","))
                 .concat(prefix)
           )
      }
   );

(a);

m=32;

m=64;

Code

 m=32;
 pt=PASCALTRIANGLE(m).$(x=>x%2)
 a=pt
 .map(function (r,i) {
    var prefix= (REPEATCHAR(" ",(2*m-(2*i+1))/2).split(""));
    return(
        prefix
        .concat(r.join(", ,").split(","))
        .concat(prefix)
       )
   }
  );
 (a);

<< ZCubes Videos
<< About ZCubes


© Copyright 1996-2020, ZCubes, Inc.