<?xml version="1.0" encoding="UTF-8" ?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:base="http://everything2.com/">
    <title>ariels's New Writeups</title>
    <link rel="alternate" type="text/html" href="http://everything2.com/index.pl?node=Everything%20User%20Search&amp;usersearch=ariels" />
    <link rel="self" type="application/atom+xml" href="?node=New%20Writeups%20Atom%20Feed&amp;type=ticker&amp;foruser=ariels" />
    <id>http://everything2.com/?node=New%20Writeups%20Atom%20Feed&amp;foruser=ariels</id>
    <updated>2007-11-18T03:58:43Z</updated>
<entry><title>Buffon's Needle (thing)</title><link rel="alternate" type="text/html" href="http://www.everything2.org:80/user/ariels/writeups/Buffon%2527s+Needle"/><id>http://www.everything2.org:80/user/ariels/writeups/Buffon%2527s+Needle</id><author><name>ariels</name><uri>http://www.everything2.org:80/user/ariels</uri></author><published>2007-11-18T03:58:43Z</published><updated>2007-11-18T03:58:43Z</updated>
<content type="html">&lt;h2&gt;Sewing without &lt;a href=&quot;/title/Calculus&quot;&gt;Calculus&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;
&lt;em&gt;Buffon's needle&lt;/em&gt; is deeply unsatisfying: a question with only a passing relationship to circles &lt;small&gt;(the needle can fall in any orientation -- but there's still the small matter of lateral motion!)&lt;/small&gt; ends up connected to &amp;pi;.  Why?
&lt;/p&gt;&lt;p&gt;
The standard proof -- above in &lt;a href=&quot;/title/devout&quot;&gt;devout&lt;/a&gt;'s writeup, with &lt;a href=&quot;/title/integral&quot;&gt;integral&lt;/a&gt;s -- does little to explain the mysterious appearance of &amp;pi;.  &lt;em&gt;&lt;a href=&quot;/title/Calculation&quot;&gt;Calculation&lt;/a&gt; is often like that.&lt;/em&gt;
&lt;/p&gt;&lt;p&gt;
&lt;a href=&quot;/title/Geometric+measure+theory&quot;&gt;Geometric measure theory&lt;/a&gt; offers a &quot;clean&quot; proof, one that almost does explain where &amp;pi; comes from.  And it goes like this.
&lt;/p&gt;
&lt;ol&gt;

