No I know it, I'm a nerd, I just started to drool
over my code
I might bore you all with this. If so move on. the thing is
that I hope to entertain you all, and being a geek this is
my way of entertainment. If I'm alone in the universe so
bee it, If only one appreciate this stuff I will be a very
happy geek, .... , lets hack a mole!
This week I have completed code to do all the things In the
last prototype + some other bit's and pieces that
inspiration brought forward. I have prototyped and clean up
interfaces for parsing including stuff such as look ahead
which contains some general patterns.
An Idea would be to make proper interfaces for threading and
process handling. This is an item that has to be handled as
well. TODO!
look ahead is interesting, and can be implemented in two
ways. Either you "rebase" by your incoming sequence so that
you have all the data you need then start the actual looping
at a later stage normalize by using delayed variables
to get in sync with the rest. The other approach is to work
with delayed variables throughout and is simpler but some
constructs will then not work.
It would be nice to have a type info for the value of the
next value. The type information is mediated as the return
value when doing a next, so it would be nice to introduce
that logic.
And one more thing. Assume G = (g.. Cnstr) will take a
generator constructor Cnstr and generate sequence of
generators/transformers/collectors but with the quirk that
when a finish signal is sent to G it will restart but
keeping all the generators created in memory so it
reiterates the same iterators when applied again. Introduce
the (x
G V) G is a generator of generators and V is generator
sequence of values (x G V) will then for each iteration take
the corresponding G an update it with the value of V. Now,
(let G (g.. coll)
(for X in (li L)
(xfor [myColl Y] in [G (li (ghead X))]
(coll (x .myColl Y)))))
meaning a transposing of the list of lists L in
a algoritmic efficient way but of cause without an optimizer
will have poor performance. It may look a little complicated
but from this you can introduce the following syntactic sugar:
(for X in (li L)
(xfor Y in .X
(xfor Z in .Y
(permute (Y coll) (Z coll) (X sum)) Z))))))
(.X just means you take the value of the generator) This
code will behave as if you permuted L and issued
something like,
(for Y in (li L)
(coll (xfor Z in .Y
(coll (xfor X in .Z
(sum X))))))
To see the transformation of the permute construct
rewrite it as
(forX (forY (forZ (Ycoll (Zcoll (Xsum Z))))
Now first move Ycoll as much to the left as possible,
then move Zcoll as much to the left as possible and lastly
Xcoll as much to the left as possible. An Acoll may not pass
an forA and an Acoll is not allowed to pass through another
Bcoll. Then you will get
(forX (forY (Ycoll (forZ (Zcoll (Xsum Z)))))
Then replace (forA (AS .. with (forA (S ..
and when that has been done replace (AS Rest) with (x
.AS Rest) and insert let statements so that we get (let
AS (g.. S) (forA ... Following these rules we reach
(let Xsums (g.. sum)
(forX
(forY (coll
(forZ (coll (x .Xsum) Z))))
Add the correct paralel iteration over the Xsums
and we reach.
(let Xsums (g.. sum)
(for X in (li L)
(for Y in .X
(coll (xfor [Xsum Z] in [Xsums .Y]
(coll (x Xsum Z)))))))))
This maybe is a little academic but fun fun fun
Cheers