On Sun, Nov 30, 2008 at 7:40 AM, Viktor Cerovski
<[EMAIL PROTECTED]> wrote:
> Raul Miller-4 wrote:
>> [...]
>> Here's how I might implement my proposed alternative
>> "Closure":
>>
>> serialize=: 1 :0
>> r=. 5!:5<'u'
>> if. 10 41-:a.i._2{.r do.
>> '((3!:2 a.{~',(":a.i.3!:1]5!:1<'u'),')5!:0)'
>> else.
>> '(',r,')'
>> end.
>> )
>>
>> Closure=:2 :0
>> linu=:u serialize
>> linv=:v serialize
>> L1=: 'L=. cocreate '''''
>> L2=: 'state__L=: m'
>> body=: linu,'state__x=: state__x ',linv,' y'
>> L3=: 'L&(4 :''',(body#~1+body=''''),''')'
>> 1 :(L1;L2;L3)
>> )
>>
> Raul, this is not it. An implementation of ]: (Closure) is a bit more
> complicated.
I did simplify your initial proposal, and I gave my reasoning.
But I should also point out that simplicity is a virtue, especially
in the context of programming.
I should also point out that my code works. I claim that if
you had any use for your planned:
G=: (a :b) ]: c
g=: G d
that
G2=: a Closure b
g=: (c d) G2
would provide you with a g which has all the
properties you had specified.
I also claim that the syntax you attributed to your G
is invalid, which is why I used a different syntax for G2.
> Your code then should also have the Closure produce unique
> instances of generators: each produced generator should have
> a unique internal state.
It does.
> I hope this helps.
No.
Thanks though,
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm