Lazily consuming a self-referential linked list
tobz619:
Ah I see, that pretty neat! And beyond my skill level xD.
I thought so too, but apparently it reliably blows up the stack and my machines memory x) so it may as well be above mine
tobz619:
I’ve had a bit more of a look and the circle I’m trying to square is the
(q → s →[q] → ([q],s))function. The question is where do you get thisqelement from if[q]is empty?
This is the type for the function performing the work. I apologize for the bad naming: q is meant to be the work queue element type, it holds some information about the work that needs to be done. s is the state that can be accessed and altered in every step. The last argument ([q]) is the work queue itself, or rather, the end of the queue. By prepending to the end of the work queue, new work can be scheduled to be performed before the work that has not yet been scheduled.
This is all very backwards, because of this ingenious lazy list, which I am not so fond of anymore.
tobz619:
I’m not totally sure if that’s helpful as I’m struggling to grasp the behaviour of
Tardis.
Be assured, I’m happy I sparked your interest and you are being helpful.
tobz619:
Part of me feels like this is also achievable with nested
foldl/foldrs but I haven’t looked that far into it.
I agree, it should be achievable, I’ll explore it probably.
Discussion in the ATmosphere