I am new to scala How can I remove Duplicates from an array. without using Distict keyword.
I have Array Like this
Input
Array(1,2,3,1,3)
=====================
I need output like This
OutPut
====================
Array(1,2,3)
My code is
Val ar=Array(1,2,3,4,5)
for(i<-0 to ar.length-1){
if(ar(i)!=for())..?
I want to write a program without using Set And List
val dup =ar.foldLeft(Array[Int]()){(a,b)=>if(a contains(b)) a else a :+ b}
I got this solution but how it works
can any one please explain how background it works I tried
1,2,3,1,2
1==2 false .. else 1 :