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

Edit detail for SandBox Aldor Generator revision 2 of 2

1 2
Editor: 127.0.0.1
Time: 2007/11/11 11:32:05 GMT-8
Note: transferred from axiom-developer


        

Aldor has generators:

http://www.aldor.org/docs/HTML/chap9.html
In fact, this form of using generators is so common, that if the expression E in for v in E. does not belong to a generator type, then an implicit call is made to an appropriate generator function. This is equivalent to writing for v in generator E.

The Aldor/Axiom interface provides such a generator for the Axiom Vector type. Let's try it.

More space? I am not sure why but it seems that I must increase GCL memory allocation to make this work. \begin{axiom} )lisp (si::allocate-contiguous-pages 1500 t) )lisp (si::allocate 'sfun 50 t) \end{axiom}

\begin{aldor} #include "axiom"

myList(v:Vector Integer):List Integer == [ i for i in v ]; \end{aldor}

\begin{axiom} V:Vector Integer:=[1,2,3] myList(V) \end{axiom} Space left? \begin{axiom} )lisp (room) \end{axiom}

Re: aldor stream oddities --Bill Page, Thu, 09 Aug 2007 10:53:09 -0500 reply
On Aug 9, 2007 10:07 AM Franz Lehner wrote:

Hello,

is there a way to get hold of generate$Stream using the aldor compiler? I spent quite some time until figuring out that generate is probably a keyword in aldor (I could not check as the aldor site seems to be down) and this causes strange error messages. The following two snippets do not work, note that the second leads to a segfault:

  =================================================
  #include "axiom"

  teststream: with {
         zerostream:()->Stream Integer;
  } == add {
         zerostream():Stream Integer == {
                 import from Integer;
                 generate((x:Integer):Integer +-> 0@Integer,0@Integer);
  }
  }
  =================================================
  aldor -Fasy -Fao -Flsp  -laxiom -DAxiom -Y/home/lehner/usr/local/lib/wh-sandbox_s1/target/x86_64-unknown-linux/algebra test1.as "test1.as", line 8:
                   generate((x:Integer):Integer +-> 0@Integer,0@Integer);
  .........................^
  [L8 C26] #1 (Error) Have determined 1 possible types for the expression.
           Meaning 1: (x: Integer) -> Integer, Integer
     The context requires an expression of type Stream(Integer).

  make: *** [test.ao] Fehler 1

  =========================================================
  #include "axiom"

  teststream: with {
         zerostream:()->Stream Integer;
  } == add {
         zerostream():Stream Integer == {
                 import from Integer;
                 generate(():Integer +-> 0@Integer);
  }
  }
  =========================================================
  aldor -Fasy -Fao -Flsp  -laxiom -DAxiom -Y/home/lehner/usr/local/lib/wh-sandbox_s1/target/x86_64-unknown-linux/algebra est2.as
  Program fault (segmentation violation).#3 (Error) Program fault
  (segmentation violation).
  "test2.as", line 6:         zerostream():Stream Integer == {
                      .......................................^
  [L6 C40] #1 (Error) Have determined 0 possible types for the expression.
     Subexpression `import from Integer':
           Meaning 1: (0 types)

  "test.as", line 9:                 generate(():Integer +-> 0@Integer);
                      .........................^
  [L9 C26] #2 (Error) Have determined 0 possible types for the expression.

  make: *** [test.ao] Fehler 1

Bill Page replied:

Here is one way. The important thing is to escape the keyword generator by prefix with _.

\begin{aldor} #include "axiom"

teststream: with { zerostream:()->Stream Integer; } == add { zerostream():Stream Integer == { import from Integer; _generate((x:Integer):Integer +-> 0@Integer,0@Integer); } } \end{aldor}

\begin{axiom} zerostream() \end{axiom}


Some or all expressions may not have rendered properly, because Axiom returned the following error:
Error: export FRICAS=/usr/local/lib/fricas/target/x86_64-unknown-linux; export ALDORROOT=/usr/local/aldor/linux/1.1.0; export PATH=$ALDORROOT/bin:$PATH; export HOME=/var/zope2/var/LatexWiki; ulimit -t 600; export LD_LIBRARY_PATH=/usr/local/lib/fricas/target/x86_64-unknown-linux/lib; LANG=en_US.UTF-8 $FRICAS/bin/FRICASsys < /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/1160129980351370747-25px.axm
/bin/sh: /usr/local/lib/fricas/target/x86_64-unknown-linux/bin/FRICASsys: not found


Some or all expressions may not have rendered properly, because Latex returned the following error:
This is pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6)
 \write18 enabled.
 %&-line parsing enabled.
entering extended mode
(./6559809022419235011-16.0px.tex
LaTeX2e <2005/12/01>
Babel <v3.8h> and hyphenation patterns for english, usenglishmax, dumylang, noh
yphenation, arabic, farsi, croatian, ukrainian, russian, bulgarian, czech, slov
ak, danish, dutch, finnish, basque, french, german, ngerman, ibycus, greek, mon
ogreek, ancientgreek, hungarian, italian, latin, mongolian, norsk, icelandic, i
nterlingua, turkish, coptic, romanian, welsh, serbian, slovenian, estonian, esp
eranto, uppersorbian, indonesian, polish, portuguese, spanish, catalan, galicia
n, swedish, ukenglish, pinyin, loaded.
(/usr/share/texmf-texlive/tex/latex/base/article.cls
Document Class: article 2005/09/16 v1.4f Standard LaTeX document class
(/usr/share/texmf-texlive/tex/latex/base/size12.clo))
(/usr/share/texmf-texlive/tex/latex/ucs/ucs.sty
(/usr/share/texmf-texlive/tex/latex/ucs/data/uni-global.def))
(/usr/share/texmf-texlive/tex/latex/base/inputenc.sty
(/usr/share/texmf-texlive/tex/latex/ucs/utf8x.def))
(/usr/share/texmf-texlive/tex/latex/bbm/bbm.sty)
(/usr/share/texmf-texlive/tex/latex/jknapltx/mathrsfs.sty)
(/usr/share/texmf-texlive/tex/latex/base/fontenc.sty
(/usr/share/texmf-texlive/tex/latex/base/t1enc.def))
(/usr/share/texmf-texlive/tex/latex/pstricks/pstricks.sty
(/usr/share/texmf-texlive/tex/generic/pstricks/pstricks.tex
`PSTricks' v1.15  <2006/12/22> (tvz)
(/usr/share/texmf-texlive/tex/generic/pstricks/pstricks.con))
(/usr/share/texmf/tex/latex/xcolor/xcolor.sty
(/etc/texmf/tex/latex/config/color.cfg)
(/usr/share/texmf-texlive/tex/latex/graphics/dvips.def)
(/usr/share/texmf-texlive/tex/latex/graphics/dvipsnam.def)))
(/usr/share/texmf-texlive/tex/latex/graphics/epsfig.sty
(/usr/share/texmf-texlive/tex/latex/graphics/graphicx.sty
(/usr/share/texmf-texlive/tex/latex/graphics/keyval.sty)
(/usr/share/texmf-texlive/tex/latex/graphics/graphics.sty
(/usr/share/texmf-texlive/tex/latex/graphics/trig.sty)
(/etc/texmf/tex/latex/config/graphics.cfg))))
(/usr/share/texmf-texlive/tex/latex/pst-grad/pst-grad.sty
(/usr/share/texmf-texlive/tex/generic/pst-grad/pst-grad.tex
(/usr/share/texmf-texlive/tex/latex/xkeyval/pst-xkey.tex
(/usr/share/texmf-texlive/tex/latex/xkeyval/xkeyval.sty
(/usr/share/texmf-texlive/tex/latex/xkeyval/xkeyval.tex)))
`pst-plot' v1.05, 2006/11/04 (tvz,dg,hv)))
(/usr/share/texmf-texlive/tex/latex/pstricks/pst-plot.sty
(/usr/share/texmf-texlive/tex/generic/pstricks/pst-plot.tex
 v97 patch 2, 1999/12/12
(/usr/share/texmf-texlive/tex/generic/multido/multido.tex
 v1.41, 2004/05/18 <tvz>)))
(/usr/share/texmf-texlive/tex/latex/geometry/geometry.sty
(/usr/share/texmf-texlive/tex/xelatex/xetexconfig/geometry.cfg)

Package geometry Warning: `lmargin' and `rmargin' result in NEGATIVE (-108.405p t). `width' should be shortened in length.

) (/usr/share/texmf-texlive/tex/latex/amsmath/amsmath.sty For additional information on amsmath, use the `? option. (/usr/share/texmf-texlive/tex/latex/amsmath/amstext.sty (/usr/share/texmf-texlive/tex/latex/amsmath/amsgen.sty)) (/usr/share/texmf-texlive/tex/latex/amsmath/amsbsy.sty) (/usr/share/texmf-texlive/tex/latex/amsmath/amsopn.sty)) (/usr/share/texmf-texlive/tex/latex/amsfonts/amsfonts.sty) (/usr/share/texmf-texlive/tex/latex/amsfonts/amssymb.sty) (/usr/share/texmf-texlive/tex/latex/amscls/amsthm.sty) (/usr/share/texmf-texlive/tex/latex/setspace/setspace.sty Package: `setspace 6.7 <2000/12/01> ) (/usr/share/texmf-texlive/tex/generic/xypic/xy.sty (/usr/share/texmf-texlive/tex/generic/xypic/xy.tex Bootstrap'ing: catcodes, docmode, (/usr/share/texmf-texlive/tex/generic/xypic/xyrecat.tex) (/usr/share/texmf-texlive/tex/generic/xypic/xyidioms.tex)

Xy-pic version 3.7 <1999/02/16> Copyright (c) 1991-1998 by Kristoffer H. Rose <krisrose@ens-lyon.fr> Xy-pic is free software: see the User's Guide for details.

Loading kernel: messages; fonts; allocations: state, direction, utility macros; pictures: \xy, positions, objects, decorations; kernel objects: directionals, circles, text; options; algorithms: directions, edges, connections; Xy-pic loaded)) (/usr/share/texmf-texlive/tex/generic/xypic/xyall.tex Xy-pic option: All features v.3.3 (/usr/share/texmf-texlive/tex/generic/xypic/xycurve.tex Xy-pic option: Curve and Spline extension v.3.7 curve, circles, loaded) (/usr/share/texmf-texlive/tex/generic/xypic/xyframe.tex Xy-pic option: Frame and Bracket extension v.3.7 loaded) (/usr/share/texmf-texlive/tex/generic/xypic/xycmtip.tex Xy-pic option: Computer Modern tip extension v.3.3 (/usr/share/texmf-texlive/tex/generic/xypic/xytips.tex Xy-pic option: More Tips extension v.3.3 loaded) loaded) (/usr/share/texmf-texlive/tex/generic/xypic/xyline.tex Xy-pic option: Line styles extension v.3.6 loaded) (/usr/share/texmf-texlive/tex/generic/xypic/xyrotate.tex Xy-pic option: Rotate and Scale extension v.3.3 loaded) (/usr/share/texmf-texlive/tex/generic/xypic/xycolor.tex Xy-pic option: Colour extension v.3.3 loaded) (/usr/share/texmf-texlive/tex/generic/xypic/xymatrix.tex Xy-pic option: Matrix feature v.3.4 loaded) (/usr/share/texmf-texlive/tex/generic/xypic/xyarrow.tex Xy-pic option: Arrow and Path feature v.3.5 path, \ar, loaded) (/usr/share/texmf-texlive/tex/generic/xypic/xygraph.tex Xy-pic option: Graph feature v.3.7 loaded) loaded) (/usr/share/texmf-texlive/tex/latex/tools/verbatim.sty) (/usr/share/texmf/tex/latex/graphviz/graphviz.sty (/usr/share/texmf-texlive/tex/latex/psfrag/psfrag.sty)) (/usr/share/texmf/tex/latex/sagetex.sty Writing sage input file 6559809022419235011-16.0px.sage ) (/usr/share/texmf-texlive/tex/latex/gnuplottex/gnuplottex.sty (/usr/share/texmf-texlive/tex/latex/base/latexsym.sty) (/usr/share/texmf-texlive/tex/latex/moreverb/moreverb.sty) (/usr/share/texmf-texlive/tex/latex/base/ifthen.sty)) (./6559809022419235011-16.0px.aux) (/usr/share/texmf-texlive/tex/latex/ucs/ucsencs.def) (/usr/share/texmf-texlive/tex/latex/base/t1cmtt.fd)

LaTeX Warning: Characters dropped after `\end{axiom}' on input line 124.

You can't use `macro parameter character #' in vertical mode. l.126 # include "axiom" [1]

LaTeX Warning: Characters dropped after `\end{axiom}' on input line 133.

LaTeX Warning: Characters dropped after `\end{axiom}' on input line 136.

You can't use `macro parameter character #' in vertical mode. l.138 # include "axiom" Missing $ inserted. <inserted text> $ l.145 _ generate((x:Integer):Integer +-> 0@Integer,0@Integer); (/usr/share/texmf-texlive/tex/latex/jknapltx/ursfs.fd) (/usr/share/texmf-texlive/tex/latex/amsfonts/umsa.fd) (/usr/share/texmf-texlive/tex/latex/amsfonts/umsb.fd) (/usr/share/texmf-texlive/tex/latex/base/ulasy.fd) Extra }, or forgotten $. l.146 }

Extra }, or forgotten $. l.147 }

Missing $ inserted. <inserted text> $ l.148 \end{aldor} \newpage Missing } inserted. <inserted text> } l.148 \end{aldor} \newpage Missing } inserted. <inserted text> } l.148 \end{aldor} \newpage [2]

LaTeX Warning: Characters dropped after `\end{axiom}' on input line 151.

[3] (./6559809022419235011-16.0px.aux) ) (see the transcript file for additional information) Output written on 6559809022419235011-16.0px.dvi (3 pages, 1740 bytes). Transcript written on 6559809022419235011-16.0px.log.