```
prefix :: String -> String -> Bool
prefix [] _ = True
prefix _ [] = False
prefix (x:xs) (y:ys) = (x == y) && (prefix xs ys)

```

I have this Haskell function in which we check whether the first string is the prefix of the other one.

I can't really understand a few things.

Why is prefix [] \_ True? And why is it false the other way around?
I mean if both are empty shouldn't it be true that nothing is a prefix of nothing?

Also, am I understanding how the function works correctly?

We take the first symbol from the first string and then we take the first symbol from second string and see whether they are equal and then we call the same function with the strings shorter by one character?

Also, we use the prefix implemention to create a function substring which checks whether one string is part of another one

```
substring :: String -> String -> Bool
substring x y
    | length x > length y = False
    | otherwise = prefix x y || substring x (tail y)

```

I am also having trouble understanding how the substring function works in general. Why is it necessarily a prefix if the length x is bigger than y?