Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

give access to iterators #52

Open
videlec opened this issue Jan 4, 2018 · 3 comments
Open

give access to iterators #52

videlec opened this issue Jan 4, 2018 · 3 comments

Comments

@videlec
Copy link
Collaborator

videlec commented Jan 4, 2018

There are several useful iterators defined in PARI/GP (forperm, forprime, forqvec, ...). They are used as functions (like the standard for loops).

? forperm(3, p, print(p))
Vecsmall([1, 2, 3])
Vecsmall([1, 3, 2])
Vecsmall([2, 1, 3])
Vecsmall([2, 3, 1])
Vecsmall([3, 1, 2])
Vecsmall([3, 2, 1])

cypari2 should provide access to these as proper iterators such as

>>> for p in pari.forperm(3):
...     print(p)

Note: iterators can be recognized by the prototype character I.

@videlec videlec changed the title give access to itertors give access to iterators Jan 4, 2018
@jdemeyer
Copy link
Collaborator

jdemeyer commented Jan 10, 2018

Note that GP has various different syntaxes for loops, for example:

forperm(a,p,seq)                  # Prototype: vGVI
forell(E,a,b,seq,{flag=0})        # Prototype: vVLLID0,L,
forpart(X=k,seq,{a=k},{n=k})      # Prototype: vV=GIDGDG

Implementation-wise, this difference shouldn't matter though. But it might be harder for the user to determine how to translate GP code to cypari2.

@jdemeyer
Copy link
Collaborator

We might want to shorten forperm to perms but there might be some name collision.

I would keep the GP name, otherwise it will just be harder to find for the user.

@jdemeyer
Copy link
Collaborator

I might work on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants