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

Edit detail for SandBoxMyReduce revision 10 of 14

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

changed:
-   F ==> (S,S)->S
-   ((f:F)=(g:F)):Boolean ==
   ((f:(S,S)->S) = (g:(S,S)->S)):Boolean ==

changed:
-myred(+,[1,2,3])
myred(+,[1,2,3,4])

changed:
-myred(*,[1,2,3])
myred(*,[1,2,3,4])

\begin{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
   --
   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)=(11)$S and (f = _$S) => return 1$S
       error "reducing over an empty list needs the 3 argument form"
     reduce(f, rest x, first x)
\end{spad}

\begin{axiom} myred(+,[1,2,3,4]) myred(+,[])$MyReduce(Integer) myred(*,[1,2,3,4]) myred(*,[])$MyReduce(Integer)

\end{axiom}


Some or all expressions may not have rendered properly, because Axiom returned the following error:
Error: export AXIOM=/usr/local/lib/open-axiom/x86_64-unknown-linux/1.1.0-2008-01-28; export ALDORROOT=/usr/local/aldor/linux/1.1.0; export PATH=$ALDORROOT/bin:$PATH; export HOME=/var/zope2/var/LatexWiki; ulimit -t 240; export LD_LIBRARY_PATH=/usr/local/lib/open-axiom/x86_64-unknown-linux/1.1.0-2008-01-28/lib; LANG=en_US.UTF-8 $AXIOM/bin/AXIOMsys < /var/zope2/var/LatexWiki/3625091118742662539-25px.axm
/bin/sh: /usr/local/lib/open-axiom/x86_64-unknown-linux/1.1.0-2008-01-28/bin/AXIOMsys: not found


Some or all expressions may not have rendered properly, because Latex returned the following error:
! Missing $ inserted.
<inserted text> 
                $
l.137          f(0,0)=(0+0)$S and (f = _
                                        +$S) => return 0$S
 Missing $ inserted.
<inserted text> 
                $
l.139          f(1,1)=(11)$S and (f = _
                                        $S) => return 1$S
 Missing $ inserted.
<inserted text> 
                $
l.142 \end{spad}
                \newpage

Overfull \hbox (194.33705pt too wide) in paragraph at lines 123--142 \T1/cmr/m/n/12 EQ(f,g)$\OML/cmm/m/it/12 Lisp \OMS/cmsy/m/n/12 ^^@ ^^@\OML/cmm/m /it/12 myred\OT1/cmr/m/n/12 (\OML/cmm/m/it/12 f \OT1/cmr/m/n/12 : (\OML/cmm/m/i t/12 S; S\OT1/cmr/m/n/12 )\OMS/cmsy/m/n/12 ^^@ \OML/cmm/m/it/12 > S; x \OT1/cmr /m/n/12 : \OML/cmm/m/it/12 ListS\OT1/cmr/m/n/12 ) : \OML/cmm/m/it/12 S \OT1/cmr /m/n/12 == \OML/cmm/m/it/12 ifempty\OT1/cmr/m/n/12 ?