kategori-antropologi.pts-ptn.net 17 Hours Information Services
Tel/Fax : 021-8762002, 8762003, 8762004, 87912360
Mobile/SMS : 081 1110 4824 27, 0812 9526 2009, 08523 1234 000, 0815 145 78119
WhatsApp : 0817 0816 486, 0812 9526 2009, 0815 145 78119
email : _Contact Us__ please click
Chatting dengan Staf :
ggkarir.com
ggiklan.com
Select Language :     ID   EN   Request Catalog / Brochure (free via post)   Encyclopedia Vacancy Advert

   
Search  
    Informatics

    Prev  (Comparison of programming lang ...) (Comparison of programming lang ...)  Next    

Comparison of programming languages (list comprehension)

Contents

List Comprehensions

List comprehension is a syntactic construct available in some programming languages for creating a list based on existing lists. It follows the form of the mathematical set-builder notation (set comprehension.) as distinct from the use of map and filter functions.

Boo

List with all the doubles from 0 to 10 (exclusive)

doubles = [i*2 for i in range(10)]

List with the names of the customers based on Rio de Janeiro

rjCustomers = [customer.Name for customer in customers if customer.State == "RJ"]

C#

var ns = from x in Enumerable.Range(0,100)         where x*x > 3         select x*2;

The previous code is syntactic sugar for the following code written using lambda expressions:

var ns = Enumerable.Range(0, 100)        .Where(x => x*x > 3)        .Select(x => x*2);

Clojure

An infinite lazy sequence:

 (for [x (iterate inc 0)        :when (> (* x x) 3)]   (* 2 x))

A list comprehension using multiple generators:

 (for [x (range 20)       y (range 20)       z (range 20)       :when (== (+ (* x x) (* y y)) (* z z))]   [x y z])

Common Lisp

List comprehensions can be expressed with the loop macro's collect keyword. Conditionals are expressed with if, as follows:

(loop for x from 0 to 100 if (> (* x x) 3) collect (* 2 x))

Cobra

List the names of customers:

names = for cust in customers get cust.name

List the customers with balances:

names = for cust in customers where cust.balance > 0

List the names of customers with balances:

names = for cust in customers where cust.balance > 0 get cust.name

The general forms:

for VAR in ENUMERABLE [where CONDITION] get EXPRfor VAR in ENUMERABLE where CONDITION

Note that by putting the condition and expression after the variable name and enumerable object, editors and IDEs can provide autocompletion on the members of the variable.

Erlang

L = lists:seq(0,100).S = [2*X || X <- L, X*X > 3].

F#

Lazily-evaluated sequences:

seq { for x in 0 .. 100 do if x*x > 3 then yield 2*x }

Or, for floating point values

seq { for x in 0. .. 100. do if x**2. > 3. then yield 2.*x }

Lists and arrays:

[ for x in 0. .. 100. do if x**2. > 3. then yield 2.*x ][| for x in 0. .. 100. do if x**2. > 3. then yield 2.*x |]

List comprehensions are the part of a greater family of language constructs called computation expressions.

Groovy

(0..100).findAll{ x -> x * x > 3 }.collect { x -> 2 * x }

Haskell

[x * 2 | x <- [0 .. 99], x * x > 3]

An example of a list comprehension using multiple generators:

pyth = [(x,y,z) | x <- [1..20], y <- [x..20], z <- [y..20], x^2 + y^2 == z^2]

ISLISP

List comprehensions can be expressed with the for special form. Conditionals are expressed with if, as follows:

(for ((x 0 (+ x 1))      (collect ()))     ((>= x 100) (reverse collect))     (if (> (* x x) 3)         (setq collect (cons (* x 2) collect))))

JavaScript

Borrowing from Python, JavaScript 1.7 and later have array comprehensions.[1] Although this feature has been proposed for inclusion in the fourth edition ECMAScript standard, Mozilla is the only implementation that currently supports it.

/* There is no "range" function in JavaScript's standard   library, so the application must provide it. */function range(n) {  for (var i = 0; i < n; i++)    yield i;} [2 * x for (x in range(100)) if (x * x > 3)]

JavaScript 1.8 adds Python-like generator expressions.

Mythryl

 s = [ 2*i for i in 1..100 where i*i > 3 ];

Multiple generators:

 pyth = [ (x,y,z) for x in 1..20 for y in x..20 for z in y..20 where x*x + y*y == z*z ];

Nemerle

$[x*2 | x in [0 .. 100], x*x > 3]

OCaml

OCaml supports List comprehension through OCaml Batteries. [2]

