maps:from_list 是否保证保留逆序?
Is maps:from_list guaranteed to preserve reverse order?
maps:from_list 似乎保留了列表顺序的倒序。此示例来自文档:
List = [{"a",ignored},{1337,"value two"},{42,value_three},{"a",1}],
maps:from_list(List).
这种行为有保障吗?
"Preserve the reverse order of the list" 并不是很准确,因为这意味着地图会以某种方式呈现该顺序,但它不会那样做。我认为您真正要问的是与列表中后面出现的键关联的值是否存储在地图中,从而有效地删除了列表中前面出现的键;如果是这样,maps:from_list/1
documentation 提供以下保证:
If the same key appears more than once, the latter (right-most) value
is used and the previous values are ignored.
maps:from_list 似乎保留了列表顺序的倒序。此示例来自文档:
List = [{"a",ignored},{1337,"value two"},{42,value_three},{"a",1}],
maps:from_list(List).
这种行为有保障吗?
"Preserve the reverse order of the list" 并不是很准确,因为这意味着地图会以某种方式呈现该顺序,但它不会那样做。我认为您真正要问的是与列表中后面出现的键关联的值是否存储在地图中,从而有效地删除了列表中前面出现的键;如果是这样,maps:from_list/1
documentation 提供以下保证:
If the same key appears more than once, the latter (right-most) value is used and the previous values are ignored.