Wednesday, June 27, 2007

lifted function

Eric Lippert irt rola a C# 2.0 Standard-ban tortent teves hasznalat kapcsan:

Precisely what mathematicians mean by “lifted”.

Suppose we’ve got a function f which maps values from a set A into a set B. That is f:A→B.

Suppose further that null is not a member of either A or B.

Now consider the sets A’ = A ∪ { null } and B’ = B ∪ { null }

We define the “lifted function” f’ as

f’:A’→B’ such that f’(x) = f(x) for all x ∈ A and f’(null) = null

Similarly, if we had a two-argument function f: A × B → C, we would define f’: A’ × B’ → C’ as f’(x,y) = f(x,y) for all (x,y) ∈ A × B and null if either x or y is null.

What we’re getting at here is that “lifted” means “takes nulls, always agrees with the unlifted version when arguments are not null, maps everything else onto null”.