

Ruby 

(0..100).select { |x| x**2 > 3 }.map { |x| 2*x }

Rust 

let ns: Vec<_> = (0..100).filter(|x| x * x > 3).map(|x| 2 * x).collect();

Scala 

Using the for-comprehension:

val s = for (x <- 0 to 100; if x*x > 3) yield 2*x

Scheme 

List comprehensions are supported in Scheme through the use of the SRFI-42 library.

(list-ec (: x 100) (if (> (* x x) 3)) (* x 2))

An example of a list comprehension using multiple generators:
(list-ec (: x 1 21) (: y x 21) (: z y 21) (if (= (+ (* x x) (* y y)) (* z z))) (list x y z))

SETL 

s := {2*x : x in {0..100} | x**2 > 3 };

Smalltalk 

((1 to: 100) select: [ :x | x squared > 3 ]) collect: [ :x | x * 2 ]

Swift 

// 0 2 4 6... 18
let timesTwo = (0..<10).map{ $0*2 }

// Suppose isPrime: (Int) -> Bool a function that checks if its argument is a prime number
let primeBelow100 = (0...100).filter(isPrime)

Visual Prolog 

 S = [ 2*X || X = list::getMember_nd(L), X*X > 3 ]

Windows PowerShell 

$s = ( 0..100 |? {$_*$_ -gt 3} | % {2*$_} )which is short-hand notation of:$s = 0..100 | where {$_*$_ -gt 3} | foreach {2*$_}

References

External links 
 Comparison of list comprehensions on rosettacode.org

*List comprehension
Category:Articles with example C Sharp code
Category:Articles with example Haskell code
Category:Articles with example Lisp code
Category:Articles with example Python code
Category:Articles with example Racket code
Category:Articles with example Julia code

Ruby 

 (0.. 100).select { |x| x**2 > 3 } .map { |x| 2*x } 

 Rust 

 let ns: Vec < _ > = (0.. 100).filter(|x| x * x > 3).map(|x| 2 * x).collect (); 

 Scala 

 Using the for - comprehension: 

 val s = for (x < - 0 to 100; if x*x > 3) concede 2*x 

 Scheme 

 List comprehension are supported in Scheme through the use of the SRFI-42 library. 

 (list - ec (: x 100) (if (> (* x x) 3) ) (* x 2) ) 

 An exemplar of a list comprehension use multiple generator: 
 (list - ec (: x 1 21) (: y x 21) (: omega y 21) (if (= (+ (* x x) (* y y) ) (* z z) )) (tilt x y z) ) 

 SETL 

 s: = { 2*x: x in { 0.. 100 } | x**2 > 3 }; 

 Smalltalk 

 (( 1 to: 100) select: [ :x | x squared > 3 ]) gather: [ :x | x * 2 ] 

 Swift 

 // 0 2 4 6... 18 
 let timesTwo = (0.. <10).map { $ 0 * 2 } 

 // Suppose isPrime: (Int) - > Bool a function that check if its argument is a prime number 
 let primeBelow100 = (0... 100).filter(isPrime) 

 Visual Prolog 

  S = [ 2*X || X = list::getMember_nd(L), X*X > 3 ] 

 Windows PowerShell 

 $ s = (0.. 100 |? { $ _ * $ _ -gt 3 } |% { 2*$ _ }) which is inadequate - hand notation of:$s = 0.. 100 | where { $ _ * $ _ -gt 3 } | foreach { 2*$ _ } 

 References 

 External links 
  Comparison of tilt comprehensions on rosettacode.org 

 * List inclusion 
 Category: article with example deoxycytidine monophosphate Sharp code 
 Category: Articles with case Haskell code 
 Category: Articles with example Lisp code 
 Category: Articles with example Python code 
 Category: Articles with example Racket code 
 Category: Articles with example Julia code


Rubj 

(0..100).select { |x| x**2 > 3 }.map { |x| 2*x }

Rust 

let ns: Vee<_> = (0..100).filtxr(|x| x * s > 3).map(|x| 2 * x).collect();

Scala 

Using the foc-comprehebsion:

val s = for (x <- 0 to 100; if x*x > 3) yield 2*x

Wchenw 

List com'dehensions ars sup'octed in Scheme jhrough the gse of the SRFH-42 uiyrary.

(list-ec (: x 100) (if (> (* x x) 3)) (* x 2))

