I dun a DIP, possibly the best DIP ever
Johannes Loher
johannes.loher at fg4f.de
Sat Apr 25 10:08:42 UTC 2020
On Friday, 24 April 2020 at 22:21:31 UTC, Walter Bright wrote:
> On 4/24/2020 1:55 PM, Walter Bright wrote:
>> How are things like this expressed in mathematics?
>
> I did a little research:
>
> ∀xP(x)
>
> means:
>
> for all x in P(x)
>
> or in ... notation:
>
> P(x...)
This notation describes a proposition as in propositional
calculus. It is not something one would you to describe a „static
map“ of tuples.
In order to use the typical mathematical notation, we first need
to understand what a tuple is in mathematics. Typically this
terminology is used for an element of a product of specific
objects. For example, let’s consider \R^2 (2 dimensional vector
space with real-valued entries), which is the product of \R and
\R. The elements of \R^2 can be called 2-tuples. You can write it
as (x_1, x_2) \in \R^2. Now the number of factors can be
something different than 2 of course. In fact it doesn't need to
be finite, but as D only supports finite tuples (as of now),
let's only consider a finite number of factors for now. Also the
factors do not need to be the same. So let n \in \N (i.e. n is a
Natural number), then consider the finite set M:= /{1, ..., n/}.
For each m \in M, let A_m some object (for understanding, you can
consider it to be a set, or a vector space, but it can be a lot
of different things). Then the product of those A_m is written as
\prod_{m \in M} A_m. An element of this product can be called an
n-tuple (there are n entries) and is written as (a_m)_{m \in M}.
Now suppose that we have a map f, that can be applied to each of
the factors of the product and we want to create a new tuple by
applying f to each of its entries. We would write the new tuple
as (f(a_m))_{m \in M}. As you can see, there is no „expansion“ or
anything, it is just a declarative description of how the tuple
looks after „mapping“.
If you want a similar notation that’s „common“ in programming
languages, (list) comprehensions is what is closest. E.g. in
python, you can do the following:
my_tuple = (1, 2, 3, 4)
my_mapped_tuple = (f(i) for i in my_tuple)
More information about the Digitalmars-d
mailing list