How to not print types in Julia?

故事扮演 提交于 2019-12-23 15:26:22

问题


If I have an array of numbers:

a = [1,2,3]

and print it, I get

[1,2,3]

but if I have an array of, say, Tuples:

b = [(1,2),(3,)]

when I print it I get:

Tuple{Int64,Vararg{Int64}}[(1,2),(3,)]

How to avoid printing the types?


回答1:


It cannot be suppressed.

julia> b = [(1,2), (3,)]
2-element Array{Tuple{Int64,Vararg{Int64}},1}:
 (1,2)
 (3,)

Maybe the type is being printed to show you that you are including a Vararg type.

If you want an output without the message, you can go ahead and write a wrapper for Base.show



来源:https://stackoverflow.com/questions/35536437/how-to-not-print-types-in-julia

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!