moduleList(elemIndex,elemIndices,find,findIndex,findIndices,nub,nubBy,delete,deleteBy, (\\),union,unionBy,intersect,intersectBy,intersperse,transpose,partition,group,groupBy,inits,tails,isPrefixOf,isSuffixOf,mapAccumL,mapAccumR,sort,sortBy,insert,insertBy,maximumBy,minimumBy,genericLength,genericTake,genericDrop,genericSplitAt,genericIndex,genericReplicate,zip4,zip5,zip6,zip7,zipWith4,zipWith5,zipWith6,zipWith7,unzip4,unzip5,unzip6,unzip7,unfoldr, -- ...and what the Prelude exports --[]((:), []),map, (++),concat,filter,head,last,tail,init,null,length, (!!),foldl,foldl1,scanl,scanl1,foldr,foldr1,scanr,scanr1,iterate,repeat,replicate,cycle,take,drop,splitAt,takeWhile,dropWhile,span,break,lines,words,unlines,unwords,reverse,and,or,any,all,elem,notElem,lookup,sum,product,maximum,minimum,concatMap,zip,zip3,zipWith,zipWith3,unzip,unzip3)whereimportPreludeimportMaybe(listToMaybe)infix5\\elemIndex::Eqa=>a->[a]->MaybeIntelemIndexx=findIndex(x==)elemIndices::Eqa=>a->[a]->[Int]elemIndicesx=findIndices(x==)find::(a->Bool)->[a]->Maybeafindp=listToMaybe.filterpfindIndex::(a->Bool)->[a]->MaybeIntfindIndexp=listToMaybe.findIndicespfindIndices::(a->Bool)->[a]->[Int]findIndicespxs=[i|(x,i)<-zipxs[0..],px]nub::Eqa=>[a]->[a]nub=nubBy(==)nubBy::(a->a->Bool)->[a]->[a]nubByeq[]=[]nubByeq(x:xs)=x:nubByeq(filter(\y->not(eqxy))xs)delete::Eqa=>a->[a]->[a]delete=deleteBy(==)deleteBy::(a->a->Bool)->a->[a]->[a]deleteByeqx[]=[]deleteByeqx(y:ys)=ifx`eq`ythenyselsey:deleteByeqxys(\\)::Eqa=>[a]->[a]->[a] (\\)=foldl(flipdelete)deleteFirstsBy::(a->a->Bool)->[a]->[a]->[a]deleteFirstsByeq=foldl(flip(deleteByeq))union::Eqa=>[a]->[a]->[a]union=unionBy(==)unionBy::(a->a->Bool)->[a]->[a]->[a]unionByeqxsys=xs++foldl(flip(deleteByeq)) (nubByeqys)xsintersect::Eqa=>[a]->[a]->[a]intersect=intersectBy(==)intersectBy::(a->a->Bool)->[a]->[a]->[a]intersectByeqxsys=[x|x<-xs,any(eqx)ys]intersperse::a->[a]->[a]interspersesep[]=[]interspersesep[x]=[x]interspersesep(x:xs)=x:sep:interspersesepxs-- transpose is lazy in both rows and columns, -- and works for non-rectangular 'matrices' -- For example, transpose [[1,2],[3,4,5],[]] = [[1,3],[2,4],[5]] -- Note that [h | (h:t) <- xss] is not the same as (map head xss) -- because the former discards empty sublists inside xsstranspose::[[a]]->[[a]]transpose[]=[]transpose([]:xss)=transposexsstranspose((x:xs):xss)=(x:[h|(h:t)<-xss]):transpose(xs:[t|(h:t)<-xss])partition::(a->Bool)->[a]->([a],[a])partitionpxs=foldrselect([],[])xswhereselectx(ts,fs)|px=(x:ts,fs)|otherwise=(ts,x:fs) -- group splits its list argument into a list of lists of equal, adjacent -- elements. e.g., -- group "Mississippi" == ["M","i","ss","i","ss","i","pp","i"]group::Eqa=>[a]->[[a]]group=groupBy(==)groupBy::(a->a->Bool)->[a]->[[a]]groupByeq[]=[]groupByeq(x:xs)=(x:ys):groupByeqzswhere(ys,zs)=span(eqx)xs-- inits xs returns the list of initial segments of xs, shortest first. -- e.g., inits "abc" == ["","a","ab","abc"]inits::[a]->[[a]]inits[]=[[]]inits(x:xs)=[[]]++map(x:) (initsxs) -- tails xs returns the list of all final segments of xs, longest first. -- e.g., tails "abc" == ["abc", "bc", "c",""]tails::[a]->[[a]]tails[]=[[]]tailsxxs@(_:xs)=xxs:tailsxsisPrefixOf::Eqa=>[a]->[a]->BoolisPrefixOf[]_=TrueisPrefixOf_[]=FalseisPrefixOf(x:xs) (y:ys)=x==y&&isPrefixOfxsysisSuffixOf::Eqa=>[a]->[a]->BoolisSuffixOfxy=reversex`isPrefixOf`reverseymapAccumL::(a->b->(a,c))->a->[b]->(a, [c])mapAccumLfs[]=(s, [])mapAccumLfs(x:xs)=(s'',y:ys)where(s',y)=fsx(s'',ys)=mapAccumLfs'xsmapAccumR::(a->b->(a,c))->a->[b]->(a, [c])mapAccumRfs[]=(s, [])mapAccumRfs(x:xs)=(s'',y:ys)where(s'',y)=fs'x(s',ys)=mapAccumRfsxsunfoldr::(b->Maybe(a,b))->b->[a]unfoldrfb=casefbofNothing->[]Just(a,b)->a:unfoldrfbsort::(Orda)=>[a]->[a]sort=sortBycomparesortBy::(a->a->Ordering)->[a]->[a]sortBycmp=foldr(insertBycmp) []insert::(Orda)=>a->[a]->[a]insert=insertBycompareinsertBy::(a->a->Ordering)->a->[a]->[a]insertBycmpx[]=[x]insertBycmpxys@(y:ys')=casecmpxyofGT->y:insertBycmpxys'_->x:ysmaximumBy::(a->a->a)->[a]->amaximumBymax[]=error"List.maximumBy: empty list"maximumBymaxxs=foldl1maxxsminimumBy::(a->a->a)->[a]->aminimumBymin[]=error"List.minimumBy: empty list"minimumByminxs=foldl1minxs--genericLength :: (Integral a) => [b] -> agenericLength[]=0genericLength(x:xs)=1+genericLengthxs--genericTake :: (Integral a) => a -> [b] -> [b]genericTake_[]=[]genericTake0_=[]genericTaken(x:xs)|n>0=x:genericTake(n-1)xs|otherwise=error"List.genericTake: negative argument" --genericDrop :: (Integral a) => a -> [b] -> [b]genericDrop0xs=xsgenericDrop_[]=[]genericDropn(_:xs)|n>0=genericDrop(n-1)xs|otherwise=error"List.genericDrop: negative argument" --genericSplitAt :: (Integral a) => a -> [b] -> ([b],[b])genericSplitAt0xs=([],xs)genericSplitAt_[]=([],[])genericSplitAtn(x:xs)|n>0=(x:xs',xs'')|otherwise=error"List.genericSplitAt: negative argument"where(xs',xs'')=genericSplitAt(n-1)xs--genericIndex :: (Integral a) => [b] -> a -> bgenericIndex(x:_) 0=xgenericIndex(x:xs)n|n>0=genericIndexxs(n-1)|otherwise=error"List.genericIndex: negative argument"genericIndex__=error"List.genericIndex: index too large" --genericReplicate :: (Integral a) => a -> b -> [b]genericReplicatenx=genericTaken(repeatx)zip4::[a]->[b]->[c]->[d]->[(a,b,c,d)]zip4=zipWith4(,,,)zip5::[a]->[b]->[c]->[d]->[e]->[(a,b,c,d,e)]zip5=zipWith5(,,,,)zip6::[a]->[b]->[c]->[d]->[e]->[f]->[(a,b,c,d,e,f)]zip6=zipWith6(,,,,,)zip7::[a]->[b]->[c]->[d]->[e]->[f]->[g]->[(a,b,c,d,e,f,g)]zip7=zipWith7(,,,,,,)zipWith4::(a->b->c->d->e)->[a]->[b]->[c]->[d]->[e]zipWith4z(a:as) (b:bs) (c:cs) (d:ds)=zabcd:zipWith4zasbscsdszipWith4_____=[]zipWith5::(a->b->c->d->e->f)->[a]->[b]->[c]->[d]->[e]->[f]zipWith5z(a:as) (b:bs) (c:cs) (d:ds) (e:es)=zabcde:zipWith5zasbscsdseszipWith5______=[]zipWith6::(a->b->c->d->e->f->g)->[a]->[b]->[c]->[d]->[e]->[f]->[g]zipWith6z(a:as) (b:bs) (c:cs) (d:ds) (e:es) (f:fs)=zabcdef:zipWith6zasbscsdsesfszipWith6_______=[]zipWith7::(a->b->c->d->e->f->g->h)->[a]->[b]->[c]->[d]->[e]->[f]->[g]->[h]zipWith7z(a:as) (b:bs) (c:cs) (d:ds) (e:es) (f:fs) (g:gs)=zabcdefg:zipWith7zasbscsdsesfsgszipWith7________=[]unzip4::[(a,b,c,d)]->([a],[b],[c],[d])unzip4=foldr(\(a,b,c,d)~(as,bs,cs,ds)->(a:as,b:bs,c:cs,d:ds)) ([],[],[],[])unzip5::[(a,b,c,d,e)]->([a],[b],[c],[d],[e])unzip5=foldr(\(a,b,c,d,e)~(as,bs,cs,ds,es)->(a:as,b:bs,c:cs,d:ds,e:es)) ([],[],[],[],[])unzip6::[(a,b,c,d,e,f)]->([a],[b],[c],[d],[e],[f])unzip6=foldr(\(a,b,c,d,e,f)~(as,bs,cs,ds,es,fs)->(a:as,b:bs,c:cs,d:ds,e:es,f:fs)) ([],[],[],[],[],[])unzip7::[(a,b,c,d,e,f,g)]->([a],[b],[c],[d],[e],[f],[g])unzip7=foldr(\(a,b,c,d,e,f,g)~(as,bs,cs,ds,es,fs,gs)->(a:as,b:bs,c:cs,d:ds,e:es,f:fs,g:gs)) ([],[],[],[],[],[],[])

Index

(HTML for this module was generated on Mar 20. About the conversion tool.)