Ah, you've forgotten to say that I it is currently only in the compiler, i.e., I have to run something like

myfun(mygen)

in order to use the generator mygen.

Anyway, thank you for making that already happen.

I guess the bigger problem will be to introduce the "generate" and "yield" keywords. It's unfortunate that stream.spad, ituple.spad and fnla.spad define a "generate" function.

BTW, can you say, what exactly Reference(Integer) is? Can I imagine that as something similar to Record(x:Integer) but using ref/deref instead of the equivalent functions for the Record domain?

Ralf

)abbrev package FFF FFF
FFF() : with
    myfun : Generator(Integer) ->  Integer
  == add

    myfun(x) ==
        res : Integer := 0
        for z in x repeat
            print(z::OutputForm)$OutputForm
            res := res + z
        res

-- input file actually using the above
mS := Reference(Integer)
empf(i : mS) : Boolean == deref(i)<= 0
stepf(i : mS) : Integer ==
     (pp := divide(deref(i), 3); setref(i, pp.quotient); pp.remainder)
mG := MakeGenerator(Integer, mS)
mygen := makeGenerator(ref(47), empf, stepf)$mG

--
You received this message because you are subscribed to the Google Groups "FriCAS - 
computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/fricas-devel?hl=en.

Reply via email to