On 3 Nov 2008 22:13:42 GMT, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> On Mon, 03 Nov 2008 21:09:58 +, Jorgen Grahn wrote:
>
>> Why multi-threading? I see no concurrency in the original algorithm.
>> There is, in my mind, nothing concurrent about 'yield'.
>
> No "real" concurrency b
On Nov 3, 11:45 pm, [EMAIL PROTECTED] wrote:
>
> Thats interesting code but seems to give a different output,
> suggesting thet the underlying algorithm is different.
> Ignoring linebreaks and case, the original code gives:
> abcd bacd bcad bcda acbd cabd cbad cbda acdb cadb cdab cdba abdc badc
> b
[EMAIL PROTECTED] writes:
[...]
> Thats interesting code but seems to give a different output,
> suggesting thet the underlying algorithm is different.
Yes.
Yours takes the first element out of the list and inserts it in every
position of all the permutations of the list without the first element
On 2 Nov, 22:03, Carsten Haese <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > Anyway what I want to do is experiment with code similar to this (i.e.
> > same algorithm and keep the recursion) in other languages,
> > particularly vbscript and wondered what it would look like if it was
> >
On Nov 3, 4:24 pm, Michele Simionato <[EMAIL PROTECTED]>
wrote:
> On Nov 2, 10:34 pm, [EMAIL PROTECTED] wrote:
>
> > Anyway what I want to do is experiment with code similar to this (i.e.
> > same algorithm and keep the recursion) in other languages,
> > particularly vbscript and wondered what it w
On Nov 3, 4:13 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> On Mon, 03 Nov 2008 21:09:58 +, Jorgen Grahn wrote:
> > Why multi-threading? I see no concurrency in the original algorithm.
> > There is, in my mind, nothing concurrent about 'yield'.
>
> No "real" concurrency but a gene
On Mon, 03 Nov 2008 21:09:58 +, Jorgen Grahn wrote:
> Why multi-threading? I see no concurrency in the original algorithm.
> There is, in my mind, nothing concurrent about 'yield'.
No "real" concurrency but a generator can be seen as independent thread
of code where the generator code is al
On Sun, 2 Nov 2008 14:09:01 -0800 (PST), Aaron Brady <[EMAIL PROTECTED]> wrote:
> On Nov 2, 3:34 pm, [EMAIL PROTECTED] wrote:
...
>> for x in all_permx("ABCD"):
>> print x
...
> I think multi-threading is the "truest" to the original. You might
> develop a framework to set events when particula
On Nov 2, 10:34 pm, [EMAIL PROTECTED] wrote:
> Anyway what I want to do is experiment with code similar to this (i.e.
> same algorithm and keep the recursion) in other languages,
> particularly vbscript and wondered what it would look like if it was
> rewritten to NOT use the yield statement - or a
Steve Holden wrote:
[EMAIL PROTECTED] wrote:
Anyway what I want to do is experiment with code similar to this (i.e.
same algorithm and keep the recursion) in other languages,
particularly vbscript and wondered what it would look like if it was
rewritten to NOT use the yield statement - or at l
[EMAIL PROTECTED] wrote:
> Hello, can someone please help.
>
> I found the following code at http://code.activestate.com/recipes/252178/
>
> def all_perms(str):
> if len(str) <=1:
> yield str
> else:
> for perm in all_perms(str[1:]):
> for i in range(len(perm)+
On Nov 2, 3:34 pm, [EMAIL PROTECTED] wrote:
> Hello, can someone please help.
>
> I found the following code athttp://code.activestate.com/recipes/252178/
>
> def all_perms(str):
> if len(str) <=1:
> yield str
> else:
> for perm in all_perms(str[1:]):
> for i in
[EMAIL PROTECTED] wrote:
> Anyway what I want to do is experiment with code similar to this (i.e.
> same algorithm and keep the recursion) in other languages,
> particularly vbscript and wondered what it would look like if it was
> rewritten to NOT use the yield statement
An obvious (though memory
[EMAIL PROTECTED] writes:
> Anyway what I want to do is experiment with code similar to this (i.e.
> same algorithm and keep the recursion) in other languages,
> particularly vbscript and wondered what it would look like if it was
> rewritten to NOT use the yield statement -
Without the yield sta
Hello, can someone please help.
I found the following code at http://code.activestate.com/recipes/252178/
def all_perms(str):
if len(str) <=1:
yield str
else:
for perm in all_perms(str[1:]):
for i in range(len(perm)+1):
#nb str[0:1] works in bot
Talin wrote:
> I'm sure I am not the first person to do this, but I wanted to share
> this: a generator which returns all permutations of a list:
>
> def permute( lst ):
> if len( lst ) == 1:
> yield lst
> else:
> head = lst[:1]
> for x in permute( lst[1:] ):
>
On Mon, 15 Aug 2005, Matt Hammond wrote:
> Just satisfied my curiosity wrt this problem, so I might as well share :-)
>
def permute(list):
How about:
def permutation(l, i):
"Makes the ith permutation of the sequence l."
# leave out the reverses if you don't care about the or
Just satisfied my curiosity wrt this problem, so I might as well share :-)
>>> def permute(list):
... if len(list) <= 1:
... yield list
... else:
... for i in xrange(0,len(list)):
... for tail in permute( list[:i] + list[i+1:] ):
... yield [ list
nd Permutations" - 2005
Can you elaborate a bit on what you mean?
Given a list of unique elements, it is easy enough to produce a
complete permutation generator in Python,
in the sense that it yields every possible permuation.
(See my previous post.) So you must mean
something else?
Che
It's hard to make "complete" permutation generators, Knuth has a whole
fascicle on it - "The Art of Computer Programming - Volume 4 Fascicle
2 - Generating All Tuples and Permutations" - 2005
--
Regards,
Casey
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, Aug 12, 2005 at 03:48:38PM -0400, Michael J. Fromberger wrote:
> In article <[EMAIL PROTECTED]>,
> Talin <[EMAIL PROTECTED]> wrote:
>
> > I'm sure I am not the first person to do this, but I wanted to share
> > this: a generator which returns all permutations of a list:
>
> You're right
On Fri, 12 Aug 2005 12:39:08 -0700, Talin wrote:
> I'm sure I am not the first person to do this, but I wanted to share
> this: a generator which returns all permutations of a list:
>
> def permute( lst ):
> if len( lst ) == 1:
> yield lst
> else:
> head = lst[:1]
>
"Talin" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I wanted to share
> this: a generator which returns all permutations of a list:
Try this instead:
def permuteg(lst): return ([lst[i]]+x
for i in range(len(lst))
for x in permute(lst[:i]+lst[i+1:])) \
or [[]
Talin <[EMAIL PROTECTED]> writes:
> I'm sure I am not the first person to do this, but I wanted to share
> this: a generator which returns all permutations of a list:
>
> def permute( lst ):
> if len( lst ) == 1:
> yield lst
> else:
> head = lst[:1]
> for x in permu
In article <[EMAIL PROTECTED]>,
Talin <[EMAIL PROTECTED]> wrote:
> I'm sure I am not the first person to do this, but I wanted to share
> this: a generator which returns all permutations of a list:
>
> def permute( lst ):
> if len( lst ) == 1:
> yield lst
> else:
> head
I'm sure I am not the first person to do this, but I wanted to share
this: a generator which returns all permutations of a list:
def permute( lst ):
if len( lst ) == 1:
yield lst
else:
head = lst[:1]
for x in permute( lst[1:] ):
yield head + x
26 matches
Mail list logo