Re: Creating Linked Lists in Python

2009-04-07 Thread andrew cooke
J-Burns wrote: > How can I do this? And if I could do this by some other way than using > linked lists than do tell me about that as well. replying to this dead thread mainly for anyone using google. there's now a python regular expression engine in lepl and the source code can be seen via http:/

Re: Creating Linked Lists in Python

2009-03-28 Thread Aahz
In article , andrew cooke wrote: >Aahz wrote: >> In article , >> andrew cooke wrote: >> >>>(I've just noticed that the comments in Sequence are incorrect, >>>unfortunately - please ignore any mention of "index"). >> >> s/comments/lies/ per my .sig ;-) >[...] >> "At Resolver we've found it useful

Re: Creating Linked Lists in Python

2009-03-28 Thread andrew cooke
Aahz wrote: > In article , > andrew cooke wrote: >>(I've just noticed that the comments in Sequence are incorrect, >>unfortunately - please ignore any mention of "index"). > > s/comments/lies/ per my .sig ;-) [...] > "At Resolver we've found it useful to short-circuit any doubt and just > refer t

Re: Creating Linked Lists in Python

2009-03-28 Thread Aahz
In article , andrew cooke wrote: > >(I've just noticed that the comments in Sequence are incorrect, >unfortunately - please ignore any mention of "index"). s/comments/lies/ per my .sig ;-) -- Aahz (a...@pythoncraft.com) <*> http://www.pythoncraft.com/ "At Resolver we've found

Re: Creating Linked Lists in Python

2009-03-28 Thread andrew cooke
J-Burns wrote: [...] > and to node 2 with the value of "b". Trying to make something like an > NFA. Where id be changing regular expressions to NFAs. > > How can I do this? And if I could do this by some other way than using > linked lists than do tell me about that as well. Just been reminded of

Re: Creating Linked Lists in Python

2009-03-21 Thread Roy Smith
In article , Tim Chase wrote: > In the past, I've done NFA with a state machine: What I've done at times is have each state be a function. The function returns an (output, next_state) tuple, and the main loop becomes something like this: state = start for input in whatever: output, stat

Re: Creating Linked Lists in Python

2009-03-21 Thread grocery_stocker
On Mar 21, 10:03 am, Tim Chase wrote: > >>>transitions = { > >>> # values are tuples of (newstate, transition_function) > >>> STATE_A: [ > >>>(STATE_B, lambda x: x > 5), > >>>(STATE_C, lambda x: x > 10), > >>>(STATE_D, lambda x: x > 100), > >>>], > >>>

Re: Creating Linked Lists in Python

2009-03-21 Thread Aaron Brady
On Mar 21, 10:47 am, grocery_stocker wrote: > On Mar 21, 6:38 am, Tim Chase wrote: > > > > > > For example, this means that there can be a start node supposedly. > > > Having a value of 0. It is pointing to node 1 with the value of "a" > > > and to node 2 with the value of "b". Trying to make som

Re: Creating Linked Lists in Python

2009-03-21 Thread Tim Chase
transitions = { # values are tuples of (newstate, transition_function) STATE_A: [ (STATE_B, lambda x: x > 5), (STATE_C, lambda x: x > 10), (STATE_D, lambda x: x > 100), ], STATE_B: [ (STATE_A, lambda x: x < 5), (STATE_C, lambda x: x > 10)

Re: Creating Linked Lists in Python

2009-03-21 Thread grocery_stocker
On Mar 21, 8:47 am, grocery_stocker wrote: > On Mar 21, 6:38 am, Tim Chase wrote: > > > > > > For example, this means that there can be a start node supposedly. > > > Having a value of 0. It is pointing to node 1 with the value of "a" > > > and to node 2 with the value of "b". Trying to make some

Re: Creating Linked Lists in Python

2009-03-21 Thread grocery_stocker
On Mar 21, 6:38 am, Tim Chase wrote: > > For example, this means that there can be a start node supposedly. > > Having a value of 0. It is pointing to node 1 with the value of "a" > > and to node 2 with the value of "b". Trying to make something like an > > NFA. Where id be changing regular expres

Re: Creating Linked Lists in Python

2009-03-21 Thread Giuliano Vilela
I've done something similar on the past week, regarding RE's and NFA's: http://code.google.com/p/yaree/ The significant code is on re_fsa.py, on the svn repository. The implementation is also a dict, of the form: { Node -> { Character -> Set(Node) } }. That is, it is a mapping of Node's to a mappi

Re: Creating Linked Lists in Python

2009-03-21 Thread Tim Chase
For example, this means that there can be a start node supposedly. Having a value of 0. It is pointing to node 1 with the value of "a" and to node 2 with the value of "b". Trying to make something like an NFA. Where id be changing regular expressions to NFAs. John has already pointed out the pre

Re: Creating Linked Lists in Python

2009-03-21 Thread Aaron Brady
On Mar 21, 8:11 am, "andrew cooke" wrote: > J-Burns wrote: snip > > For example, this means that there can be a start node supposedly. > > Having a value of 0. It is pointing to node 1 with the value of "a" > > and to node 2 with the value of "b". Trying to make something like an > > NFA. Where id

Re: Creating Linked Lists in Python

2009-03-21 Thread andrew cooke
andrew cooke wrote: [...] i messed up my example; corrected below (I hope) > in your case you could use ints for the nodes and a dict([int]) for the > graph. so: > {1: [2,3], 2: [1,3], 3: [3]} > > is a graph in which 1 and 2 are connected in each direction, both 1 and 2 > are linked to 3, and 3

Re: Creating Linked Lists in Python

2009-03-21 Thread andrew cooke
J-Burns wrote: > I need to make a linked list that can do the following: > > 1) Point to multiple nodes at one time > 2) Should have 2 values: > a) The node no. > b) The value of that node in reference to the next node that it is > pointing to > > For example, this means that there can be a

Re: Creating Linked Lists in Python

2009-03-21 Thread John Machin
On Mar 21, 10:38 pm, J-Burns wrote: > Hey thr, > > I need some help here actually. So i thought i could get it easily > from here. > > I need to make a linked list that can do the following: > > 1) Point to multiple nodes at one time The term "linked list" is usually restricted to a collection of

Creating Linked Lists in Python

2009-03-21 Thread J-Burns
Hey thr, I need some help here actually. So i thought i could get it easily from here. I need to make a linked list that can do the following: 1) Point to multiple nodes at one time 2) Should have 2 values: a) The node no. b) The value of that node in reference to the next node that it i