&lt;li&gt;
We are interested in the &lt;a href=&quot;/title/probability&quot;&gt;probability&lt;/a&gt; &quot;p&lt;sub&gt;L&lt;/sub&gt;&quot; that a needle of length L, randomly dropped on a surface ruled with lines at interval 1 from each other, will intersect a line.  Suppose L&amp;le;1.  Then &lt;a href=&quot;/title/almost+always&quot;&gt;almost always&lt;/a&gt; the needle can intersect at most 1 line, so either it intersects 1 line (with probability p&lt;sub&gt;L&lt;/sub&gt;) or it intersects 0 lines (with probability 1-p&lt;sub&gt;L&lt;/sub&gt;).&lt;/li&gt;&lt;/ol&gt;&amp;hellip;</content>
</entry><entry><title>generic programming (thing)</title><link rel="alternate" type="text/html" href="http://www.everything2.org:80/user/ariels/writeups/generic+programming"/><id>http://www.everything2.org:80/user/ariels/writeups/generic+programming</id><author><name>ariels</name><uri>http://www.everything2.org:80/user/ariels</uri></author><published>2007-08-25T21:02:46Z</published><updated>2007-08-25T21:02:46Z</updated>
<content type="html">&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;
&lt;em&gt;Generic&lt;/em&gt; &lt;a href=&quot;/title/programming&quot;&gt;programming&lt;/a&gt; is a philosophy of programming that emphasizes the &lt;strong&gt;&lt;a href=&quot;/title/algorithm&quot;&gt;algorithm&lt;/a&gt;&lt;/strong&gt;, &lt;a href=&quot;/title/invented%252Fdiscovered&quot;&gt;invented/discovered&lt;/a&gt; by &lt;strong&gt;&lt;a href=&quot;/title/Alexander+Stepanov&quot;&gt;Alexander Stepanov&lt;/a&gt;&lt;/strong&gt;.  Its most famous incarnation is in the &lt;strong&gt;&lt;a href=&quot;/title/STL&quot;&gt;STL&lt;/a&gt;&lt;/strong&gt; of &lt;a href=&quot;/title/C%252B%252B&quot;&gt;C++&lt;/a&gt;; however it is quite distinct.  &lt;small&gt;Best to say that C++, as a multi-paradigmatic language, &lt;em&gt;also&lt;/em&gt; supports generic programming.&lt;/small&gt;
&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;
&lt;em&gt;At work we have a fairly complex Message class.  There are at least two different possible views of the contents of Message, neither of which exists in &lt;a href=&quot;/title/contiguous&quot;&gt;contiguous&lt;/a&gt; &lt;a href=&quot;/title/memory&quot;&gt;memory&lt;/a&gt;.  Just last week I got asked...&lt;/em&gt;
&lt;/p&gt;&lt;p&gt;
&quot;Do we have a &lt;em&gt;&lt;a href=&quot;/title/substring+find&quot;&gt;substring find&lt;/a&gt;&lt;/em&gt; &lt;a href=&quot;/title/algorithm&quot;&gt;algorithm&lt;/a&gt; on Messages?  And what about &lt;a href=&quot;/title/regular+expression&quot;&gt;regular expression&lt;/a&gt;s?  Do we have algorithms for those?  I looked and couldn't find any relevant &lt;a href=&quot;/title/method&quot;&gt;method&lt;/a&gt; in &lt;a href=&quot;/title/class&quot;&gt;class&lt;/a&gt; Message.&quot;
&lt;/p&gt;&lt;/blockquote&gt;
&lt;h2&gt;Algorithms&lt;/h2&gt;
&lt;p&gt;
Algorithms are a &lt;a href=&quot;/title/sequence&quot;&gt;sequence&lt;/a&gt; of &lt;a href=&quot;/title/step&quot;&gt;step&lt;/a&gt;s.  For example, an algorithm for finding a &lt;a href=&quot;/title/minimal&quot;&gt;minimal&lt;/a&gt;&amp;hellip;</content>
</entry><entry><title>Proof of Sperner's theorem (thing)</title><link rel="alternate" type="text/html" href="http://www.everything2.org:80/user/ariels/writeups/Proof+of+Sperner%2527s+theorem"/><id>http://www.everything2.org:80/user/ariels/writeups/Proof+of+Sperner%2527s+theorem</id><author><name>ariels</name><uri>http://www.everything2.org:80/user/ariels</uri></author><published>2007-07-30T06:36:38Z</published><updated>2007-07-30T06:36:38Z</updated>
<content type="html">&lt;p&gt;
This is about the &lt;em&gt;only&lt;/em&gt; &lt;a href=&quot;/title/proof&quot;&gt;proof&lt;/a&gt; I can come up with for &lt;strong&gt;&lt;a href=&quot;/title/Sperner%2527s+theorem&quot;&gt;Sperner's theorem&lt;/a&gt;&lt;/strong&gt; &lt;small&gt;(&lt;a href=&quot;/title/which+see&quot;&gt;which see&lt;/a&gt;)&lt;/small&gt;.  It's an interesting question whether other, structurally different, proofs exist.  In particular, a truly &lt;a href=&quot;/title/probabilistic+proof&quot;&gt;probabilistic proof&lt;/a&gt; &lt;small&gt;(not just rephrasing the &lt;a href=&quot;/title/counting+argument&quot;&gt;counting argument&lt;/a&gt; below in terms of &lt;a href=&quot;/title/probability&quot;&gt;probability&lt;/a&gt;)&lt;/small&gt; would be desirable (to me, at least).
&lt;/p&gt;
&lt;h3&gt;Proof.&lt;/h3&gt;
&lt;p&gt;
Suppose we have some &lt;strong&gt;&lt;a href=&quot;/title/antichain&quot;&gt;antichain&lt;/a&gt;&lt;/strong&gt; F on {1,...,n}.  Consider all &lt;a href=&quot;/title/ordered&quot;&gt;ordered&lt;/a&gt; &lt;strong&gt;&lt;a href=&quot;/title/permutation&quot;&gt;permutation&lt;/a&gt;s&lt;/strong&gt; a&lt;sub&gt;1&lt;/sub&gt;,a&lt;sub&gt;n&lt;/sub&gt;&amp;isin;{1,...,n} (that is, all &lt;em&gt;orderings&lt;/em&gt; of the numbers 1,...,n).  There are n! such orderings.  Now, the sequence of &lt;a href=&quot;/title/set&quot;&gt;set&lt;/a&gt;s
&lt;blockquote&gt;
{a&lt;sub&gt;1&lt;/sub&gt;} &amp;sube; {a&lt;sub&gt;1&lt;/sub&gt;,a&lt;sub&gt;2&lt;/sub&gt;} &amp;sube; ... &amp;sube; {a&lt;sub&gt;1&lt;/sub&gt;,a&lt;sub&gt;2&lt;/sub&gt;,...,a&lt;sub&gt;n&lt;/sub&gt;}
&lt;/blockquote&gt;
contains at most one &lt;a href=&quot;/title/element&quot;&gt;element&lt;/a&gt; of F (otherwise F is no antichain).
&lt;/p&gt;&lt;p&gt;
Suppose f&amp;isin;F has k elements. Then there are exactly k!(n-k)! orderings that intersect&amp;hellip;</content>
</entry><entry><title>Sperner's theorem (thing)</title><link rel="alternate" type="text/html" href="http://www.everything2.org:80/user/ariels/writeups/Sperner%2527s+theorem"/><id>http://www.everything2.org:80/user/ariels/writeups/Sperner%2527s+theorem</id><author><name>ariels</name><uri>http://www.everything2.org:80/user/ariels</uri></author><published>2007-06-28T15:17:12Z</published><updated>2007-06-28T15:17:12Z</updated>
<content type="html">&lt;h1&gt;&lt;a href=&quot;/title/Sperner%2527s+theorem&quot;&gt;Sperner's theorem&lt;/a&gt;&lt;/h1&gt;
&lt;h3&gt;(&lt;a href=&quot;/title/Combinatorics&quot;&gt;Combinatorics&lt;/a&gt;, &lt;a href=&quot;/title/finite+set+theory&quot;&gt;finite set theory&lt;/a&gt;:)&lt;/h3&gt;
&lt;p&gt;
  Sperner's theorem is an important example of &lt;a href=&quot;/title/extremal&quot;&gt;extremal&lt;/a&gt; problems in
  &lt;a href=&quot;/title/finite&quot;&gt;finite&lt;/a&gt; &lt;a href=&quot;/title/combinatorics&quot;&gt;combinatorics&lt;/a&gt;.  It establishes a &lt;a href=&quot;/title/bound&quot;&gt;bound&lt;/a&gt; on the largest
  possible size of a (hopefully interesting) &lt;a href=&quot;/title/configuration&quot;&gt;configuration&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
  What is the size of the largest possible &lt;a href=&quot;/title/antichain&quot;&gt;antichain&lt;/a&gt; on {1,2,...,n}?
  As the &lt;a href=&quot;/title/antichain&quot;&gt;antichain&lt;/a&gt; writeup shows, the set of all subsets of size k
  is an antichain.  The size of this antichain
  is &lt;big&gt;&lt;b&gt;C&lt;/b&gt;&lt;/big&gt;&lt;sub&gt;k,n&lt;/sub&gt;=n!/(k!&amp;sdot;(n-k)!).  The
  largest such antichain (for even n) is attained when k=n/2.  It
  turns out that this is, in fact, the largest &lt;em&gt;possible&lt;/em&gt;
  antichain.
