Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,845 questions

51,766 answers

573 users

How to print duplicates from array in Lua

1 Answer

0 votes
arr = {5, 6, 3, 1, 1, 5, 5, 1, 7}
exist = {}

for i = 1, #arr do
   if not exist[arr[i]] then
      io.write(arr[i] .. ' ')
      exist[arr[i]] = true
   end
end




--[[
run:

5 6 3 1 7 

--]]

 



answered Sep 23, 2020 by avibootz
edited Sep 25, 2020 by avibootz

Related questions

1 answer 238 views
238 views asked Sep 23, 2020 by avibootz
1 answer 136 views
136 views asked Feb 15, 2023 by avibootz
2 answers 289 views
1 answer 168 views
168 views asked Sep 24, 2020 by avibootz
1 answer 222 views
222 views asked Sep 24, 2020 by avibootz
2 answers 249 views
249 views asked Sep 24, 2020 by avibootz
1 answer 171 views
...