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

Edit detail for SandBoxMyReduce revision 13 of 14

1 2 3 4 5 6 7 8 9 10 11 12 13 14
Editor: Bill Page
Time: 2008/04/08 15:26:45 GMT-7
Note: OpenAxiom version

added:

From BillPage Tue Apr 8 15:26:44 -0700 2008
From: Bill Page
Date: Tue, 08 Apr 2008 15:26:44 -0700
Subject: OpenAxiom version
Message-ID: <20080408152644-0700@axiom-wiki.newsynthesis.org>

SandBoxMyReduceInOpenAxiom

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 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"
spad
   Compiling OpenAxiom source code from file 
      /var/zope2/var/LatexWiki/4005334095377159465-25px001.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
      MYRED;= is replaced by EQ 
Time: 0.01 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.14 SEC.
(time taken in buildFunctor:  0)
;;;     ***       |MyReduce| REDEFINED
;;;     ***       |MyReduce| REDEFINED
Time: 0 SEC.
   Cumulative Statistics for Constructor MyReduce
      Time: 0.15 seconds
   finalizing NRLIB MYRED 
   Processing MyReduce for Browser database:
--->-->MyReduce((myred (S (Mapping S S S) (List S)))): Not documented!!!!
--->-->MyReduce(constructor): Not documented!!!!
--->-->MyReduce(): Missing Description
------------------------------------------------------------------------
   MyReduce is now explicitly exposed in frame initial 
   MyReduce will be automatically loaded when needed from 
      /var/zope2/var/LatexWiki/MYRED.NRLIB/code

axiom
myred(+,[1,2,3,4])
LatexWiki Image(1)
Type: PositiveInteger?
axiom
myred(+,[]$List Integer)
LatexWiki Image(2)
Type: NonNegativeInteger?
axiom
myred(*,[1,2,3,4])
LatexWiki Image(3)
Type: PositiveInteger?
axiom
myred(*,[]$List Integer)
LatexWiki Image(4)
Type: PositiveInteger?

OpenAxiom? version --Bill Page, Tue, 08 Apr 2008 15:26:44 -0700 reply
SandBoxMyReduceInOpenAxiom?