Ask Your Question
1

breaking out of while, for loops.

asked 2014-11-22 11:04:18 +0100

anonymous user

Anonymous

updated 2014-11-23 06:38:25 +0100

vdelecroix gravatar image

Hello.

Actually, my problem is to get all new representatives.

But I think it is only an algorithmic problem to me.

My consideration is following:

  1. Let A be a group and Rep=[A]. And i=0

  2. Make i=i+1 and the list L of all subgroups with index 2^i.

  3. Make empty list New.

  4. For B in L, if B is not conjugate to any group in Rep then add to Rep and add to New else do nothing.

  5. If New is empty then return Rep else make New empty list and go to STEP 2.

How can I do this in SAGE....

I cannot give a simple example. :(

In my problem,

  1. A=[1,x,x^2], Rep=[A], i=0 (A is a generator of the rank 3 Z-module in Z[x])

  2. i=i+1, L : the list of all submodule of A with index 2^i.

  3. New=[]

  4. For B in L, [ For C in Rep, t=False, if B~C then t=true. ] If t=False then Rep=Rep+[B] and New=New+[B]

  5. If len(New)==0 then return Rep else New=[] and go to STEP 2.

If you have some question I WILL answer as soon as possible. :)

Thanks.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2014-11-22 17:44:38 +0100

Here are two example functions illustrating breaking out of while and for loops:

def f():
    index = 0
    while True:
        print index
        index += 1
        if index >= 4:
            break

def g():
    for i in range(10):
        if i >= 5:
            continue
        print i
edit flag offensive delete link more

Comments

Thanks! It's useful to me. Using that algorithm, I solved my problem, roughly~. :)

Semin gravatar imageSemin ( 2014-11-23 14:15:19 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-11-22 11:04:18 +0100

Seen: 6,176 times

Last updated: Nov 22 '14