[Jprogramming] lazy evaluation on infinite streams
Raoul Schorer
raoul.schorer at gmail.com
Wed Jan 8 00:51:08 UTC 2020
Hi,
Implementing Minikanren <http://minikanren.org/> in J by translating from
Scheme, I stumbled on the following:
I have a Scheme procedure 'fives'
<https://github.com/jasonhemann/microKanren/blob/master/microKanren-test-programs.scm>
that is passed a vector and yields a procedure that then takes a pair.
((fives (vector 0)) '(() . 0))
My problem is that this then evaluates to a pair data -- procedure:
((((#(0) . 5)) . 0) . #<procedure at microKanren-test-programs.scm:677>)
The second member of the pair (the procedure) is then evaluated on demand
to yield another similar structure of length n+1, therefore allowing the
lazy evaluation of this infinite "stream".
Is switching to iterative/eager eval the only realistic way?
Can someone help me with lazy eval of infinite structures in J, or give me
pointers to resources on the topic?
Thanks!
Raoul Schorer
More information about the Programming
mailing list