delay vs. generate - yieldOn Date: 01 Mar 2009 14:37:58 +0100 Martin Rubey wrote: [Due to] the absence of Generators in SPAD, [here is] a
mini-tutorial for
Simplest example I can think of: fricas (1) -> <spad> fricas )abb package TEST Test
Test(): with
f: Integer -> Stream Integer
== add
f n == delay cons(n,
fricas Compiling FriCAS source code from file
/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/4237768559018105081-25px001.spad
using old system compiler.
TEST abbreviates package Test
------------------------------------------------------------------------
initializing NRLIB TEST for Test
compiling into NRLIB TEST
compiling exported f : Integer -> Stream Integer
Time: 0 SEC.then'f 1' will return '[1,...]?'. fricas f 1
Type: Stream(Integer)
Of course the actual output depends on your setting of
Thus, the aldor style:
f() == generate {
block1;
yield a;
block2;
yield b;
}
}
could become:
f() == f1()
f1() == delay
block1
cons(a, f2())
f2() == delay
block2
[b]::Stream R
|