Skip to content

Feature Request: filtering in comprehensions #1256

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

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...

jishnub added a commit that referenced this issue Apr 23, 2025
)

Stdlib: LinearAlgebra
URL: https://github.com/JuliaLang/LinearAlgebra.jl.git
Stdlib branch: master
Julia branch: master
Old commit: 1ce8426
New commit: 07725da
Julia version: 1.13.0-DEV
LinearAlgebra version: 1.12.0(Does not match)
Bump invoked by: @jishnub
Powered by:
[BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl)

Diff:
JuliaLang/LinearAlgebra.jl@1ce8426...07725da

```
$ git log --oneline 1ce8426..07725da
07725da Branch on `Bool` `alpha` in scaling `mul!` (#1286)
61e444d Fix exponentiation with immutable matrix (#1289)
77475c1 Fix `lmul!`/`rmul!` for 0-sized matrices (#1290)
c3d35c0 Test for `versioninfo` with `ENV` variable (#1279)
830ea2f Fit broken matmul test (#1288)
222f7f2 Propagate inbounds in diagzero (#1285)
e65e75c Clean up `herk_wrapper!` and add 5-arg tests (#1254)
ece1962 `versioninfo`: simplify, improve type stability (#1274)
3e525a8 Speicalize `copy!` for triangular, and use `copy!` in `ldiv` (#1263)
763f19f Forward scaling `lmul!`/`rmul!` for `Tridiagonal` to bands (#1284)
2d27d1c Explicit loop in converting `Bidiagonal`/`Tridiagonal` to `Matrix` (#1283)
0671a7b Simplify small Bidiagonal-AbstractVecOrMat multiplication (#1278)
a8fd121 Test for empty `Symmetric` and `BlasFlag.NONE` (#1280)
6e2de14 Remove bounds-checking in `Bidiagonal` `rdiv!` (#1281)
4a8fc62 Test for 5-arg `mul!`
c437beb Test for empty `Symmetric` and `BlasFlag.NONE`
7a891e9 Test for `versioninfo` with `ENV` variable
84fd21b Test for `versioninfo` (#1276)
243efdb `AbstractQ` bugfix: define `Base.IteratorSize` (#1277)
6073f28 Ease inference in `Bidiagonal` divmul tests (#1273)
30cb5d6 Avoid copy in empty bidiag `ldiv!` (#1275)
5d3ef46 Skip symmetry check in converting Symmetric to SymTridiagonal (#1269)
ae5385b Specialize `isreal` for banded matrices (#1271)
0a253be Explicit loop in `_iszero` for strided views (#1264)
3f46f5f `istril`/`istriu` for opposite triangularity (#1265)
cd048eb Tests for `mul!` scaling with mismatched axes (#1266)
26db4c8 Restrict tests to `Number` eltypes
8b21ca6 Tests for `mul!` scaling with mismatched axes
9675c38 Fix minimum band for `UpperTriangular`/`Lowertriangular`
aeeed7d Add unit triangular tests
3e1aaac Add banded tests
7fdfb3b Add tests
d866014 istril/istriu for opposite triangularity
925acef Return view in `_diag` for `Bidiagonal` (#1258)
b1bcca1 Branch on `Bool` `alpha` in diagonal matmul (#1256)
e3e9987 `peakflops`: make `eltype` a static parameter of the method (#1253)
781eb5d `peakflops`: make the element type a static parameter of the method
e53b50c use smaller matrix size in `peakflops` on 32-bit (#1255)
0c87d0d use smaller matrix size in `peakflops` on 32-bit
0cbf85f Check approx equality in bunchkaufman docstring (#1251)
5e53d12 Avoid accessing unset indices in symmetric copyto! (#1244)
e64a3df fix dispatch to herk (#1247)
bfdb742 Destination zeros from eltype in zero-length generic_matvecmul (#1241)
16dedb5 Remove redundant adjoint/transpose methods for Symmetric/Hermitian (#1245)
7f1dfe4 stop assuming that you can mutate data structures in other packages at precompile time (#1252)
```

Co-authored-by: jishnub <[email protected]>
LebedevRI pushed a commit to LebedevRI/julia that referenced this issue May 2, 2025
…iaLang#58180)

