[m-users.] Efficient circular lists in pure Mercury?

jfondren at minimaltype.com jfondren at minimaltype.com
Wed Jun 26 02:58:38 AEST 2019


Thanks. The very moment you mentioned a pair of lists, I remembered
that this is a well-known technique :-/

I tried this zipper library, but for the life of me, in the 30 minutes
I have to look at it now, I couldn't define game_in, game_out, etc.
modes that work with the zipper insts and my code. It's likely this is
due to bugs in my code, since I'd already watered game_di down to the
equivalent of game_in.

On 2019-06-25 11:10, Bartosz Witkowski wrote:
> Hi Peter, Julian,
> 
> Just throwing it out there but I implemented a zipper data structure
>  in mercury some time ago if you're interested:
> 
>   https://gist.github.com/bartosz-witkowski/8154124
> 
> Kind Regards,
> Bartosz Witkowski
> 
> On Tue, Jun 25, 2019 at 3:49 PM Peter Wang <novalazy at gmail.com> wrote:
> 
>> On Tue, 25 Jun 2019 00:28:59 -0500, jfondren at minimaltype.com wrote:
>>> 
>>> 1. Do you recommend some other way to implement circular lists, or
>> a
>>> data structure suitable for this task?
>> 
>> Hi,
>> 
>> I think the standard solution would be a pair of lists. One list
>> represents, in reverse, the elements before the "current" element.
>> The other list represents the current and subsequent elements.
>> 
>> https://en.wikipedia.org/wiki/Zipper_(data_structure)
>> 
>> Peter
>> _______________________________________________
>> users mailing list
>> users at lists.mercurylang.org
>> https://lists.mercurylang.org/listinfo/users


More information about the users mailing list