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 | Branch a
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
On Wed, Jan 21, 2015 at 9:15 AM, Ian Kelly ian.g.ke...@gmail.com 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,
On Wed, Jan 21, 2015 at 7:47 AM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info 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
Rustom Mody rustompm...@gmail.com 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]
--
On Tue, Jan 20, 2015 at 6:23 PM, Rustom Mody rustompm...@gmail.com 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
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])
*Main bfs
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 rst) --
On Wed, Jan 21, 2015 at 10:20 PM, Rustom Mody rustompm...@gmail.com 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
On Wed, Jan 21, 2015 at 11:56 PM, Ian Kelly ian.g.ke...@gmail.com 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
Ian Kelly ian.g.ke...@gmail.com 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
Stephen Hansen me+pyt...@ixokai.io:
On Tue, Jan 20, 2015 at 1:45 AM, Marko Rauhamaa ma...@pacujo.net wrote:
Terry Reedy tjre...@udel.edu:
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
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
On Wed, Jan 21, 2015 at 11:55 PM, Tim Chase
python.l...@tim.thechases.com 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
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 ma...@pacujo.net wrote:
Terry Reedy tjr...@udel.edu:
Others have answered as to why other special-purpose
constrained-structure trees have not been added to
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
Type help,
On Wed, Jan 21, 2015 at 11:09 PM, Rustom Mody rustompm...@gmail.com 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
On Thu, Jan 22, 2015 at 1:26 AM, Tim Chase
python.l...@tim.thechases.com 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
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
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
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
code,
On Mon, Jan 19, 2015 at 11:52 PM, Devin Jeanpierre
jeanpierr...@gmail.com wrote:
On Mon, Jan 19, 2015 at 3:08 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
Zachary Gilmartin wrote:
Why aren't there trees in the python standard library?
Possibly because they aren't needed?
Terry Reedy tjre...@udel.edu:
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,
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 sequences can
On 20/01/2015 05:19, Marko Rauhamaa wrote:
Mark Lawrence breamore...@yahoo.co.uk:
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
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 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
On Mon, Jan 19, 2015 at 6:46 PM, Mark Lawrence breamore...@yahoo.co.uk
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
Rustom Mody rustompm...@gmail.com:
Yeah python has trees alright.
Does Python balance them for you?
Marko
--
https://mail.python.org/mailman/listinfo/python-list
On Tue, Jan 20, 2015 at 6:33 AM, Rustom Mody rustompm...@gmail.com 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
Marko Rauhamaa ma...@pacujo.net 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
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.I
L =
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 than I
Marko Rauhamaa ma...@pacujo.net 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?
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info 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
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/
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
On Wed, Jan 21, 2015 at 7:15 AM, Ken Seehart k...@seehart.com 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
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 d34dbfbe-fe82-47dc-8bc3-c8773e2b7...@googlegroups.com,
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
Rustom Mody rustompm...@gmail.com 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
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]
bfs (B x
On 20 January 2015 at 04:21, Dan Stromberg drsali...@gmail.com wrote:
On Mon, Jan 19, 2015 at 6:46 PM, Mark Lawrence breamore...@yahoo.co.uk
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
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 21/01/2015 01:22, Joshua Landau wrote:
On 20 January 2015 at 04:21, Dan Stromberg drsali...@gmail.com wrote:
On Mon, Jan 19, 2015 at 6:46 PM, Mark Lawrence breamore...@yahoo.co.uk wrote:
I don't know if you've seen this http://kmike.ru/python-data-structures/ but
maybe of interest.
I've
On 1/20/2015 4:47 PM, Mario wrote:
In article d34dbfbe-fe82-47dc-8bc3-c8773e2b7...@googlegroups.com,
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
On Tue, Jan 20, 2015 at 5:22 PM, Joshua Landau jos...@landau.ws wrote:
On 20 January 2015 at 04:21, Dan Stromberg drsali...@gmail.com wrote:
On Mon, Jan 19, 2015 at 6:46 PM, Mark Lawrence breamore...@yahoo.co.uk
wrote:
I don't know if you've seen this http://kmike.ru/python-data-structures/
On Tue, Jan 20, 2015 at 1:45 AM, Marko Rauhamaa ma...@pacujo.net wrote:
Terry Reedy tjre...@udel.edu:
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
Paul Rubin no.email@nospam.invalid:
Marko Rauhamaa ma...@pacujo.net 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
Paul Rubin no.email@nospam.invalid:
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
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 rhetorical
On Mon, Jan 19, 2015 at 3:08 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info 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
On Mon, Jan 19, 2015 at 2:06 PM, Zachary Gilmartin
zacharygilmar...@gmail.com 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
On Mon, Jan 19, 2015 at 6:46 PM, Mark Lawrence breamore...@yahoo.co.uk wrote:
On 20/01/2015 00:49, Dan Stromberg wrote:
On Mon, Jan 19, 2015 at 2:06 PM, Zachary Gilmartin
zacharygilmar...@gmail.com wrote:
Why aren't there trees in the python standard library?
Trees are kind of specialized
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 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 dict or
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
On Mon, Jan 19, 2015 at 11:21 PM, Dan Stromberg drsali...@gmail.com wrote:
On Mon, Jan 19, 2015 at 6:46 PM, Mark Lawrence breamore...@yahoo.co.uk
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,
In article mailman.17862.1421705173.18130.python-l...@python.org,
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
On 20/01/2015 00:49, Dan Stromberg wrote:
On Mon, Jan 19, 2015 at 2:06 PM, Zachary Gilmartin
zacharygilmar...@gmail.com 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
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
Mark Lawrence breamore...@yahoo.co.uk:
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
Zachary Gilmartin zacharygilmar...@gmail.com 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
On Tue, Jan 20, 2015 at 9:16 AM, Ben Finney ben+pyt...@benfinney.id.au 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
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'])
subtree
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:
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 !-)
--
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 python
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...
/F
--
http://mail.python.org/mailman/listinfo/python-list
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:
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
--
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
They have great
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.
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
it,
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
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
Would this be for a GUI toolkit or maybe using a standard class scheme?
--
http://mail.python.org/mailman/listinfo/python-list
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 Scientific
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]
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
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
81 matches
Mail list logo