Below there is a function which generates Pascal triangle by iteratively filling rows of a matrix using recurence formula. Spad array indexing is one based, so we cheat and add 1 to indices. fricas (1) -> <spad> fricas )abbrev package PASCAL Pascal Pascal : with ( make_pascal : Integer -> Matrix(Integer) ) == add make_pascal(N : Integer) : Matrix(Integer) == -- coerce here to NonNegativeInteger because this is what -- 'zero' requires nn := N::NonNegativeInteger tab := zero(nn, fricas Compiling FriCAS source code from file /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/1379180095272779836-25px001.spad using old system compiler. PASCAL abbreviates package Pascal ------------------------------------------------------------------------ initializing NRLIB PASCAL for Pascal compiling into NRLIB PASCAL compiling exported make_pascal : Integer -> Matrix Integer Time: 0.02 SEC. Try it out: fricas make_pascal(5)
Type: Matrix(Integer)
See also PascalTriangleNopile. |