Symmetric difference: Difference between revisions

Add Miranda
(Initial FutureBasic task solution added)
(Add Miranda)
Line 2,381:
to_sorted_list(Set, Elems),
io.format("%11s: %s\n", [s(Desc), s(string(Elems))], !IO).</syntaxhighlight>
 
=={{header|Miranda}}==
<syntaxhighlight lang="miranda>main :: [sys_message]
main = [Stdout (show (symdiff a b) ++ "\n")]
where a = ["John", "Serena", "Bob", "Mary", "Serena"]
b = ["Jim", "Mary", "John", "Jim", "Bob"]
 
symdiff :: [*]->[*]->[*]
symdiff a b = (a' -- b') ++ (b' -- a')
where a' = nub a
b' = nub b
 
nub :: [*]->[*]
nub = f []
where f acc [] = acc
f acc (a:as) = f acc as, if a $in acc
= f (a:acc) as, otherwise
 
in :: *->[*]->bool
in i [] = False
in i (a:as) = a == i \/ i $in as</syntaxhighlight>
{{out}}
<pre>["Serena","Jim"]</pre>
 
=={{header|Nim}}==
2,094

edits