Maybe a stupid idea

Kirk Strauser kirk at strauser.com
Wed Dec 31 19:45:05 CET 2003

```-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

At 2003-12-31T17:49:55Z, sebb at linuxcult.com (sebb) writes:

> I thought about that because it's not very easy to program a cycle.

Your example doesn't really define a cycle.  What is it?  A loop from
start-val to end-val to start-val?

>>> def cycle(a,b):
...     return range(a,b)+range(b,a,-1)
...
>>> cycle(0,10)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]

> Here is a simple example :
>
> b=0
>
> while b < 50:
>     b+=1
>     print "*" * b
>
> while b > 0:
>     b-= 1
>     print "*" * b

for length in cycle(0,50):
print "*" * length

There you go, and it didn't even take a new language structure.  :)
- --
Kirk Strauser
The Strauser Group
Open. Solutions. Simple.
http://www.strausergroup.com/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQE/8xj95sRg+Y0CpvERAmRzAJ49ZjF7tBXPrMQ8VnpeB0tvMHb5gQCeJ7cO
+r9MHpgTAA9nZmdrTGBDGOo=
=Apc/
-----END PGP SIGNATURE-----

```