Newsgroups: perl.perl6.language
From: fibon...@babylonia.flatirons.org (Luke Palmer)
Date: Fri, 6 Dec 2002 14:03:00 -0700 (MST)
Subject: Perl 6 and Set Theory
=head1 Perl 6 and Set Theory
This document will introduce a new way of thinking about some Perl 6 Even in absence of an explicit "set" type, Perl 6 is quite proficient =head2 Junctions Junctions are a transparent mechanism for dealing with finite sets. The expressions: 1 | 2 | 3 represent the set: { 1, 2, 3 } Which we will call N. Performing some operation I<z> on them { z(x): x ∈ N } If, for example, this operation is C<{ $^x + 2 }>, we have: { x + 2: x ∈ N } or { 3, 4, 5 } If that was a comparison operation, say C<{ $^x > 2 }>, the resultant { undef, undef, 1 } Evaluating this in boolean context should be true if the junction was { ∃x: x ∈ J ∧ ?x, disjunctive That is, the "type" of junction just determines whether the quantifier There is one behavior of junctions, however, that doesn't work with • Junctions discard C<undef>s on-sight (i.e. C<undef> can never be Unfortunately, the last change clobbers the left-short-circuiting Note that the definition of how junctions behave in itself allows A + B = { x + B: x ∈ A } Where each inner set is a conjunctive set, and the outer is a 5 < C < 9 It would be true (in fact, "C<5 but true>"), as all(6, 7, 8) would =head2 Classes In Perl 6, classes represent infinite sets of objects. The class Unlike junctions, classes are not transparent interfaces to their For instance, to declare a variable that can represent either an my (Int | Str) $var; The type of that variable is the union of the sets of integers and Since a derived object can be used in place of its parent anywhere, it Multiple inheritance represents a superset of multiple sets. C<Object> or C<UNIVERSAL> represents the "universe"; i.e. the set of It is an interesting issue whether any junction can be used as a my (1 | 2 | 4) $var; would declare $var to only accept values 1, 2, and 4. This probably =head2 Summary The rules for a junction J, again, are: z(J) ≡ { z(x): x ∈ J } { ∃x: x ∈ J ∧ ?x, disjunctive Classes have no such rules, as they are not transparent. =cut There could be good, mathematically consistent ways to do the things I I'd also like junctions and classes to be as powerful as real sets, Luke You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||