Resolved my first question, from the help of another forum. If anyone's interested :
"By definition the domain of f is the set of all inputs for which f is defined; in this case that’s {a,b,c,d}=X. This is actually implicit in the notation f:X→Y, which almost always implies that that the domain of f is X. (I say almost because in some areas of mathematics one deals with so-called partial functions from X to Y, whose domains may not be all of X. I would not worry about this: it should not come up in what you’re doing.)
The codomain can also be read straight from the notation f:X→Y: it’s the target set Y, which here is {1,2,3,4,5}. The range is always a subset of the codomain: it’s the set of values that the function actually assumes (or if you prefer — and in CS you might! — outputs). For your function f those values are 1,2, and 5, so the range of f is the set {1,2,5}.
That’s all there is to it."