Popular recipes tagged "structure"http://code.activestate.com/recipes/tags/structure/2012-05-14T16:49:13-07:00ActiveState Code RecipesHow to Mutate a Float (Python)
2012-05-14T16:49:13-07:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/578132-how-to-mutate-a-float/
<p style="color: grey">
Python
recipe 578132
by <a href="/recipes/users/2608421/">Stephen Chappell</a>
(<a href="/recipes/tags/ctypes/">ctypes</a>, <a href="/recipes/tags/experiment/">experiment</a>, <a href="/recipes/tags/float/">float</a>, <a href="/recipes/tags/structure/">structure</a>).
</p>
<p>This is just an experiment to test my mental understanding of Python. It should not be used in any code as is violates the design principle that floats are to be immutable. The code also abuses <code>ctypes</code> and an understanding of how <code>floats</code> are currently arranged in memory. <code>set_float</code> is not guaranteed to work properly on any system, and may fail to work in the future if the data's arrangement changes.</p>
2-3 Tree (Python)
2011-10-08T21:46:03-07:00Borishttp://code.activestate.com/recipes/users/4179529/http://code.activestate.com/recipes/577898-2-3-tree/
<p style="color: grey">
Python
recipe 577898
by <a href="/recipes/users/4179529/">Boris</a>
(<a href="/recipes/tags/2_3tree/">2_3tree</a>, <a href="/recipes/tags/algorithms/">algorithms</a>, <a href="/recipes/tags/data/">data</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/structure/">structure</a>, <a href="/recipes/tags/tree/">tree</a>).
</p>
<p>My implementation of 2-3 Trees on python</p>
Retrieving the median of a set in constant time (Python)
2011-04-19T15:00:57-07:00jimmy2timeshttp://code.activestate.com/recipes/users/4177690/http://code.activestate.com/recipes/577661-retrieving-the-median-of-a-set-in-constant-time/
<p style="color: grey">
Python
recipe 577661
by <a href="/recipes/users/4177690/">jimmy2times</a>
(<a href="/recipes/tags/data/">data</a>, <a href="/recipes/tags/heap/">heap</a>, <a href="/recipes/tags/median/">median</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/retrieving/">retrieving</a>, <a href="/recipes/tags/structure/">structure</a>).
Revision 2.
</p>
<p>Provides a data structure for a queue of integers whose get() method returns the median element. The interface is similar to the standard Queue module, with an added method top() to retrieve the median without removing it.</p>
Representing a set in a compact way (Python)
2011-04-24T10:55:45-07:00jimmy2timeshttp://code.activestate.com/recipes/users/4177690/http://code.activestate.com/recipes/577660-representing-a-set-in-a-compact-way/
<p style="color: grey">
Python
recipe 577660
by <a href="/recipes/users/4177690/">jimmy2times</a>
(<a href="/recipes/tags/compact/">compact</a>, <a href="/recipes/tags/compressed/">compressed</a>, <a href="/recipes/tags/data/">data</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/set/">set</a>, <a href="/recipes/tags/structure/">structure</a>).
Revision 5.
</p>
<p>Implements a data structure for sets of natural numbers, represented by a single integer. The interface is similar to the built-in structure 'set'.</p>
Matlab code for displaying 'struct' details (Python)
2008-09-05T13:31:54-07:00Kaushik Ghosehttp://code.activestate.com/recipes/users/4166965/http://code.activestate.com/recipes/576489-matlab-code-for-displaying-struct-details/
<p style="color: grey">
Python
recipe 576489
by <a href="/recipes/users/4166965/">Kaushik Ghose</a>
(<a href="/recipes/tags/matlab/">matlab</a>, <a href="/recipes/tags/recursion/">recursion</a>, <a href="/recipes/tags/structure/">structure</a>, <a href="/recipes/tags/tree/">tree</a>).
</p>
<p>This code, when passed a MATLAB structure, will recursively go into it and print out the form of the struct.</p>