[m-users.] Higher order term vw. lamda abstraction
Zoltan Somogyi
zoltan.somogyi at runbox.com
Tue Oct 8 18:06:34 AEDT 2019
On Tue, 08 Oct 2019 08:21:03 +0200, Volker Wysk <post at volker-wysk.de> wrote:
> test_listen.m:013: In clause for `main(di, uo)':
> test_listen.m:013: in argument 1 of call to predicate `map'/3:
> test_listen.m:013: mode error in unification of `V_9' and higher-
> order term
> test_listen.m:013: based on multi-moded predicate
> `string.from_char_list'/2.
> test_listen.m:013: The modes of the argument variables match more
> than one of
> test_listen.m:013: the called predicate's modes.
>
> I don't understand the difference. Shouldn't the two be the same?
The root cause of the problem is that the string.from_char_list predicate
has two modes, and the compiler cannot choose between them. The lambda
version works because the lambda's arguments explicitly specify the mode
of the higher order value being passed as the argument of list.map.
The function version of string.from_char_list has only one mode.
You can simply switch to using that, and the problem will go away.
Zoltan.
More information about the users
mailing list