Erlang shell table Data Alignment

Source: Internet
Author: User

Recently, some tests were conducted in Erlang shell. In order to make the test result data more intuitive, we wanted to align the data to be printed and achieve the same effect as imaging tables.

The idea was to insert a tab in the data. Of course, Erlang also supports tabs, but the actual effect is not satisfactory.

Tab support is as follows:

1> IO: Format ("No1 ~ Sn2 ~ N1 ~ S2 ~ N ", [" \ t "," \ t "]).
No1 no2
1 2
OK


However, if the data length exceeds 8 characters, is there a way to customize the number of alignment characters?


Yes, IO: format/2 pairs ~ S also supports ~ NS, N can be a positive integer or a negative integer. The effect is as follows:

2> IO: Format ("~ -10 s ~ -10 s ~ -10 s ~ -10 s ~ N ", [" No1 "," NO2 "," NO3 "," No4 "]), IO: Format ("~ -10 s ~ -10 s ~ -10 s ~ -10 s ~ N ", [" 123 "," 456789 "," 012 "," 345678901 "]).

No1 NO2 NO3 No4

123 456789 012 345678901

OK

3> IO: Format ("~ 10 s ~ 10 s ~ 10 s ~ 10 s ~ N ", [" No1 "," NO2 "," NO3 "," No4 "]), IO: Format ("~ 10 s ~ 10 s ~ 10 s ~ 10 s ~ N ", [" 123 "," 456789 "," 012 "," 345678901 "]).

No1 NO2 NO3 No4

123 456789 012 345678901


Reference: http://blog.csdn.net/mycwq/article/details/37933111

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.