Ask Your Question
0

on what structures is possible to iterate?

asked 2016-12-24 15:48:09 +0200

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

I need to do a for loop on MatrixSpace(MatrixSpace(GF(2), 2), 1, 2) but it turns out to be impossible. Is there anyway to get around it?

Also, as the title says, on what structures is possible to iterate? I would imagine in structures with a natural order, but I am not sure about it.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-12-25 16:16:27 +0200

ndomes gravatar image

I think you need a nested for loop. For example:

N = MatrixSpace(GF(2), 2)([0,1,1,0])
M = MatrixSpace(MatrixSpace(GF(2), 2), 1, 2)
M1 = M((N,N))
show(M1)
for m in M1.list():
    for k in m.list():
        print k

You can iterate over any sequence. If your respective object isn't a sequence, look if it has a list method.

edit flag offensive delete link more

Comments

@ndomes Thanks for your answer. But is it possible to iterate on the entire space M? It does not have a list method.

xhimi gravatar imagexhimi ( 2016-12-29 18:27:52 +0200 )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: 2016-12-24 15:48:09 +0200

Seen: 350 times

Last updated: Dec 25 '16