Stdlib: LinearAlgebra
URL: https://github.com/JuliaLang/LinearAlgebra.jl.git
Stdlib branch: master
Julia branch: master
Old commit: 1ce8426
New commit: 07725da
Julia version: 1.13.0-DEV
LinearAlgebra version: 1.12.0(Does not match)
Bump invoked by: @jishnub
Powered by:
[BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl)

Diff:
JuliaLang/LinearAlgebra.jl@1ce8426...07725da

```
$ git log --oneline 1ce8426..07725da
07725da Branch on `Bool` `alpha` in scaling `mul!` (JuliaLang#1286)
61e444d Fix exponentiation with immutable matrix (JuliaLang#1289)
77475c1 Fix `lmul!`/`rmul!` for 0-sized matrices (JuliaLang#1290)
c3d35c0 Test for `versioninfo` with `ENV` variable (JuliaLang#1279)
830ea2f Fit broken matmul test (JuliaLang#1288)
222f7f2 Propagate inbounds in diagzero (JuliaLang#1285)
e65e75c Clean up `herk_wrapper!` and add 5-arg tests (JuliaLang#1254)
ece1962 `versioninfo`: simplify, improve type stability (JuliaLang#1274)
3e525a8 Speicalize `copy!` for triangular, and use `copy!` in `ldiv` (JuliaLang#1263)
763f19f Forward scaling `lmul!`/`rmul!` for `Tridiagonal` to bands (JuliaLang#1284)
2d27d1c Explicit loop in converting `Bidiagonal`/`Tridiagonal` to `Matrix` (JuliaLang#1283)
0671a7b Simplify small Bidiagonal-AbstractVecOrMat multiplication (JuliaLang#1278)
a8fd121 Test for empty `Symmetric` and `BlasFlag.NONE` (JuliaLang#1280)
6e2de14 Remove bounds-checking in `Bidiagonal` `rdiv!` (JuliaLang#1281)
4a8fc62 Test for 5-arg `mul!`
c437beb Test for empty `Symmetric` and `BlasFlag.NONE`
7a891e9 Test for `versioninfo` with `ENV` variable
84fd21b Test for `versioninfo` (JuliaLang#1276)
243efdb `AbstractQ` bugfix: define `Base.IteratorSize` (JuliaLang#1277)
6073f28 Ease inference in `Bidiagonal` divmul tests (JuliaLang#1273)
30cb5d6 Avoid copy in empty bidiag `ldiv!` (JuliaLang#1275)
5d3ef46 Skip symmetry check in converting Symmetric to SymTridiagonal (JuliaLang#1269)
ae5385b Specialize `isreal` for banded matrices (JuliaLang#1271)
0a253be Explicit loop in `_iszero` for strided views (JuliaLang#1264)
3f46f5f `istril`/`istriu` for opposite triangularity (JuliaLang#1265)
cd048eb Tests for `mul!` scaling with mismatched axes (JuliaLang#1266)
26db4c8 Restrict tests to `Number` eltypes
8b21ca6 Tests for `mul!` scaling with mismatched axes
9675c38 Fix minimum band for `UpperTriangular`/`Lowertriangular`
aeeed7d Add unit triangular tests
3e1aaac Add banded tests
7fdfb3b Add tests
d866014 istril/istriu for opposite triangularity
925acef Return view in `_diag` for `Bidiagonal` (JuliaLang#1258)
b1bcca1 Branch on `Bool` `alpha` in diagonal matmul (JuliaLang#1256)
e3e9987 `peakflops`: make `eltype` a static parameter of the method (JuliaLang#1253)
781eb5d `peakflops`: make the element type a static parameter of the method
e53b50c use smaller matrix size in `peakflops` on 32-bit (JuliaLang#1255)
0c87d0d use smaller matrix size in `peakflops` on 32-bit
0cbf85f Check approx equality in bunchkaufman docstring (JuliaLang#1251)
5e53d12 Avoid accessing unset indices in symmetric copyto! (JuliaLang#1244)
e64a3df fix dispatch to herk (JuliaLang#1247)
bfdb742 Destination zeros from eltype in zero-length generic_matvecmul (JuliaLang#1241)
16dedb5 Remove redundant adjoint/transpose methods for Symmetric/Hermitian (JuliaLang#1245)
7f1dfe4 stop assuming that you can mutate data structures in other packages at precompile time (JuliaLang#1252)
```

Co-authored-by: jishnub <[email protected]>
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