&lt;/p&gt;
&lt;p&gt;
  &lt;blockquote&gt;&lt;strong&gt;&lt;a href=&quot;/title/Theorem&quot;&gt;Theorem&lt;/a&gt;.&lt;/strong&gt;
    The size of the largest possible antichain on {1,2,...,n} is
    &lt;blockquote&gt;
      &lt;big&gt;&lt;b&gt;C&lt;/b&gt;&lt;/big&gt;&lt;sub&gt;&amp;lfloor;n/2&amp;rfloor;,n&lt;/sub&gt; =
      n!/(&amp;lfloor;n/2&amp;rfloor;!&amp;sdot;&amp;lceil;n/2&amp;rceil;!)
    &lt;/blockquote&gt;
  &lt;/blockquote&gt;
&lt;/p&gt;
&lt;p&gt;
  Proofs of&amp;hellip;</content>
</entry><entry><title>antichain (thing)</title><link rel="alternate" type="text/html" href="http://www.everything2.org:80/user/ariels/writeups/antichain"/><id>http://www.everything2.org:80/user/ariels/writeups/antichain</id><author><name>ariels</name><uri>http://www.everything2.org:80/user/ariels</uri></author><published>2007-06-21T08:45:41Z</published><updated>2007-06-21T08:45:41Z</updated>
<content type="html">&lt;h3&gt;(&lt;a href=&quot;/title/Combinatorics&quot;&gt;Combinatorics&lt;/a&gt;, &lt;a href=&quot;/title/Set+Theory&quot;&gt;Set Theory&lt;/a&gt;, &lt;a href=&quot;/title/Logic&quot;&gt;Logic&lt;/a&gt;:)&lt;/h3&gt;
&lt;p&gt;
  In the combinatorics of &lt;a href=&quot;/title/set&quot;&gt;set&lt;/a&gt;s, especially &lt;a href=&quot;/title/finite+set&quot;&gt;finite set&lt;/a&gt;s,
  an &lt;em&gt;anti&lt;a href=&quot;/title/chain&quot;&gt;chain&lt;/a&gt;&lt;/em&gt; is a family &lt;b&gt;F&lt;/b&gt; of sets such that no
  member contains any other member:
  &lt;blockquote&gt;
    &amp;forall;x,y&amp;isin;&lt;b&gt;F&lt;/b&gt;. &amp;not;(x&amp;sub;y)
  &lt;/blockquote&gt;
