You are on page 1of 20

join a list of strings in a string using a glue string

join(s, l) Perl, Perl6, PHP


String.Join(s, l) C#
s.join(l) Python
l.join(s) JavaScript, Perl6, Ruby
l asStringWith: s Smalltalk
join l s Tcl
implode(s, l) PHP
ListTools[Join] Maple
rjoin E
join Io
concat F#, OCaml
strcat Matlab
concat_atom Prolog
l * s Pike, Ruby
(mapconcat 'identity l s) Emacs Lisp
componentsJoinedByString Objective-C
intercalate Haskell
StringJoin @@ Riffle[l, s] Mathematica
list size
size C++, Dylan, E, Io, Java, Matlab, merd, Pliant, Ruby, Scilab, Smalltalk, YCP
sizeof Pike

length C#, Common Lisp, Emacs Lisp, F#, Haskell, Java, JavaScript, Matlab, Mercury,
OCaml, PostScript, Prolog, Ruby, Scheme, SML
Length Ada, F#, Mathematica, Oz
length? Rebol
len Python
llength Tcl
$LENGTH MUMPS
elems Perl6
getn Lua
count Eiffel, FishShell, Objective-C, PHP, SQL92, XPath
numel Matlab
scalar
@l Perl

nops Maple
# Lua
iterate with index
each_with_index merd, Ruby
enumerate(l) Python
foreach($l as $i => $v) PHP
a foreach(i, e, ...) Io
for i => v in l E
for (v in l, i from 0) ... end Dylan
forAllInd Oz
foreachi Lua
foreach(l; typ0 i; typ1 v) { ... } Pike
withIndexDo Squeak
iteri F#, OCaml
IterateIndexed F#
MapIndexed Mathematica
(loop for v in l as i upfrom 0 do ...) Common Lisp

remove duplicates abram


arya adi
uniq merd, Perl6, Pike, Ruby
uniq! Ruby
uniq2 Pike
unique(11) C++, Io, Matlab, Rebol
nub Haskell
array_unique PHP
ListTools[MakeUnique] Maple
delete-duplicates Common Lisp, Scheme-SRFI1
delete-duplicates! Scheme-SRFI1
remove-duplicates Common Lisp, Dylan
lsort -unique Tcl
toset YCP
distinct SQL92
set Python
Union Mathematica
sort

C#, C++, Common Lisp, E, Eiffel, F#, Haskell,


sort(12) Io, Java, JavaScript, Lua, Maple, Matlab, merd,
OCaml, Perl, Perl6, PHP, Pike, Prolog, Python,
Rebol, Ruby, Scheme, XSLT, YCP
sort! Ruby
sorted Python
Sort Mathematica, Oz
sort_by merd, Ruby
sortBy Haskell, Io, Smalltalk
order by SQL92
lsort Tcl
asort Awk
sort-object MSH
sortedArrayUsingSelector,
sortUsingSelector Objective-C

predsort / keysort /
mergesort Prolog

reverse

C++, Common Lisp, Dylan, Emacs Lisp, Haskell, Io, Java, JavaScript,
reverse Logo, Mercury, merd, Perl, Perl6, Pike, Prolog, Python, Rebol, Ruby,
Scheme
Reverse C#, Mathematica, Oz
reversed Python, Smalltalk
reverse_copy C++
rev F#, OCaml, SML
Reverse_Elemen
ts Ada

lreverse Tcl8.5
array_reverse PHP
ListTools[Reve
rse] Maple

fliplr
flipud... Matlab

l[::-1] Python

list of couples from 2 lists abram


arya adi
combine F#, OCaml
zip F#, Haskell, Maple, merd, Perl6, Python, Ruby, Scheme-SRFI1, SML
pairlis(13) Common Lisp
transpose Ruby
Transpose Mathematica
[a b] Matlab
2 lists from a list of couples
split F#, OCaml
unzip F#, Haskell, merd, SML
unzip2 Scheme-SRFI1
transpose Ruby
Transpose Mathematica
zip(*l) Python
a(1,:), a(2,:) Matlab
lookup an element in a association list
lookup Haskell
assoc Common Lisp, Emacs Lisp, F#, OCaml, Ruby, Scheme
assq Emacs Lisp, Scheme
assv Scheme
get_assoc Prolog
select Rebol
a.(e) Matlab
a[e] Maple
gprop Logo
/. Mathematica
list out of a bag
to_a Ruby
toArray Java
asArray Smalltalk
to_list merd
list Python
map-as(<list>, bag) Dylan
[a.(:)] Matlab
array get Tcl
f(... f(f(init, e1), e2) ..., en)
foldl Haskell, Maple, Mercury, merd, SML
FoldL Oz
fold_left OCaml
fold F#, Scheme-SRFI1
Fold Mathematica
reduce(14) Common Lisp, Dylan, Io, Perl, Perl6, Pike, Python
inject Ruby
inject into Smalltalk
f(e1, f(e2, ... f(en, init) ...))

foldr Haskell, Maple, Mercury,


merd, SML
FoldR Oz
fold-right Scheme-SRFI1
fold_right OCaml
foldBack F#
rreduce Pike
(reduce f '(e1 e2 ... en) :from-right t
:initial-value init) Common Lisp

reverseReduce Io

Remarks
(1) restricted to initialisation of a local variable in C and C++
(2) a b c must be constants
(3) beware, if you give only one integer argument, it is the size!
(4) for write access: a i o put
(5) in C++, it is range-checked whereas a[i] is not. in Smalltalk, for write access: a :at i :put o
(6) see also Head
(7) list comprehension
(8) in List::Util
(9) not in standard
(10) Python >= 2.5
(11) in C++, it is done in place
(12) in Scheme, not standard, but nearly standard
(13) the result is not guaranteed to be the same as the order in the input
(14) in Perl, in List::Util

Pixel
This document is licensed under GFDL (GNU Free Documentation License).
Generated from syntax-across-languages.html.pl
$Id: syntax-across-languages.html.pl 408 2008-08-29 08:32:23Z pixel $
abram
abram dedi parman
tukang sayur
abram dedi parman
tukang sayur
abram dedi parman
tukang sayur

You might also like