Kevin Sookocheff explains the concepts of domain, range, and codomain:
That is, a function relates an input to an output. But, not all input values have to work, and not all output values. For example, you can imagine a function that only works for positive numbers, or a function that only returns natural numbers. To more clearly specify the types and values of a functions input and output, we use the terms domain, range, and codomain.
Speaking as simply as possible, we can define what can go into a function, and what can come out:
-
domain: what can go into a function
-
codomain: what may possibly come out of a function
-
range: what actually comes out of a function
Read on for more, including a couple of examples. These are important concepts for learning functional programming.