Hey People
I think my current try seems to fit in here.
At the moment I try to code some kind of generator-function, wich yield's a Value on the Runtime, and after recalling it start over on that position.
The code is very complicated and I had'nt any time yet to add comments.
Its not even finished and can handle not all kind of stuff.
At the moment it can handle yield's nested in:
- if
- while
- yield
- and I think all kind of operators wich aren't any special.
If the operator is a list it will output a message, beause I have'nt any idea how to handle thi situation.
*********************
Here a small example:
(generator
'TEST
'(lambda (a b / c )
(while (> a 0)
(setq c b)
(while (> b 0)
(print b)
(if (> (yield a) 5)
(yield (cons a b))
)
(setq b (1- b))
)
(setq a (1- a))
(setq b c)
"This is the end"
)
)
'(10 5)
)
The function 'generator' parses the given lambda-expression to a "generator-function" and stores it in the given Symbol (here 'TEST).
It also stores the namespace of the lambda-expression. The third argument are the InputValues for the future generator.
Use it like
(test) ;-> (T . 10)
(test) ;-> (T 10 . 5)
.
.
.
(test) ;-> (nil . "This is the end")
The function return a dotted-pair.
* The car-value
'T ... Value was yield-ed
'nil ... Function is finished
Maybe someone has a use for it
or some ideas to make it better....
** Code in the attachment
greets
reltro