I am currently taking the Scala course on Coursera on my free time after work, in an attempt to finally give a try to functional programming. I am currently working on an as
So based on all the responses above, I think the real workhorse is incl and the recursive way of calling union is just for going through all the elements in the sets.
I came up with the following implementation of union, is this better?
def union(other:BTSet) :BTSet = right union (left union (other incl element))