&lt;/p&gt;
&lt;p&gt;
  More generally, we can define antichains whenever (P,&amp;lt;) is
  a &lt;em&gt;&lt;a href=&quot;/title/poset&quot;&gt;poset&lt;/a&gt;&lt;/em&gt; &lt;small&gt;(a &lt;a href=&quot;/title/partial+order&quot;&gt;partially order&lt;/a&gt;ed set)&lt;/small&gt;.  A subset F&amp;sube;P is an &lt;em&gt;antichain&lt;/em&gt; if no two elements of F can
  be compared:
  &lt;blockquote&gt;
    &amp;forall;x,y&amp;isin;F. &amp;not;(x&amp;lt;y)
  &lt;/blockquote&gt;
&lt;/p&gt;
&lt;p&gt;
  The definition for sets is a special case of the definition for
  posets (when the family &lt;b&gt;F&lt;/b&gt; is a set): take the poset
  (&lt;b&gt;F&lt;/b&gt;,&amp;sub;).
&lt;/p&gt;
&lt;h4&gt;&lt;a href=&quot;/title/Example&quot;&gt;Example&lt;/a&gt;s.&lt;/h4&gt;
&lt;ol&gt;
  &lt;li&gt;Let S be a set and k a &lt;a href=&quot;/title/natural+number&quot;&gt;natural number&lt;/a&gt;.  The set
    &lt;blockquote&gt;
      &lt;b&gt;F&lt;/b&gt;&lt;sub&gt;k&lt;/sub&gt;(S) = {x&amp;sube;S: |x|=k}
    &lt;/blockquote&gt;
    of all subsets of S of size k is an antichain.
  &lt;/li&gt;
  &lt;/ol&gt;&amp;hellip;</content>
