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

Edit detail for SandBoxMyReduce revision 11 of 14

1 2 3 4 5 6 7 8 9 10 11 12 13 14
Editor: Bill Page
Time: 2008/04/07 21:10:30 GMT-7
Note: Waldek's function

changed:
-myred(+,[])$MyReduce(Integer)
myred(+,[]$List Integer)

changed:
-myred(*,[])$MyReduce(Integer)
myred(*,[]$List Integer)

fricas
(1) -> <spad>
fricas
)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
   --
   myred(f:(S,S)->S, x:List S):S ==
     if empty? x then
       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
       if S has Monoid then
         f(1,1)=(1*1)$S and (f = _*$S) => return 1$S
       error "reducing over an empty list needs the 3 argument form"
     reduce(f, rest x, first x)</spad>
fricas
Compiling FriCAS source code from file 
      /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/4801885550606007333-25px001.spad
      using system compiler.
   MYRED abbreviates package MyReduce 
------------------------------------------------------------------------
   initializing NRLIB MYRED for MyReduce 
   compiling into NRLIB MYRED 
   compiling local = : ((S,S) -> S,(S,S) -> S) -> Boolean
      MYRED;= is replaced by EQ 
Time: 0 SEC.
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.01 SEC.
(time taken in buildFunctor: 0) Time: 0 SEC.
Cumulative Statistics for Constructor MyReduce Time: 0.01 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 22 OCT 2026 11:08:24 PM):
; wrote /var/aw/var/LatexWiki/MYRED.NRLIB/MYRED.fasl ; compilation finished in 0:00:00.016 ------------------------------------------------------------------------ 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)
Type: PositiveInteger?
fricas
myred(+,[]$List Integer)

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

\label{eq3}24(3)
Type: PositiveInteger?
fricas
myred(*,[]$List Integer)

\label{eq4}1(4)
Type: PositiveInteger?