[m-dev.] Unique Modes and Transaction Logic

Mark Brown mark at mercurylang.org
Wed Jul 9 00:34:30 AEST 2014


On Tue, Jul 8, 2014 at 5:30 PM, Julien Fischer <jfischer at opturion.com> wrote:
>
> On Tue, 8 Jul 2014, Mark Brown wrote:
>>>>
>>>> Additionally, pure, reversible
>>>> /assert/ and /retract/ semantics can even be used in semidet and nondet
>>>> contexts without leading to inconsistent states.
>>>
>>>
>>> There was a more general proposal to achieve something similar to this.
>>> You
>>> would still need to use solutions/2 to create a list but then you could
>>> iterate over the list using a loop.
>>>
>>> Also do you know that you can use list.foldl to help print out a list?
>>>
>>>         foldl(print_item, List, !IO),
>>>
>>>     :- pred print_item(string::in, io::di, io::uo) is det.
>>>
>>>     print_item(String, !IO) :-
>>>         write_string(String, !IO),
>>>         nl(!IO).
>>>
>>
>> Also io.print_line  ;-)
>
>
> ... is so new that it hasn't yet made it into a stable release ;-)
> For the current stable release,
>
>     write_list(List, "\n", write_string, !IO)
>

That doesn't print the trailing newline. Maybe some sort of inline
iterator would help?

;-)

Cheers,
Mark.



More information about the developers mailing list