</entry><entry><title>virtual destructor (thing)</title><link rel="alternate" type="text/html" href="http://www.everything2.org:80/user/ariels/writeups/virtual+destructor"/><id>http://www.everything2.org:80/user/ariels/writeups/virtual+destructor</id><author><name>ariels</name><uri>http://www.everything2.org:80/user/ariels</uri></author><published>2007-06-04T12:40:16Z</published><updated>2007-06-04T12:40:16Z</updated>
<content type="html">&lt;h3&gt;(&lt;a href=&quot;/title/C%252B%252B&quot;&gt;C++&lt;/a&gt;, and most likely &lt;em&gt;only&lt;/em&gt; C++:)&lt;/h3&gt;
&lt;h2&gt;A &lt;em&gt;&lt;a href=&quot;/title/destructor&quot;&gt;destructor&lt;/a&gt;&lt;/em&gt; that is &lt;a href=&quot;/title/virtual&quot;&gt;virtual&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;
  In &lt;a href=&quot;/title/C%252B%252B&quot;&gt;C++&lt;/a&gt;, a &lt;em&gt; virtual destructor&lt;/em&gt; is a destructor that
  happens to be a &lt;a href=&quot;/title/virtual+function&quot;&gt;virtual function&lt;/a&gt; &lt;small&gt; (which see, if you'd
    like a recap of why &lt;a href=&quot;/title/member+function&quot;&gt;member function&lt;/a&gt;s sometimes like to be
    virtual)&lt;/small&gt; . So, it gets called with (&lt;a href=&quot;/title/run+time&quot;&gt;run time&lt;/a&gt;)
  &lt;a href=&quot;/title/polymorphism&quot;&gt;polymorphism&lt;/a&gt;. &lt;/p&gt;
&lt;h2&gt;Why bother?&lt;/h2&gt;
&lt;p&gt;
  To apply run-time polymorphism in C++, you need to hold the &lt;a href=&quot;/title/object&quot;&gt;object&lt;/a&gt;
  itself, via &lt;a href=&quot;/title/pointer&quot;&gt;pointer&lt;/a&gt; or &lt;a href=&quot;/title/reference&quot;&gt;reference&lt;/a&gt;.  If ever you &lt;a href=&quot;/title/copy&quot;&gt;copy&lt;/a&gt; an object
  to a &lt;a href=&quot;/title/variable&quot;&gt;variable&lt;/a&gt; of a &lt;a href=&quot;/title/base+class&quot;&gt;base class&lt;/a&gt;, &lt;a href=&quot;/title/object+slicing&quot;&gt;object slicing&lt;/a&gt; takes place and
  your new copy has that class.
&lt;/p&gt;
&lt;p&gt;
  Now suppose you want to write code like this:
  &lt;blockquote&gt;&lt;pre&gt;
      &lt;a href=&quot;/title/class&quot;&gt;class&lt;/a&gt; X { &lt;a href=&quot;/title/%252F%252A&quot;&gt;/*&lt;/a&gt; ... */ };
      class Y : &lt;a href=&quot;/title/public&quot;&gt;public&lt;/a&gt; X { /* ... */ };

      X* make_a_new_X(int);

      void f(int t) {
        X* px = make_a_new_x(t);
        // do stuff with px
        &lt;a href=&quot;/title/delete&quot;&gt;delete&lt;/a&gt; px;
      }
  &lt;/pre&gt;&lt;/blockquote&gt;

This code works&amp;hellip;</content>
</entry></feed>
