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

Feature Request: filtering in comprehensions #1256

Closed
kmsquire opened this issue Sep 5, 2012 · 2 comments
Closed

Feature Request: filtering in comprehensions #1256

kmsquire opened this issue Sep 5, 2012 · 2 comments

Comments

@kmsquire
Copy link
Member

kmsquire commented Sep 5, 2012

Comprehensions' offer an easy-to-understand paradigm for map-like operations:

bases = ['A', 'C', 'G', 'T']
basemap = map(i -> bases[i & 3 + 1], [0:255])
basemap2 = [ bases[i & 3 + 1] for i in 0:255 ]
assert(basemap == basemap2)

Some languages (Python, Scala, at least) add syntax to comprehensions to allow filtering of output values:

# Python
xs = range(1,101)
prime_100 = filter(isprime, xs)  # assumes isprime is defined
prime_100_2 = [x for x in xs if isprime(x)]
assert(prime_100 == prime_100_2)

It would be nice if julia supported a similar syntax.

@JeffBezanson
Copy link
Member

Dup of #550.

@kmsquire
Copy link
Member Author

kmsquire commented Sep 5, 2012

Sorry, need to search the issues more carefully...

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