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

From ZCubes Wiki
Jump to navigation Jump to search
 
(3 intermediate revisions by one other user not shown)
Line 8: Line 8:
 
<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==
+
==Code-Pascal vs Sierpinski Triangle==
m=10;
+
    m=10;
pt=PASCALTRIANGLE(m);
+
    pt=PASCALTRIANGLE(m);
a=pt
+
    a=pt
    .map(
+
      .map(
    function(r,i)
+
        function(r,i)
    {
+
        {
 
           var prefix=(REPEATCHAR(" ",(2*m-(2*i+1))/2).split(""));
 
           var prefix=(REPEATCHAR(" ",(2*m-(2*i+1))/2).split(""));
 
             return(
 
             return(
Line 20: Line 20:
 
                   .concat(r.join(", ,").split(","))
 
                   .concat(r.join(", ,").split(","))
 
                   .concat(prefix)
 
                   .concat(prefix)
            )
+
            )
      }
+
        }
    );
+
      );
(a);
+
  (a);
  
  
m=32;
+
  m=32;
pt=PASCALTRIANGLE(m);
+
  pt=PASCALTRIANGLE(m);
  
m=10;
+
  m=10;
pt=PASCALTRIANGLE(m).$(x=>x%2)
+
  pt=PASCALTRIANGLE(m).$(x=>x%2)
a=pt
+
  a=pt
    .map(
+
      .map(
    function(r,i)
+
      function(r,i)
    {
+
      {
 
           var prefix=(REPEATCHAR(" ",(2*m-(2*i+1))/2).split(""));
 
           var prefix=(REPEATCHAR(" ",(2*m-(2*i+1))/2).split(""));
 
             return(
 
             return(
Line 43: Line 43:
 
       }
 
       }
 
     );
 
     );
(a);
+
  (a);
  
m=32;
 
  
m=64;
+
  m=64;
  
==Code==
 
<pre>
 
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);
 
</pre>
 
  
<<[[ZCubes_Videos#ZCubes_Videos_List | ZCubes Videos ]]
 
 
<br/>
 
<br/>
<<[[Main_Page | About ZCubes ]]
+
*[[Z3 | Z3 home]]
 
+
*[[Z^3 Language Documentation]]
 +
*[[ZCubes_Videos | ZCubes Videos and Tutorials]]
 +
*[[Main_Page | About ZCubes ]]
 +
<br/>
 
<br/>
 
<br/>
&copy; Copyright 1996-2020, ZCubes, Inc.
+
&copy; Copyright 1996-2021, ZCubes, Inc.

Latest revision as of 00:08, 11 March 2021

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-Pascal vs Sierpinski Triangle

   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=64;





© Copyright 1996-2021, ZCubes, Inc.