login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Edit detail for ProgrammingSPAD revision 1 of 28

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
Editor: hemmecke
Time: 2014/02/14 00:14:18 GMT+0
Note:

changed:
-
A very brief introduction to programming in SPAD

  - SPAD is an ordinary programming language, just like C, Java, and Python.

  - SPAD programs are compiled to machine code by the SPAD compiler that comes with FriCAS.

  - SPAD is a statically typed language with type levels.

    1. **Elements**:  These are the basic data objects.
       Examples are: '42', '3.14159265', '"abc"', '[3,5,11]'.
       It is one one usually consideres as values in other programming languages.

    1. **Domains**: These are the types of elements.
       For example, 'Integer' is a type for '42', '3.14' is of type 'Float',
       '"abc"' is of type 'String', '[1,2,4,8]' is of type 'List(Integer)'.

       Domains are comparable to classes in object oriented programming languages.

    1. **Categories**: These are the types of domains.
       For example, 'Integer' is of type 'IntegerNumberSystem', 'String' is of type 'StringCategory',
       'List(Integer)' is of type 'ListAggregate(Integer)'.

       Categories are somewhat comparable to interfaces in Java, but are much more powerful.

    1. The highest type level is the constant keyword 'Category'.
       In other words, 'IntegerNumberSystem', 'StringCategory', 'ListAggregate(Integer)' are of
       type 'Category'.





\begin{spad}
)abbrev domain MINI MinimalInitialNotIntegrated
MinimalInitialNotIntegrated(x,F): Exports == Implementation where
    x: Symbol
    F: Field

    INT ==> Integer
    P ==> UnivariatePolynomial(x,F)
    FRP ==> Fraction P
    LFRP ==> List FRP

    Exports == with
      
       degreeX: % -> INT

    Implementation == add

       Rep := LFRP

       degreeX f ==
          a := [denom i for i in f::Rep]@List(P)  --  denom : FRAC UP -> UP(x,F)
          b := map(di +-> degree(di), a)$ListFunctions2(P, INT) -- degree : UP -> NonNegativeInteger
          --b := [degree i for i in a ]
          reduce( max, b ,0) :: INT
\end{spad}


A very brief introduction to programming in SPAD

  • SPAD is an ordinary programming language, just like C, Java, and Python.
  • SPAD programs are compiled to machine code by the SPAD compiler that comes with FriCAS?.
  • SPAD is a statically typed language with type levels.
    1. Elements: These are the basic data objects. Examples are: 42, 3.14159265, "abc", '[3,5,11]?'. It is one one usually consideres as values in other programming languages.
    2. Domains: These are the types of elements. For example, Integer is a type for 42, 3.14 is of type Float, "abc" is of type String, '[1,2,4,8]?' is of type List(Integer).

      Domains are comparable to classes in object oriented programming languages.

    3. Categories: These are the types of domains. For example, Integer is of type IntegerNumberSystem, String is of type StringCategory, List(Integer) is of type ListAggregate(Integer).

      Categories are somewhat comparable to interfaces in Java, but are much more powerful.

    4. The highest type level is the constant keyword Category. In other words, IntegerNumberSystem, StringCategory, ListAggregate(Integer) are of type Category.

spad
)abbrev domain MINI MinimalInitialNotIntegrated
MinimalInitialNotIntegrated(x,F): Exports == Implementation where
    x: Symbol
    F: Field
INT ==> Integer P ==> UnivariatePolynomial(x,F) FRP ==> Fraction P LFRP ==> List FRP
Exports == with
degreeX: % -> INT
Implementation == add
Rep := LFRP
degreeX f == a := [denom i for i in f::Rep]@List(P) -- denom : FRAC UP -> UP(x,F) b := map(di +-> degree(di), a)$ListFunctions2(P, INT) -- degree : UP -> NonNegativeInteger --b := [degree i for i in a ] reduce( max, b ,0) :: INT
spad
   Compiling FriCAS source code from file 
      /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/1973871146429693580-25px001.spad
      using old system compiler.
   MINI abbreviates domain MinimalInitialNotIntegrated 
------------------------------------------------------------------------
   initializing NRLIB MINI for MinimalInitialNotIntegrated 
   compiling into NRLIB MINI 
   compiling exported degreeX : $ -> Integer
Time: 0.05 SEC.
(time taken in buildFunctor: 0)
;;; *** |MinimalInitialNotIntegrated| REDEFINED
;;; *** |MinimalInitialNotIntegrated| REDEFINED Time: 0 SEC.
Cumulative Statistics for Constructor MinimalInitialNotIntegrated Time: 0.05 seconds
finalizing NRLIB MINI Processing MinimalInitialNotIntegrated for Browser database: --->-->MinimalInitialNotIntegrated(constructor): Not documented!!!! --->-->MinimalInitialNotIntegrated((degreeX ((Integer) %))): Not documented!!!! --->-->MinimalInitialNotIntegrated(): Missing Description ; compiling file "/var/aw/var/LatexWiki/MINI.NRLIB/MINI.lsp" (written 14 FEB 2014 12:14:19 AM):
; /var/aw/var/LatexWiki/MINI.NRLIB/MINI.fasl written ; compilation finished in 0:00:00.018 ------------------------------------------------------------------------ MinimalInitialNotIntegrated is now explicitly exposed in frame initial MinimalInitialNotIntegrated will be automatically loaded when needed from /var/aw/var/LatexWiki/MINI.NRLIB/MINI