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

fricas
)version
Value = "FriCAS 2013-04-06 compiled at Thursday April 25, 2013 at 18:12:03 "

spad
)abbrev package MYRED MyReduce
MyReduce(S:Type): with
    myred: ((S,S)->S,List S) -> S
 == add
   -- Waldek's local helper function
   ((f:(S,S)->S) = (g:(S,S)->S)):Boolean ==
      print(coerceMap2E(f)$Lisp::OutputForm)
      print(coerceMap2E(g)$Lisp::OutputForm)
      EQ(f,g)$Lisp
   --
   import NonNegativeInteger
   myred(f:(S,S)->S, x:List S):S ==
     if #x>1 then
       f(first x, myred(f,rest x))
     else if #x=1 then
       first x
     else
       if S has AbelianMonoid then
         -- Must force "newGoGet" by applying operations before comparison!
         f(0,0)=(0+0)$S and (f = _+$S) => return 0$S
         -- (f = _+$S) => return 0$S
       if S has Monoid then
         f(1,1)=(1*1)$S and (f = _*$S) => return 1$S
         -- (f = _*$S) => return 1$S
       error "reducing over an empty list needs the 3 argument form"
spad
   Compiling FriCAS source code from file 
      /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/3864115453202676649-25px002.spad
      using old system compiler.
   MYRED abbreviates package MyReduce 
------------------------------------------------------------------------
   initializing NRLIB MYRED for MyReduce 
   compiling into NRLIB MYRED 
   compiling local = : ((S,S) -> S,(S,S) -> S) -> Boolean
Time: 0 SEC.
importing NonNegativeInteger compiling exported myred : ((S,S) -> S,List S) -> S ****** Domain: S already in scope augmenting S: (AbelianMonoid) ****** Domain: S already in scope augmenting S: (Monoid) Time: 0.02 SEC.
(time taken in buildFunctor: 0)
;;; *** |MyReduce| REDEFINED
;;; *** |MyReduce| REDEFINED Time: 0 SEC.
Cumulative Statistics for Constructor MyReduce Time: 0.02 seconds
finalizing NRLIB MYRED Processing MyReduce for Browser database: --->-->MyReduce(constructor): Not documented!!!! --->-->MyReduce((myred (S (Mapping S S S) (List S)))): Not documented!!!! --->-->MyReduce(): Missing Description ; compiling file "/var/aw/var/LatexWiki/MYRED.NRLIB/MYRED.lsp" (written 09 MAY 2013 04:01:09 PM):
; /var/aw/var/LatexWiki/MYRED.NRLIB/MYRED.fasl written ; compilation finished in 0:00:00.031 ------------------------------------------------------------------------ MyReduce is now explicitly exposed in frame initial MyReduce will be automatically loaded when needed from /var/aw/var/LatexWiki/MYRED.NRLIB/MYRED

fricas
myred(+,[1,2,3,4])

\label{eq1}10(1)
fricas
myred(+,[]$List Integer)
theMap(INT;+;3$;38,303) theMap(INT;+;3$;38,303)

\label{eq2}0(2)
fricas
myred(*,[1,2,3,4])

\label{eq3}24(3)
fricas
myred(*,[]$List Integer)
theMap(INT;*;3$;41,303) theMap(INT;+;3$;38,303) theMap(INT;*;3$;41,303) theMap(INT;*;3$;41,303)

\label{eq4}1(4)

Waldek writes:

Problem with recompilation.

fricas
eq((f:(INT,INT)->INT),(g:(INT,INT)->INT)):Boolean ==
      print(coerceMap2E(f)$Lisp::OutputForm)
      print(coerceMap2E(g)$Lisp::OutputForm)
      not null? EQ(f,g)$Lisp
Function declaration eq : (((Integer,Integer) -> Integer),((Integer, Integer) -> Integer)) -> Boolean has been added to workspace.
Type: Void
fricas
f1 := _+$Integer @ Mapping(Integer, Integer, Integer)

\label{eq5}\mbox{theMap (...)}(5)
Type: ((Integer,Integer) -> Integer)
fricas
f2 := _+$Integer @ Mapping(Integer, Integer, Integer)

\label{eq6}\mbox{theMap (...)}(6)
Type: ((Integer,Integer) -> Integer)
fricas
eq(f1,f2)
fricas
Compiling function eq with type (((Integer,Integer) -> Integer),((
      Integer,Integer) -> Integer)) -> Boolean 
   (theMap INT;+;3$;38 303)
   (theMap INT;+;3$;38 303)

\label{eq7} \mbox{\rm true} (7)
Type: Boolean

FOO has nothing to do with Integer:

spad
)abbrev category FOO FOO
FOO(): Category == with ()
spad
   Compiling FriCAS source code from file 
      /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/4158498938098016222-25px005.spad
      using old system compiler.
   FOO abbreviates category FOO 
------------------------------------------------------------------------
   initializing NRLIB FOO for FOO 
   compiling into NRLIB FOO 
;;; *** FOO REDEFINED Time: 0 SEC.
finalizing NRLIB FOO Processing FOO for Browser database: --->-->FOO(): Missing Description ; compiling file "/var/aw/var/LatexWiki/FOO.NRLIB/FOO.lsp" (written 09 MAY 2013 04:01:09 PM):
; /var/aw/var/LatexWiki/FOO.NRLIB/FOO.fasl written ; compilation finished in 0:00:00.005 ------------------------------------------------------------------------ FOO is now explicitly exposed in frame initial FOO will be automatically loaded when needed from /var/aw/var/LatexWiki/FOO.NRLIB/FOO

but mere fact that I compiled FOO invalidates all domain vectors...

fricas
g := _+$Integer @ Mapping(Integer, Integer, Integer)

\label{eq8}\mbox{theMap (...)}(8)
Type: ((Integer,Integer) -> Integer)
fricas
eq(f1,g)
(theMap INT;+;3$;38 303) (theMap INT;+;3$;38 303)

\label{eq9} \mbox{\rm false} (9)
Type: Boolean
fricas
f1(1,2)

\label{eq10}3(10)
fricas
g(1,2)

\label{eq11}3(11)

Note: Both functions f1 and g point to the same function although the names have changed.




  Subject:   Be Bold !!
  ( 13 subscribers )  
Please rate this page: