简体   繁体   English

如何显示长整数列表? (水银语言)

[英]How do I display a list of long integers? (Mercury language)

In io.write_list(List(integer), ",", OutputPred, !IO), what is OutputPred? 在io.write_list(List(integer),“,”,OutputPred,!IO)中,什么是OutputPred? I'm trying to display a list of type integer. 我正在尝试显示整数类型的列表。 The list is initially never empty. 该列表最初从不为空。

io.write_list(MyList, ",", io.write, !IO), where MyList is a list of type integer, will cause MyList members to be printed/displayed. io.write_list(MyList,“,”,io.write,!IO),其中MyList是整数类型的列表,将导致MyList成员被打印/显示。 Each member has the following display format i(1, [integer_value]), so it's an awkward appearing output, but is correct. 每个成员都具有以下显示格式i(1,[integer_value]),因此它的输出看起来很尴尬,但是是正确的。 An empty list prints nothing and doesn't result in error. 空列表不会打印任何内容,也不会导致错误。

An alternative is io.write(MyList, !IO) and produces the same result. 替代方法是io.write(MyList,!IO)并产生相同的结果。

The answer to the question of what OutputPred is is io.write. 关于什么是OutputPred的问题的答案是io.write。 io.print also works. io.print也可以。

This information was obtained from Mercury.org 该信息是从Mercury.org获得的

The following Mercury code will display/print the list of type Integer in a more common form: [10, 9, 8,..., 2, 1]. 以下Mercury代码将以更常见的形式显示/打印Integer类型的列表:[10、9、8,...,2、1]。

io.write_string(string.join_list(" ,", map(integer.to_string, My_List)), !IO). io.write_string(string.join_list(“,”,map(integer.to_string,My_List)),!IO)。

The square brackets have to be added separately and can be obtained with preceding and trailing io.write_string commands. 方括号必须单独添加,并且可以通过前面和后面的io.write_string命令获得。

It works. 有用。 My_List is a list of elements of type integer. My_List是整数类型的元素的列表。

This information was obtained from Mercury.org 该信息是从Mercury.org获得的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM