Cheatography

# Lists - Python and Q Cheat Sheet (DRAFT) by BodonFerenc

List operations by Ptyhon and Q

This is a draft cheat sheet. It is a work in progress and is not finished yet.

### Modifi­cation

 operation Python Q adding item ``l.appe­nd(3)`` ``l,: 3`` insert ``l.inse­rt(i, 7)`` ``l: (i#l), 7, i _ l`` delete all ``l.clear()`` ``l: 0#l`` pop ``l.pop()`` ``l: -1 _ l`` remove single ``l.remo­ve(3)`` ``l: l except 3`` remove multiple ``[e for e in l1 if e not in l2]`` ``l: l except l2`` deleteby index ``del l[3]`` ``l: l _ 3``

### Simila­rities on general list

 operation Python Q length ``len(l)`` ``count t`` reverse ``list(r­eve­rse(l))`` ``reverse l`` first part ``l[:2]`` ``2#l`` last part ``l[-2:]`` ``-2#l`` middle part ``l[1:3]`` ``1_3#l``

### operations on list of numbers

 operation Python Q minumum ``min(l)`` ``min l`` average ``statis­tic­s.m­ean(l)`` ``avg l`` variance ``statis­tic­s.v­ari­ance(l)`` ``svar l`` cummul­ative sum ``list(i­ter­too­ls.a­cc­umu­late(l, operat­or.a­dd))`` ``sums l`` cummul­ative prod ``list(i­ter­too­ls.a­cc­umu­late(l, operat­or.m­ul))`` ``prds l``

### Split and Join

 operation Python Q join ``"­,".j­oin(l)`` ``"­," sv l`` split ``s.spli­t(",­")`` ``"­," vs s``