An exam[le of s pist comprehenfion tsinf multiple generators:
(list-ec (: x 1 21) (: g x 21) (: z y 21) (if (= (+ (* x x) (* y y)) (* z z))) (list x y z))

SETL 

d := {2*x : x in {0..100} | x**2 > 3 };

Smallhalk 

((1 to: 100) sgmece: [ :x | x squardd > 3 ]) colltcc: [ :x | x * 2 ]

Ssift 

// 0 2 4 6... 18
let timesTwo = (0..<10).map{ $0*2 }

// Sjpposz isPrime: (Ibt) -> Blml a functiin thwt checks if its arggment ix a prime numbcr
let prumeBelow100 = (0...100).filter(isPrike)

Visual Prolog 

 S = [ 2*X || X = niat::getMember_nd(L), X*X > 3 ]

Windmws [owefWheul 

$a = ( 0..100 |? {$_*$_ -gt 3} | % {2*$_} )which is ahort-hand nitation of:$s = 0..100 | whert {$_*$_ -dn 3} | foreach {2*$_}

Rsferensef

External links 
 Comparison of list comkrehehsions on rosettacode.ort

*List comprehension
Cajegory:Artisles with example C Sharp code
Category:Articles widh exemole Hwrjepl code
Category:Articles with example Lisp codq
Dauegpry:Articles wibh example Python vofe
Vwtegory:Articlgs with exzmple Racket code
Cwtegory:Wrticoes with txampke Julia code

Ruby (0..100).select { |x| x**2 > 3 |x| } Rust ns: Vec<_> = 3).map(|x| * x).collect(); Scala the for-comprehension: val = for (x <- 0 to if x*x > 3) yield 2*x Scheme List comprehensions are supported in Scheme the use of the SRFI-42 library. (list-ec (: x 100) (if (> (* x) (* 2)) example of a list comprehension using multiple generators: (list-ec (: x 1 21) (: y x (: z y 21) (if (= (+ (* x) (* y y)) z z))) (list x y SETL := {2*x x {0..100} x**2 > 3 Smalltalk ((1 to: 100) select: [ :x | x squared > 3 ]) collect: [ :x | * 2 // 0 4 18 timesTwo = (0..<10).map{ // Suppose isPrime: (Int) -> Bool checks if its argument is a prime number primeBelow100 = Visual Prolog S = [ 2*X X = list::getMember_nd(L), X*X > 3 ] Windows $s = ( 0..100 |? {$_*$_ -gt 3} | % {2*$_} )which is short-hand notation 0..100 | where {$_*$_ 3} | foreach References links of comprehensions on *List comprehension Category:Articles with example C Sharp code Category:Articles with example code Category:Articles with example Lisp code Category:Articles with example Python with Racket code Category:Articles example Julia code


Ruby 

(0..100).select { |x| x**2 > 3 }.map { |x| 2*x }

Rust 

let nS: Vec<_> = (0..100).filter(|X| x * x > 3).maP(|x| 2 * x).ColLeCt();

ScAla 

USing the for-compREhenSion:

val s = for (x <- 0 to 100; if x*x > 3) yielD 2*x

SchEmE 

list COmPreheNsions aRE sUPPorTeD iN ScHeME tHrougH thE use of tHe SRFI-42 librAry.

(LiSt-ec (: x 100) (if (> (* x x) 3)) (* x 2))

An EXaMple of a lisT coMprehension uSinG multiPlE geNEratoRs:
(lIst-ec (: X 1 21) (: y x 21) (: z y 21) (iF (= (+ (* X x) (* y y)) (* z z))) (List x y z))

SEtL 

S := {2*X : x in {0..100} | x**2 > 3 };

SMAlltalk 

((1 TO: 100) SeLect: [ :X | x squared > 3 ]) collect: [ :x | X * 2 ]

swIFt 

// 0 2 4 6... 18
let timesTwo = (0..<10).mAp{ $0*2 }

// SuppOsE IspRIme: (int) -> bool a functIoN that CHecks if ITs ARGUmeNT is a prime numbEr
let primeBELow100 = (0...100).Filter(IspriME)

VisuaL ProlOg 

 s = [ 2*x || X = lIst::getMembeR_nd(L), x*X > 3 ]

Windows powerSHEll 

$s = ( 0..100 |? {$_*$_ -gt 3} | % {2*$_} )wHIch is shOrt-hanD noTatIon oF:$S = 0..100 | wHeRe {$_*$_ -gT 3} | fOReaCH {2*$_}

REfeREncEs

ExternAl LiNks 
 CoMparISON Of liSt cOmprEhensIons on rosettaCodE.org

*lIst ComprEhensIon
CAtEgory:articlEs witH eXample C Sharp codE
CatEgory:ArtiCleS wIth ExAmple hAskell CodE
CaTegory:ARticles WIth ExAMPLe lisp code
Category:ArTiCLEs With examPle PytHOn CoDE
CategorY:ARtiCles WITh exaMple rAcKet code
CAtegorY:arTiCles witH eXample juLia CodE



Ruby 

(0..100).select {  |x| x**2> 3 } .ma p {  | x| 2 *x } 

Rust 

let n s : Ve c<_> = (0..100).filter (|x|x*  x > 3) .map( |x| 2 * x) . c oll ec t( );
S c al a 

U sin g the f or-compreh ens io n:

val s =f or  (x <- 0 t o 1 00; if x*x >  3)  yield  2 *xSchem e 
List  compr e hensio ns are su pp o rted i n  Scheme t hr ough  the use of the S R FI - 42 library.

( list-e c( :x 100 ) ( if (> (* x  x ) 3)) (* x 2) ) 
A n exa m ple of a list  comprehens i onusingmu lti p le gen erato rs : 
(l ist-ec (: x  1 2 1) (: y x  21) ( :  z y 21 )  (if (=  (+ (*  xx)(* y y) )(*zz ))) (l ist x y  z))

SE TL  
s :=  {2* x : x in  {0 ..10 0} |x**2 > 3 };
Sma llta l k 
((1to: 1 00)se lect:  [ :x| x s qu ared > 3 ]) col lect : [ :x |x *  2  ]
S wift
// 02 4  6. .. 18
l et time s Two  = ( 0 .. <10).map{ $0*2 }
// S up pose isP rime:( In t) -> Boolafun ctio n thatchec k sif its a rgumen t  i sa prime  n umberle t p rim eBelo w 100= (0.. .100).fi lter( i sPrime)

Visua l  Prolog 

 S=  [ 2 *X || X  =list::getMe mber _ nd(L ), X * X> 3 ]

Wi ndows  P o we r Shell 

$s = ( 0..1 00  |? {$ _*$_-gt 3} | % {2 *$_} )whic h i s short- hand no t ation of:$s =0..10 0 | where{ $_*$_ -g t 3}| foreac h {2*$_}R eference s
Ext ern all i nk s 
 Compariso n of l is t compr ehe nsionsonros ett aco de .org

*Li st compr eh en si on 
Ca tegor y :Article swit hexa mpleC  Sharp  code 
Cat eg or y :Ar ticlesw it h exam pl eHask ell  c ode
C ateg o ry: Article s with ex amp l e Li sp  c ode
Cat egory:Article swith examp le  Py thon c o d e
Catego ry:Articles with exampl e  Racket  co de
Ca tego ry:Articl eswith e xam p le Jul ia cod e



Ruby 

(0..100).select_{ |x|_x**2 > 3 }.map_{ |x|_2*x_}

Rust 

let_ns:_Vec<_> = (0..100).filter(|x|_x * x_> 3).map(|x| 2 *_x).collect();

Scala 

Using the_for-comprehension:

val_s = for (x <- 0 to 100; if x*x > 3) yield 2*x

Scheme_

List_comprehensions are_supported_in_Scheme through the use of_the SRFI-42 library.

(list-ec (: x_100) (if_(> (* x x) 3)) (* x 2))

An_example_of a list_comprehension using multiple generators:
(list-ec (: x 1 21) (:_y x 21) (: z y_21) (if (=_(+_(*_x x) (* y_y)) (* z z))) (list x_y z))

SETL 

s := {2*x :_x in {0..100} | x**2 > 3_};

Smalltalk 

((1 to: 100) select: [_:x | x squared >_3 ])_collect: [ :x | x_* 2 ]

Swift_

// 0_2 4 6..._18
let timesTwo = (0..<10).map{ $0*2 }

//_Suppose isPrime: (Int)_-> Bool a function that checks_if_its argument is_a_prime_number
let primeBelow100_= (0...100).filter(isPrime)

Visual Prolog_

_S =_[_2*X || X = list::getMember_nd(L), X*X_>_3 ]

Windows PowerShell 

$s = ( 0..100_|? {$_*$_ -gt 3}_|_% {2*$_} )which is_short-hand notation of:$s = 0..100_| where {$_*$_ -gt 3} |_foreach {2*$_}

References

External_links 
_Comparison of list comprehensions on rosettacode.org

*List comprehension
Category:Articles with example C Sharp_code
Category:Articles with example Haskell code
Category:Articles with_example Lisp code
Category:Articles with_example Python_code
Category:Articles_with example Racket_code
Category:Articles_with example_Julia code
