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

Mark Brown mark at mercurylang.org
Thu Jun 27 05:45:35 AEST 2019


Hi,

On Wed, Jun 26, 2019 at 2:11 AM Bartosz Witkowski
<bartosz.witkowski at like-a-boss.net> wrote:
> 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

Nice :-)

You should check out the predicate reverse_prepend in the list module,
though. It's more efficient than the separate calls to reverse and
append that you currently have.

>> 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?

Since you know the size of the problem in advance there's no need to
go for a dynamic data structure. You could just use a circular buffer.

Mark


More information about the users mailing list