Check if two lists have the same elements

haskell

Solution

This works as well

import Data.List

function :: (Eq a) => [a] -> [a] -> Bool
function x y = null (x \\ y) && null (y \\ x)

Problem

I'm trying to write a function wich given two lists returns a boolean responding if the two lists have the same elements, even if they do not appear in the same order. I've got something like this: ``` function :: [a] -> [a] -> Bool function (x:xs) y = elem x y && function xs y ``` The problem with this is that there's no pattern when xs is empty, and I do not have any idea how to deal with that case. Any other way to solve this will be really welcome, I am quite new to Haskell. Thanks all!

Original source