I have 2 lists:
List1 = [1,2,3]. List2 = ["asd", "sda", "dsa"].
How can I print this list in the following order:
1 asd 2 sda 3 dsa
Thanks.
1> lists:zipwith(fun (X1, X2) -> io:format("~p ~p ", [X1,X2]) end, List1, List2). 1 "asd" 2 "sda" 3 "dsa" [ok,ok,ok] 2>
sometimes it's better to reinvent the wheel. in the case of erlang, just for understanding recursion, tail calls, and how to work with lists.
f([], []) -> ok; f([H1|R1], [H2|R2]) -> io:format("~p ~p", [H1, H2]), f(R1, R2).
Source: https://habr.com/ru/post/1337020/More articles:How to resize a view using the UINavigationController setToolbarHidden: animated: - iosRunning a task list on Windows with popen in C without a popup window cmd.exe - cStruts2 + Json Serializing Items - javaRails i18n: problem with lack of translation, locale not defined - ruby-on-railsHow can I see 0s and 1s / machine code from an executable / object file? - binaryShared primary key - mysqlPDF created by Latex does not open at 100% zoom - pdfTable Design and Class Hierarchy - language-agnosticHow can I unit test or integration test for 404 - not found? - tddAlgorithmic decision to find the nearest city based on lat / lon - algorithmAll Articles