Intersection function in Scala
intersecton(List(1, 2, 4), List(4, 5, 6)) incorrectly returns None.



You've asked several questions recently, and I keep seeing similar issues:


Using list.last: You have been advised to avoid traversing to the end of the list, for efficiency.  Lists should be manipulated at the head.
Functional thinking: These solutions involve too many tedious cases, and the code could be simplified by defining helper functions, or even restated entirely in terms of other functions.
Spelling: What's an "intersecton"?  (You previously misspelled "palindrome", twice.)
Inadequate testing: The counterexample cited above just happened to be the first test I tried, and it failed.  This isn't the first time I've seen an obviously wrong result.  Your first question was closed due to broken code, and it still hasn't been fixed.


You are welcome to use Code Review as a learning resource, but it would be a good idea to show some improvement between questions.