Andrew Clarke wrote:
> Hey folks,
> 
> Has anyone invented a successful way of using coroutines like lambas? I 
> want
> 
> the initial invocation of the coroutine to be able to receive 
> parameters. 

How about the following:

procedure makeLamda(ce)
     return (@ce, ce)
end

This will perform the initial activation of the coexpression and then
return the coexpression.  You have to write your co-expression with that
in mind.

A variant of this would be:

    procedure lamda(A)
        return (@A[1], A[1])
    end

which can be used as a PDCO to automatically create the coexpression, as in:

    procedure genAcc(n)
        return lamda { while i := (n...@source)[1] do n +:= i }
    end

a sample use is:

    procedure main()
        a := genAcc(3)
        b := genAcc(5)

        write("         ","a",  " ","b")
        write("genAcc: ", a(4), " ",b(4))
        write("genAcc: ", a(2), " ",b(3))
    end


-- 
Steve Wampler -- [email protected]
The gods that smiled on your birth are now laughing out loud.

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Unicon-group mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/unicon-group

Reply via email to