I answer in the case you wish to test the intersection between two
|List| expressions, and not comparing text. In that later case others have already provide good answers.
Linear O(N) algorithms won't be efficient once implemented in vimscript as they would require using
:for which has terrible performances. Functional O(N²) implementations are likely to be the fastest with current versions of Vim.
For instance, in that case I'd use the following function from my vim script library
function! lh#list#intersect(list1, list2) abort
let result = copy(a:list1)
call filter(result, 'index(a:list2, v:val) >= 0')