[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-list
Subject:    Re: counting using variable length string as base
From:       castironpi () gmail ! com
Date:       2008-03-27 11:28:51
Message-ID: a01ee901-037e-4c35-a84d-56a442161e80 () k13g2000hse ! googlegroups ! com
[Download RAW message or body]

On Mar 27, 4:01 am, Peter Otten <__pete...@web.de> wrote:
> Grimsqueaker wrote:
> > That seems to give me the items in the list back in an iterator. Am I
> > using it incorrectly?
>
> With Dan's functions in cartesian.py you can do the following:
>
> >>> from cartesian import *
> >>> def count(digits):
>
> ...     args = []
> ...     while 1:
> ...             args.append(digits)
> ...             for n in string_cartesian_product(*args):
> ...                     yield n
> ...>>> from itertools import islice
> >>> print " ".join(islice(count("abc"), 30))
>
> a b c aa ab ac ba bb bc ca cb cc aaa aab aac aba abb abc aca acb acc baa bab
> bac bba bbb bbc bca bcb bcc

For the base, we Arabics use the cardinal; what letters you count in
doesn't change anything.  Don't just spell out numbers, unless: Are
you reading marked-tally.  Or do you want to yield a word and see the
number that it spells out to?  Be there or be around.  I'm bad at
spelling, but I can rearrange linear.
-- 
http://mail.python.org/mailman/listinfo/python-list

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic