https://wiki.haskell.org/index.php?title=Nhc98&feed=atom&action=historyNhc98 - Revision history2016-09-25T14:18:20ZRevision history for this page on the wikiMediaWiki 1.19.14+dfsg-1https://wiki.haskell.org/index.php?title=Nhc98&diff=48648&oldid=prevChandan: Here is a program to form a new list from two given lists such that a term appears in this new list iff it appeared in exactly one of those two lists. It takes O(nlog n) time.2012-08-12T10:57:50Z<p>Here is a program to form a new list from two given lists such that a term appears in this new list iff it appeared in exactly one of those two lists. It takes O(nlog n) time.</p>
<p><b>New page</b></p><div>uncommon :: [Int]->[Int]->[Int]<br />
uncommon x y=common (finalsort (x++y))<br />
<br />
common :: [Int]->[Int]<br />
common []=[]<br />
common [x]=[x]<br />
common (x:y:zs)<br />
| (x==y) =common zs<br />
| otherwise =x:(common (y:zs))<br />
<br />
sort :: [Int]->[Int]->[Int]<br />
sort [] x=x<br />
sort x []=x<br />
sort (x:xs) (y:ys)<br />
| (x>=y) =x:(sort xs (y:ys))<br />
| otherwise =y:(sort (x:xs) ys)<br />
<br />
finalsort :: [Int]->[Int]<br />
finalsort [x]=[x]<br />
finalsort x=sort (finalsort (first x)) (finalsort (lastest x))<br />
<br />
mylength :: [Int]->Int<br />
mylength []=0<br />
mylength (x:xs)=1+ mylength xs<br />
<br />
auxfirst :: [Int]->Int->[Int]<br />
auxfirst x 0=[]<br />
auxfirst (y:ys) x=y:(auxfirst ys (x-1))<br />
<br />
first :: [Int]->[Int]<br />
first x=auxfirst x (div (mylength x) 2)<br />
<br />
auxlast :: [Int]->Int->[Int]<br />
auxlast x 0=x<br />
auxlast (x:xs) y=auxlast xs (y-1)<br />
<br />
lastest :: [Int]->[Int]<br />
lastest x=auxlast x (div (mylength x) 2)</div>Chandan