On Thursday, January 22, 2015 at 12:46:22 PM UTC+5:30, Paul Rubin wrote:
> Ian Kelly writes:
> > How do you create a tree containing an even number of elements under
> > this constraint?
>
> That's a good point, I've usually seen different definitions of trees,
> e.g.
>
>data Tree a = Leaf |
Ian Kelly writes:
> How do you create a tree containing an even number of elements under
> this constraint?
That's a good point, I've usually seen different definitions of trees,
e.g.
data Tree a = Leaf | Branch a (Tree a) (Tree a)
so a Leaf node doesn't have a value associated with it.
h
On Wed, Jan 21, 2015 at 10:20 PM, Rustom Mody wrote:
> On Thursday, January 22, 2015 at 4:25:03 AM UTC+5:30, Ian wrote:
>> On Tue, Jan 20, 2015 at 6:23 PM, Rustom Mody wrote:
>> > The Haskell is bullseye¹ in capturing the essense of a tree because
>> > conceptually a tree of type t is recursive in
On Wed, Jan 21, 2015 at 11:56 PM, Ian Kelly wrote:
> Since each element is associated with a node, the question could
> equally be phrased as "How do you create a tree containing an even
> number of elements under this constraint?"
Of course I meant to write "nodes" there, not "elements".
--
htt
On Thursday, January 22, 2015 at 4:25:03 AM UTC+5:30, Ian wrote:
> On Tue, Jan 20, 2015 at 6:23 PM, Rustom Mody wrote:
> > The Haskell is bullseye¹ in capturing the essense of a tree because
> > conceptually a tree of type t is recursive in the sense that it can contain
> > 2 subtrees -- (B x lst r
On Thursday, January 22, 2015 at 3:57:50 AM UTC+5:30, Paul Rubin wrote:
> Rustom Mody writes:
> > Thats not bfs. That's inorder traversal
>
> Oops, you're right. How's this:
>
> bfs x = go [x] where
> go [] = []
> go (L x:ts) = x:go ts
> go (B x lst rst:ts) = x : go (ts ++ [lst, rst])
>
On Tue, Jan 20, 2015 at 6:23 PM, Rustom Mody wrote:
> The Haskell is bullseye¹ in capturing the essense of a tree because
> conceptually a tree of type t is recursive in the sense that it can contain
> 2 subtrees -- (B x lst rst) -- or its a base case -- L x.
How do you create a tree containing a
Rustom Mody writes:
> Thats not bfs. That's inorder traversal
Oops, you're right. How's this:
bfs x = go [x] where
go [] = []
go (L x:ts) = x:go ts
go (B x lst rst:ts) = x : go (ts ++ [lst, rst])
*Main> bfs t
[6,2,8,1,4,7,9,3,5]
--
https://mail.python.org/mailman/listinfo/python-list
On Wed, Jan 21, 2015 at 9:15 AM, Ian Kelly wrote:
> class MultiSet(MutableSet):
In retrospect this probably shouldn't derive from MutableSet, since
that carries the expectation that all elements are unique (much like
how bool shouldn't be subclassed). For instance, collections.Set
includes some o
On Wed, Jan 21, 2015 at 7:47 AM, Steven D'Aprano
wrote:
>> More irksome that for the second we've to preface with
>>
>> from collections import Counter
>>
>> And still more a PITA that a straightforward standard name like bag (or
>> multiset) is called by such an ungoogleable misleading name as co
On Wednesday, January 21, 2015 at 6:06:06 PM UTC+5:30, Chris Angelico wrote:
> On Wed, Jan 21, 2015 at 11:09 PM, Rustom Mody wrote:
> > I would like a set to be {1,2,3} or at worst ⦃1,2,3⦄
> > and a bag to be ⟅1,2,3⟆
> >
> > Apart from the unicode niceness that Ive described here
> > http://blog.l
Rustom Mody wrote:
> On Wednesday, January 21, 2015 at 1:27:39 PM UTC+5:30, Stephen Hansen
> wrote:
[...]
> Among my teachers of CS, there were two – both brilliant — one taught me
> Numerical Analysis, the other taught me programming.
I wonder just how brilliant the Numerical Analysis guy really
On Thu, Jan 22, 2015 at 1:26 AM, Tim Chase
wrote:
> While 2.0 is certainly antiquated, Red Hat Enterprise Linux (RHEL) is
> often considered the best definition of what's considered "oldest
> supported production environment". RHEL v4 ships with Py2.3 and one
> can still obtain extended support f
On 2015-01-22 00:01, Chris Angelico wrote:
> On Wed, Jan 21, 2015 at 11:55 PM, Tim Chase
>>> Looks like {1,2,3} works for me.
>>
>> That hasn't always worked:
>
> the argument's still fairly weak when it's alongside a pipe-dream
> desire to use specific mathematical Unicode characters in source
>
Hello Terry,
It is not play with words. A tree is a recursive - nested -
hierachical
data structure with the restriction of no cycles or alternate
pathways.
Python collections whose members are general objects, including
collections, can be nested. The resulting structures *are* tree
structures
On Wed, Jan 21, 2015 at 11:55 PM, Tim Chase
wrote:
> On 2015-01-21 23:35, Chris Angelico wrote:
>> On Wed, Jan 21, 2015 at 11:09 PM, Rustom Mody wrote
>> > Its a bit of a nuisance that we have to write set([1,2,3]) for
>> > the first
>>
>> Looks like {1,2,3} works for me.
>
> That hasn't always wo
On 2015-01-21 23:35, Chris Angelico wrote:
> On Wed, Jan 21, 2015 at 11:09 PM, Rustom Mody wrote
> > Its a bit of a nuisance that we have to write set([1,2,3]) for
> > the first
>
> Wait, what?
>
> rosuav@sikorsky:~$ python
> Python 2.7.3 (default, Mar 13 2014, 11:03:55)
> [GCC 4.7.2] on linux2
>
On Wed, Jan 21, 2015 at 11:09 PM, Rustom Mody wrote:
> I would like a set to be {1,2,3} or at worst ⦃1,2,3⦄
> and a bag to be ⟅1,2,3⟆
>
> Apart from the unicode niceness that Ive described here
> http://blog.languager.org/2014/04/unicoded-python.html
>
> Its a bit of a nuisance that we have to wri
On Wednesday, January 21, 2015 at 1:27:39 PM UTC+5:30, Stephen Hansen wrote:
> On Tue, Jan 20, 2015 at 1:45 AM, Marko Rauhamaa wrote:
> Terry Reedy :
>
>
>
> > Others have answered as to why other special-purpose
>
> > constrained-structure trees have not been added to the stdlib.
>
>
>
> O
Stephen Hansen :
> On Tue, Jan 20, 2015 at 1:45 AM, Marko Rauhamaa wrote:
>> Terry Reedy :
>> > Others have answered as to why other special-purpose
>> > constrained-structure trees have not been added to the stdlib.
>>
>> Ordered O(log n) mappings are not special-purpose data structures. I'd
>>
Hash Table, Christiania
(a table with many kinds of hash)
On 1/20/2015 12:19 PM, Devin Jeanpierre wrote:
There are similarly many kinds of hash tables.
For a given use case (e.g. a sorted dict, or a list with efficient
removal, etc.), there's a few data structures that make sense, and a
library
On Tue, Jan 20, 2015 at 1:45 AM, Marko Rauhamaa wrote:
> Terry Reedy :
>
> > Others have answered as to why other special-purpose
> > constrained-structure trees have not been added to the stdlib.
>
> Ordered O(log n) mappings are not special-purpose data structures. I'd
> say strings and floats
On Tue, Jan 20, 2015 at 5:22 PM, Joshua Landau wrote:
> On 20 January 2015 at 04:21, Dan Stromberg wrote:
>> On Mon, Jan 19, 2015 at 6:46 PM, Mark Lawrence
>> wrote:
>>>
>>> I don't know if you've seen this http://kmike.ru/python-data-structures/ but
>>> maybe of interest.
>>
>> I've seen it. I
On 21/01/2015 01:22, Joshua Landau wrote:
On 20 January 2015 at 04:21, Dan Stromberg wrote:
On Mon, Jan 19, 2015 at 6:46 PM, Mark Lawrence wrote:
I don't know if you've seen this http://kmike.ru/python-data-structures/ but
maybe of interest.
I've seen it. It's a nice page.
I attempted to
On 1/20/2015 4:47 PM, Mario wrote:
In article ,
rustompm...@gmail.com says...
Yeah python has trees alright.
Heres' some simple tree-code
Didn't you just demonstrate that Python has no trees and instead you
have to implement them yourself (or use a third-party implementation)?
I don't know
On Wednesday, January 21, 2015 at 7:19:39 AM UTC+5:30, Paul Rubin wrote:
> Rustom Mody writes:
> > ## The depth first algorithm
> > dfs (L x) = [x]
> > dfs (B x lst rst) = [x] ++ dfs lst ++ dfs rst
>
> Cute. I can't resist posting the similar breadth first algorithm:
>
> bfs (L x) = [x]
Rustom Mody writes:
> ## The depth first algorithm
> dfs (L x) = [x]
> dfs (B x lst rst) = [x] ++ dfs lst ++ dfs rst
Cute. I can't resist posting the similar breadth first algorithm:
bfs (L x) = [x]
bfs (B x lst rst) = bfs lst ++ [x] ++ bfs rst
> *Main> dfs t
> [6,2,1,4,3,5,8,7,9]
*
On Wednesday, January 21, 2015 at 3:18:03 AM UTC+5:30, Mario wrote:
> rustompmody says...
> >
> > Yeah python has trees alright.
> >
> > Heres' some simple tree-code
>
> Didn't you just demonstrate that Python has no trees and instead you
> have to implement them yourself (or use a third-party
On 20 January 2015 at 04:21, Dan Stromberg wrote:
> On Mon, Jan 19, 2015 at 6:46 PM, Mark Lawrence
> wrote:
>>
>> I don't know if you've seen this http://kmike.ru/python-data-structures/ but
>> maybe of interest.
>
> I've seen it. It's a nice page.
>
> I attempted to get my treap port in there s
On 20/01/15 01:49, Dan Stromberg wrote:
I think probably the most common need for a tree is implementing a
cache,
That is probably true, at least if you're a squirrel.
--
https://mail.python.org/mailman/listinfo/python-list
In article ,
rustompm...@gmail.com says...
>
> Yeah python has trees alright.
>
> Heres' some simple tree-code
Didn't you just demonstrate that Python has no trees and instead you
have to implement them yourself (or use a third-party implementation)?
I don't know what's the point of all this
Paul Rubin :
> You could look up the "timer wheel" approach used by the Linux kernel
> and by Erlang. It's less general than an ordered map, but probably
> faster in practice.
>
> https://lkml.org/lkml/2005/10/19/46
>
> Has some info. I think the kernel uses a different method now though.
I
Paul Rubin :
> Marko Rauhamaa writes:
>> So in my Python software (both at work and at home) needs, I use a
>> Python AVL tree implementation of my own. My use case is timers. (GvR
>> uses heapq for the purpose.)
>
> Have you benchmarked your version against heapq or even the builtin
> sorting fu
On Wed, Jan 21, 2015 at 7:15 AM, Ken Seehart wrote:
> Exactly. There are over 23,000 different kinds of trees. There's no way you
> could get all of them to fit in a library, especially a standard one.
> Instead, we prefer to provide people with the tools they need to grow their
> own trees.
I'm
There are similarly many kinds of hash tables.
For a given use case (e.g. a sorted dict, or a list with efficient
removal, etc.), there's a few data structures that make sense, and a
library (even the standard library) doesn't have to expose which one
was picked as long as the performance is good.
Exactly. There are over 23,000 different kinds of trees. There's no way
you could get all of them to fit in a library, especially a standard
one. Instead, we prefer to provide people with the tools they need to
grow their own trees.
http://caseytrees.org/programs/planting/ctp/
http://www.ncsu.
On Tuesday, January 20, 2015 at 11:46:11 PM UTC+5:30, Rustom Mody wrote:
> On Tuesday, January 20, 2015 at 10:51:13 PM UTC+5:30, Ian wrote:
> > On Tue, Jan 20, 2015 at 6:33 AM, Rustom Mody wrote:
> > > # Converting to generators is trivial
> > > =
> >
> > :-)
>
> Less trivial
Marko Rauhamaa writes:
> As I said, I use ordered mappings to implement timers... The downside
> of heapq is that canceled timers often flood the heapq structure...,
> GvR mentioned a periodic "garbage collection" as a potentially
> effective solution.
You could look up the "timer wheel" approac
On Tuesday, January 20, 2015 at 10:51:13 PM UTC+5:30, Ian wrote:
> On Tue, Jan 20, 2015 at 6:33 AM, Rustom Mody wrote:
> > from enum import Enum
> > class TreeTag(Enum):
> > I = 0 # An internal node
> > L = 1 # A leaf node
> > def __repr__(self): return self.name
> >
> > I = TreeTag
Steven D'Aprano writes:
> Possibly because they aren't needed? Under what circumstances would
> you use a tree instead of a list or a dict or combination of both?
I've sometimes wanted a functional tree in the sense of functional
programming. That means the tree structure is immutable and you in
Marko Rauhamaa writes:
> So in my Python software (both at work and at home) needs, I use a
> Python AVL tree implementation of my own. My use case is timers. (GvR
> uses heapq for the purpose.)
Have you benchmarked your version against heapq or even the builtin
sorting functions?
--
https://mai
On Tue, Jan 20, 2015 at 6:33 AM, Rustom Mody wrote:
> from enum import Enum
> class TreeTag(Enum):
> I = 0 # An internal node
> L = 1 # A leaf node
> def __repr__(self): return self.name
>
> I = TreeTag.I
> L = TreeTag.L
Explicitly tagging nodes as internal or leaves is kind of ugl
On Tuesday, January 20, 2015 at 7:46:02 PM UTC+5:30, Marko Rauhamaa wrote:
> Rustom Mody :
>
> > Yeah python has trees alright.
>
> Does Python balance them for you?
No
Does python support a menagerie of lists like C
- singly linked, doubly linked, with header, without header etc?
Or access to
On 20/01/2015 05:19, Marko Rauhamaa wrote:
Mark Lawrence :
On 19/01/2015 22:06, Zachary Gilmartin wrote:
Why aren't there trees in the python standard library?
Probably because you'd never get agreement as to which specific tree
and which specific implementation was the most suitable for inc
Rustom Mody :
> Yeah python has trees alright.
Does Python balance them for you?
Marko
--
https://mail.python.org/mailman/listinfo/python-list
On Mon, Jan 19, 2015 at 6:46 PM, Mark Lawrence
wrote:
> I don't know if you've seen this http://kmike.ru/python-data-structures/
> but maybe of interest.
>
I haven't read but also possibly of interest:
Data Structures and Algorithms in Python by Michael T. Goodrich, Roberto
Tamassia, Michael H.
On Tuesday, January 20, 2015 at 7:03:56 PM UTC+5:30, Rustom Mody wrote:
> On Tuesday, January 20, 2015 at 11:38:27 AM UTC+5:30, Terry Reedy wrote:
> > On 1/19/2015 5:06 PM, Zachary Gilmartin wrote:
> > > Why aren't there trees in the python standard library?
> >
> > Sequences nested withing sequen
On Tuesday, January 20, 2015 at 11:38:27 AM UTC+5:30, Terry Reedy wrote:
> On 1/19/2015 5:06 PM, Zachary Gilmartin wrote:
> > Why aren't there trees in the python standard library?
>
> Sequences nested withing sequences can be regarded as trees, and Python
> has these. I regard Lisp as a tree pr
Terry Reedy :
> Others have answered as to why other special-purpose
> constrained-structure trees have not been added to the stdlib.
Ordered O(log n) mappings are not special-purpose data structures. I'd
say strings and floats are much more special-purpose than ordered
mappings, and yet Python h
On Mon, Jan 19, 2015 at 11:52 PM, Devin Jeanpierre
wrote:
> On Mon, Jan 19, 2015 at 3:08 PM, Steven D'Aprano
> wrote:
>> Zachary Gilmartin wrote:
>>
>>> Why aren't there trees in the python standard library?
>>
>> Possibly because they aren't needed? Under what circumstances would you use
>> a tr
On 1/19/2015 5:06 PM, Zachary Gilmartin wrote:
Why aren't there trees in the python standard library?
Sequences nested withing sequences can be regarded as trees, and Python
has these. I regard Lisp as a tree processing languages, as it must be
to manipulate, for example, code with nested st
Mark Lawrence :
> On 19/01/2015 22:06, Zachary Gilmartin wrote:
>> Why aren't there trees in the python standard library?
>
> Probably because you'd never get agreement as to which specific tree
> and which specific implementation was the most suitable for inclusion.
Most programming languages pr
On Mon, Jan 19, 2015 at 11:21 PM, Dan Stromberg wrote:
> On Mon, Jan 19, 2015 at 6:46 PM, Mark Lawrence
> wrote:
> > On 20/01/2015 00:49, Dan Stromberg wrote:
> >>
>
apropos of nothing, I went to stonybrook too. beee 1978
> >> On Mon, Jan 19, 2015 at 2:06 PM, Zachary Gilmartin
> >> wrote:
>
On Mon, Jan 19, 2015 at 6:46 PM, Mark Lawrence wrote:
> On 20/01/2015 00:49, Dan Stromberg wrote:
>>
>> On Mon, Jan 19, 2015 at 2:06 PM, Zachary Gilmartin
>> wrote:
>>>
>>> Why aren't there trees in the python standard library?
>>
>>
>> Trees are kind of specialized datastructures; no one type of
On 20/01/2015 00:49, Dan Stromberg wrote:
On Mon, Jan 19, 2015 at 2:06 PM, Zachary Gilmartin
wrote:
Why aren't there trees in the python standard library?
Trees are kind of specialized datastructures; no one type of tree
solves all tree-related problems suitably well.
I think probably the mo
On Mon, Jan 19, 2015 at 2:06 PM, Zachary Gilmartin
wrote:
> Why aren't there trees in the python standard library?
Trees are kind of specialized datastructures; no one type of tree
solves all tree-related problems suitably well.
I think probably the most common need for a tree is implementing a
In article ,
zacharygilmar...@gmail.com says...
>
> Why aren't there trees in the python standard library?
I don't know much about python development process and strategies, but I
suspect it shouldn't be much different from any other language I know
of. So here's my tentative answer:
Once gen
On 2015-01-19 16:19, Michael Torrie wrote:
> On 01/19/2015 04:08 PM, Steven D'Aprano wrote:
> > Zachary Gilmartin wrote:
> >> Why aren't there trees in the python standard library?
> >
> > Possibly because they aren't needed? Under what circumstances
> > would you use a tree instead of a list or a
On Mon, Jan 19, 2015 at 3:08 PM, Steven D'Aprano
wrote:
> Zachary Gilmartin wrote:
>
>> Why aren't there trees in the python standard library?
>
> Possibly because they aren't needed? Under what circumstances would you use
> a tree instead of a list or a dict or combination of both?
>
> That's not
On 01/19/2015 04:08 PM, Steven D'Aprano wrote:
> Zachary Gilmartin wrote:
>
>> Why aren't there trees in the python standard library?
>
> Possibly because they aren't needed? Under what circumstances would you use
> a tree instead of a list or a dict or combination of both?
>
> That's not a rhet
Zachary Gilmartin wrote:
> Why aren't there trees in the python standard library?
Possibly because they aren't needed? Under what circumstances would you use
a tree instead of a list or a dict or combination of both?
That's not a rhetorical question. I am genuinely curious, what task do you
have
On 19/01/2015 22:06, Zachary Gilmartin wrote:
Why aren't there trees in the python standard library?
Probably because you'd never get agreement as to which specific tree and
which specific implementation was the most suitable for inclusion.
--
My fellow Pythonistas, ask not what our languag
On Tue, Jan 20, 2015 at 9:16 AM, Ben Finney wrote:
> If you're asking because you think all data structures magically appear
> in the standard library by wishing it so, I think you over-estimate the
> powers of the standard library maintainers.
Oh come on Ben. Guido has a time machine; TimSort is
Zachary Gilmartin writes:
> Why aren't there trees in the python standard library?
What sort of answer are you looking for? There are many ways that
question could be intended.
If you're asking about what could be keeping a particular tree
implementation out of the standard library: that depend
At Sunday 31/12/2006 14:25, vertigo wrote:
I use nltk package - but it should not matter here.
Yes, it does. The framework should provide some form of tree traversal.
So i wanted to 'travel thru my tree' to last node which should be changed:
>>> tree6 = Tree('main', ['sub1', 'sub2'])
>>> sub
John Nagle wrote:
>SpeedTree, of course.
>
> http://www.speedtree.com
>
>They have great downloadable demos.
And how do you distribute the code in a python program?
Is there a wrapper for an available static library
or do I have to compile the speedtree source when
running the pytho
Raymond Hettinger a écrit :
> vertigo wrote:
>
>>What library/functions/classes could i use to create trees ?
>
>
> Start with random.seed, login as root, use svn to download the trunk
> and branches, when Spring arrives, the leaves will fill-in ;-)
keyboard !-)
--
http://mail.python.org/mailm
vertigo wrote:
> What library/functions/classes could i use to create trees ?
Start with random.seed, login as root, use svn to download the trunk
and branches, when Spring arrives, the leaves will fill-in ;-)
Or just use lists as Fredrik suggested.
Or look at an example in the cookbook:
http://
You could use ElementTree for XML.
Or just use nested dictionaries.
-T
John Nagle wrote:
> Delaney, Timothy (Tim) wrote:
> > vertigo wrote:
> >
> >
> >>Hello
> >>
> >>What library/functions/classes could i use to create trees ?
>
> SpeedTree, of course.
>
> http://www.speedtree.com
>
>
Delaney, Timothy (Tim) wrote:
> vertigo wrote:
>
>
>>Hello
>>
>>What library/functions/classes could i use to create trees ?
SpeedTree, of course.
http://www.speedtree.com
They have great downloadable demos.
John Nagle
--
http://mail.py
vertigo wrote:
> Hello
>
> What library/functions/classes could i use to create trees ?
I would suggest either a horticultural or religious class. I'm sure that
any library will contain functional texts on both.
Or you could just read the following:
http://www.catb.org/~esr/faqs/smart-questions
vertigo wrote:
> What library/functions/classes could i use to create trees ?
what kind of trees? using lists, tuples, or a class with child pointers
is so extremely simple so it has to be something else you're after...
--
http://mail.python.org/mailman/listinfo/python-list
> Writing a *simple* node class is easy, but a full-featured one that
> supports things like comparison and easy iteration is a bit more work. So
> various people write partial implementations with only the features they
> need, and they all end up being incompatible. So beyond being able to use
>
Alex Le Dain <[EMAIL PROTECTED]> writes:
>Is there a generic "tree" module that can enable me to sort and use
>trees (and nodes). Basically having methods such as .AddNode(),
>.GetAllChildren(), .FindNode() etc.
http://newcenturycomputers.net/projects/rbtree.html
might do most of what you want
Alex Le Dain said unto the world upon 2005-02-27 19:54:
> Would this be for a GUI toolkit or maybe using a standard
> class scheme?
Sorry, yes I should have been more specific. I meant a non-GUI, standard
class scheme. I want to use the scheme to hold a structure in memory and
retrieve/add info
> Would this be for a GUI toolkit or maybe using a standard
> class scheme?
Sorry, yes I should have been more specific. I meant a non-GUI, standard
class scheme. I want to use the scheme to hold a structure in memory and
retrieve/add information to it.
I've had a couple of goes myself but get a
Diez B. Roggisch wrote:
Or writing a Node-class is also so straightforward that few care about them
being part of the core:
Writing a *simple* node class is easy, but a full-featured one that supports
things like comparison and easy iteration is a bit more work. So various people
write partial im
[Alex Le Dain]
> Is there a generic "tree" module that can enable me to sort and use
> trees (and nodes). Basically having methods such as .AddNode(),
> .GetAllChildren(), .FindNode() etc.
> Is this handled natively with any of the core modules?
Using only standard Python, look at the suite of `
Alex Le Dain wrote:
> Is there a generic "tree" module that can enable me to sort and use
> trees (and nodes). Basically having methods such as .AddNode(),
> .GetAllChildren(), .FindNode() etc.
No. Usually, one uses the built-in python datastructures for this. E.g.
('root', [('child1', None), (
Alex Le Dain wrote:
> Is there a generic "tree" module that can enable me to sort and use
> trees (and nodes). Basically having methods such as .AddNode(),
> .GetAllChildren(), .FindNode() etc.
>
> Is this handled natively with any of the core modules?
>
> cheers, Alex.
>
> --
> Poseidon Scientifi
Would this be for a GUI toolkit or maybe using a standard class scheme?
--
http://mail.python.org/mailman/listinfo/python-list
81 matches
Mail list logo