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

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/FriCAS interface provides such a generator for the FriCAS Vector type. Let's try it.

fricas
(1) -> <aldor>
#include "fricas"
myList(v:Vector Integer):List Integer == [ i for i in v ];</aldor>
fricas
Compiling FriCAS source code from file 
      /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/7106011744705935635-25px001.as
      using Aldor compiler and options 
-O -Fasy -Fao -Flsp -lfricas -Mno-ALDOR_W_WillObsolete -DFriCAS -Y $FRICAS/algebra -I $FRICAS/algebra
      Use the system command )set compiler args to change these 
      options.
fricas
Compiling Lisp source code from file 
      ./7106011744705935635-25px001.lsp
   Issuing )library command for 7106011744705935635-25px001
fricas
Reading /var/aw/var/LatexWiki/7106011744705935635-25px001.asy

fricas
V:Vector Integer:=[1,2,3]

\label{eq1}\left[ 1, \: 2, \: 3 \right](1)
Type: Vector(Integer)
fricas
myList(V)

\label{eq2}\left[ 1, \: 2, \: 3 \right](2)
Type: List(Integer)

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. But FriCAS Stream no longer has generate so code below is not needed and does not work.

aldor
#include "fricas"
teststream: with { zerostream:()->Stream Integer; } == add { zerostream():Stream Integer == { import from Integer; _generate((x:Integer):Integer +-> 0@Integer,0@Integer); } }
aldor
   Compiling FriCAS source code from file 
      /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/4578529267043810746-25px003.as
      using Aldor compiler and options 
-O -Fasy -Fao -Flsp -lfricas -Mno-ALDOR_W_WillObsolete -DFriCAS -Y $FRICAS/algebra -I $FRICAS/algebra
      Use the system command )set compiler args to change these 
      options.
"/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/4578529267043810746-25px003.as", line 8: 
                _generate((x:Integer):Integer +-> 0@Integer,0@Integer);
................^
[L8 C17] #1 (Error) There are no suitable meanings for the operator `generate'.
The )library system command was not called after compilation.

fricas
zerostream()
There are no library operations named zerostream Use HyperDoc Browse or issue )what op zerostream to learn if there is any operation containing " zerostream " in its name.
Cannot find a no-argument definition or library operation named zerostream .




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