Write a Python function to convert a list of characters to their corresponding ASCII codes.
[‘a’, ‘b’, ‘c’, ‘d’]
def to_ascii(arr):
    res = []
    for c in arr:
        res.append(ord(c))
    return res

print(to_ascii(['a', 'b', 'c', 'd']))