Perl 6

my @s = ($_ * 2 if $_ ** 2 > 3 for 0 .. 99);

Python

Python uses the following syntax to express list comprehensions over finite lists:

S = [2*x for x in range(100) if x**2 > 3]

A generator expression may be used in Python versions >= 2.4 which gives lazy evaluation over its input, and can be used with generators to iterate over 'infinite' input such as the count generator function which returns successive integers:

from itertools import countS = (2*x for x in count() if x**2 > 3)

(Subsequent use of the generator expression will determine when to stop generating values).

R

x = (0:100)S = 2 * x[x ^ 2 > 3]

Racket

(for/list ([x (in-range 100)] #:when (> (* x x) 3)) (* x 2))

An example with multiple generators:

(for*/list ([x (in-range 1 21)] [y (in-range 1 21)] [z (in-range 1 21)]            #:when (= (+ (* x x) (* y y)) (* z z)))  (list x y z))

Ruby

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

Scala

Using the for-comprehension:

val s = for (x <- Stream.from(0); if x*x > 3) yield 2*x

Scheme

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

(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 ]

Visual Prolog

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

Windows PowerShell

$s = ( 0..100 | ? {$_*$_ -gt 3} | % {2*$_} )

References

    Prev  (Comparison of programming lang ...) (Comparison of programming lang ...)  Next    


World Encyclopedia ➪ AgricultureAnimalArtAstronomyBiographyCharacterChemicalCultureEcologyEconomicsEducationElectronics
EnvironmentFilmGeographyHistoryIndonesiaJabodetabekLanguageLawLiteratureMathematicsMedical
MilitaryMusicMythologyPhilosophyPhysicsPlantPoliticalPuppetReligionScienceSocietySportsTechnology
Manual / Tutorial   ➪ AntApache ServerHTML 4HTML 5JavaScriptMySQLPerlPHPLinuxShell       Network Encyclopedia
Web Network ➪ Employee ClassRegularEvening ClassS2PTSPartyGeneral    
Reference ➪ Internet, Computers, ICT, OS, etc

  » Cyber University   » Fakultas Pertanian UMJ Jakarta   » Fakultas Teknik UMJ   » FE Universitas MH. Thamrin Jakarta   » FISIP UMJ Jakarta   » FK Universitas MH. Thamrin Jakarta   » IAI Al-Ghurabaa Jakarta
  » IAI Muhammad Azim Jambi   » IBISA Purworejo   » IKIP Widya Darma Surabaya   » Institut Agama Islam Sukabumi   » Institut Teknologi Sains Bandung   » ISIF Cirebon   » ISTA Jakarta
  » ISTN Jakarta   » ITB Muhammadiyah Purbalingga   » ITB STIKOM Bali   » ITB STIKOM Jimbaran Bali   » ITBU Jakarta   » ITEKES Tri Tunas Nasional Makassar   » ITESA Muhamadiyah Semarang
  » ITM Purwakarta   » MA UNHI Denpasar   » Magister Teknik ISTN Jakarta   » Magister Universitas Buddhi Dharma   » Magister Universitas Satyagama   » MH UM SURABAYA   » MH UNKRIS Jakarta
  » MIA FISIP UMJ Jakarta   » MIA UNKRIS Jakarta   » MIKOM FISIP UMJ Jakarta   » MM Patria Artha Makassar   » MM STIE ABI Surabaya   » MM STIE Ganesha Jakarta   » MM STIE GICI Business School Jakarta
  » MM STIE IGI Jakarta   » MM UMIBA Jakarta   » MM UNHI Denpasar   » MM UNKRIS Jakarta   » MPD UM SURABAYA   » MPD UNHI Denpasar   » Mpu Tantular Kedoya Jakarta
  » MT UNKRIS Jakarta   » Politeknik Semen Indonesia   » Polnas Denpasar   » S2 FISIP UMJ Jakarta   » S2 FT UMJ   » S2 NUSA MANDIRI   » S2 STMIK Jakarta
  » S2 UIN Al-Azhaar Lubuklinggau   » S2 UM SURABAYA   » S2 UNHI Denpasar   » S2 UNKRIS Jakarta   » S2 UNSURYA   » Sekolah Tinggi Bisnis Runata   » STAI Al-Akbar Surabaya
  » STAI Al-Andina Sukabumi   » STAI Al-Hidayah Tasikmalaya   » STAI Al-Ittihad Cianjur   » STAI Al-Muhajirin Purwakarta   » STAI Muhammadiyah Tulungagung   » STAI Terpadu Yogyakarta   » STEBI Bina Essa Bandung
  » STEI SEBI Cikarang   » STEI SEBI Depok   » STEI Yogyakarta   » STIBADA MASA Surabaya   » STIE ABI Surabaya   » STIE Al-Rifaie Malang   » STIE Cendekia Semarang
  » STIE Dharma Nasional Jember   » STIE Ganesha Jakarta   » STIE GEMA Bandung   » STIE GICI Business School Bogor   » STIE GICI Business School Depok   » STIE GICI Business School Bekasi   » STIE GICI Business School Jakarta
  » STIE Hidayatullah Depok   » STIE IGI Jakarta   » STIE Indocakti Malang   » STIE Nusantara Makassar   » STIE PASIM Sukabumi   » STIE PEMUDA Surabaya   » STIE Pioneer Manado
  » STIE Trianandra Pemuda Jakarta   » STIE Widya Darma Surabaya   » STIE Widya Persada Jakarta   » STIEKIA Bojonegoro   » STIH Awang Long Samarinda   » STIH Gunung Jati Tangerang   » STIH Litigasi Jakarta
  » STIKI Malang   » STIPER Jember   » STISIP Guna Nusantara Cianjur   » STIT Al-Hikmah Lampung   » STIT Tarbiyatun Nisa Sentul Bogor   » STMIK Jakarta   » STT Bina Tunggal Bekasi
  » STT Mandala Bandung   » STT STIKMA Internasional   » UHAMZAH Medan   » UICM Bandung   » UIN Al-Azhaar Lubuklinggau   » UM Palangkaraya   » UM Surabaya
  » UNAKI Semarang   » UNDARIS Ungaran Semarang   » UNHI Denpasar   » UNIBA Banyuwangi   » UNISA Kuningan Jawa Barat   » UNISMU Purwakarta   » Univ. Bali Dwipa Denpasar Bali
  » Universitas Boyolali   » Universitas Buddhi Dharma   » Universitas Cokroaminoto Makassar   » Universitas Deli Sumatera   » Universitas Dr. Soebandi Jember   » Universitas IVET Semarang   » Universitas Kahuripan Kediri
  » Universitas Mahakarya Asia Yogyakarta   » Universitas MH. Thamrin Jakarta   » Universitas Mitra Bangsa   » Universitas Mochammad Sroedji Jember   » Universitas Mpu Tantular Jakarta   » Universitas Muhammadiyah Jakarta   » Universitas Musi Rawas Lubuklinggau
  » Universitas Nurul Huda Oku Timur   » Universitas Nusa Mandiri Jatiwaringin   » Universitas Nusa Mandiri Kramat   » Universitas Nusa Mandiri Margonda   » Universitas Nusa Mandiri Tangerang   » Universitas Nusantara Manado   » Universitas Pandanaran Semarang
  » Universitas Parna Raya Manado   » Universitas Patria Artha Makassar   » Universitas Saintek Muhammadiyah   » Universitas Satyagama   » Universitas Tanri Abeng Jakarta   » Universitas Teknologi Bandung   » Universitas Teknologi Nusantara
  » Universitas Teknologi Sulawesi Makassar   » Universitas Ubudiyah Indonesia Aceh   » Universitas Yuppentek Indonesia   » UNKRIS Jakarta   » UNSUB Subang   » UNSURYA Jakarta   » UNTARA Cikokol Tangerang
  » UNTARA Tigaraksa Tangerang   » UNU Cirebon   » UNU Kalbar Pontianak   » UNU Kaltim Samarinda   » UNUGHA Cilacap   » UNUSA Surabaya   » UNUSIDA
  » USM Indonesia Medan   » UWIKA SurabayaCombined Information Employee Class entire PTS

Al Quran onlineAdvertisingBarter Link232 CountriesCat Info CenterCity & Province WebsitesCPNSComplete POS codeCorruption Rating
Embassy:  KBRI  Foreign  • Exercise Psychotest  • Civitasbook.com  • Hosting: ID World  • Info Prov, City, District, Village  • International Organizations
Islands in NKRIJob VacancyLibrariesNews & Magazine: ID ForeignNKRI, KPK, MA, etc.Political PartyPatriotPTAPTNPTSHospitalRanch
ScholarshipSholat & Imsak ScheduleSMASMKSMPTV & Radio : Foreign IDFootballWorld Statistics     Academic : Majors Prospectus

Department/Study Program (D3, S1, S2), Curriculum, Prospectus (Career Prospects), and Title/Degree
Undergraduate Programs (S-1)
¤ S1 Accounting
¤ S1 Agribusiness
¤ S1 Agricultural Sciences
¤ S1 Agroteknologi (Agricultural Industry Technology)
¤ S1 Akhwal al Syakhsiyyah / Civil Law of Islam (Sharia)
¤ S1 Animal Sciences
¤ S1 Architectural Engineering
¤ S1 Biology Education
¤ S1 Business/Commerce Administration Science
¤ S1 Chemical Engineering
¤ S1 Civil Engineering
¤ S1 Communication Studies
¤ S1 Computer Engineering / Computer Systems
¤ S1 ECD (Early Childhood Teacher Education)
¤ S1 Electrical Engineering
¤ S1 English Education
¤ S1 English Language / Literature
¤ S1 Food Technology
¤ S1 Indonesian Language and Literature Education
¤ S1 Industrial Engineering
¤ S1 Industrial Product Design
¤ S1 Informatics Engineering
¤ S1 Information System
¤ S1 International Relations
¤ S1 Law/Legal Studies
¤ S1 Management
¤ S1 Mathematics Education
¤ S1 Mechanical Engineering
¤ S1 Nursing
¤ S1 OPJKR (Physical Education, Health, Recreation)
¤ S1 Pancasila and Citizenship Education (PPKN)
¤ S1 Petroleum Engineering
¤ S1 Pharmaceuticals
¤ S1 Planning / Urban and Regional Planning Engineering
¤ S1 Political Sciences
¤ S1 Psychology
¤ S1 Public Health
¤ S1 Public/State Administration Science
¤ S1 Shipping Engineering
¤ S1 Social Welfare Studies
¤ S1 Sociology
¤ S1 Tarbiyah / Islamic Education
¤ S1 Ushuludin / Comparative Religion
¤ S1 Visual Communication Design
Graduate Programs (S-2)
¤ S2 Master of Management / MM

Three Diploma Programs (D-III)
¤ D3 Accounting
¤ D3 Accounting Computer
¤ D3 Business Travel (Business Tourism & Hospitality)
¤ D3 Computer Engineering (Computer Systems)
¤ D3 Electrical Engineering
¤ D3 Finance and Banking
¤ D3 Health Analyst
¤ D3 Informatics Management
¤ D3 Midwifery
¤ D3 MPRS (Hospital Services Management)
¤ D3 Nursing
¤ D3 Nutrition
¤ D3 Pharmaceutical and Food Analysts

Home       Debate : BuddhistChristian, CatholicConfucianEducationHealthHinduInternetIslamMotivationMusicPolitical



Tags: Comparison of programming languages (list comprehension), Informatics, 479, Comparison of programming languages (list comprehension) Programming language comparisons General comparison Basic syntax Basic instructions Arrays Associative arrays String operations String functions List comprehension Object oriented programming Object oriented constructors Database access Evaluation strategy List of, Hello World, programs ALGOL 58's influence on ALGOL 60 ALGOL 60: C, Comparison of programming languages (list comprehension), English, Instruction Examples, Tutorials, Reference, Books, Guide kategori antropologi, pts-ptn.net
 Free Tuition
 Job Fairs
 Advanced School Program
 Book Encyclopedia
 Postgraduate Degree
 Waivers Cost Study Application
 Afternoon / Evening Course Program
 Download Brochures

 Online Registration
 Diverse Forums
 Online Tuition in the Best 168 PTS
 Tutorial book
Sites
Postgraduate Program (Online Lectures)

Profile PTS-PTS
Student Admission
Study Program each PTS
Study Program + Curriculum
Our Services
Improvement Income
Sites Network Main
Sites Network Regular College
Sites Network Postgraduate Degree
Sites Network Advanced School
Sites Network Afternoon / Evening Course

 Psychotest Practice
 Many Kinds Adverts
 Prayer Times
 Alqur'an Online
Kandungan Vitamin B5 pada berbagai sayuran, Lutein + Zeaksantin / Zeaxanthin, etc.
Menanam benih Srikaya di pot / polybag

Tell Your Friend's
Your name

Your email

Your Friend's email 1

Your Friend's email 2 (not required)

Your Friend's email 3 (not required)
▣ must be filled in correctly

Valuable Site
Site CBS, CBSS, CCAMLR
Encyclopedia Centre

snmpts.com  |  bidik-misi.web.id  |  pmb.web.id  |  sbmpts.web.id  |  simak-pts.web.id  |  snmpts.web.id  |  umb-pts.com  |  umbpts.com  |  bidik-misi.com  |  umb-pts.org  |  stmikjakarta.web.id