-- | General shorthands and other small operations. Part of the "Useful" module.moduleUseful.GeneralwhereimportData.List-- | Alias of as /= (not equal to)(!=)::Eqa=>a->a->Bool(!=)=(/=)-- | Alias of mod(%)::(Integrala)=>a->a->a(%)=mod-- | Works like python's \"in\" function. (Alias of elem). Simply checks if an item is in a list.---- > $ "Hello" ? ["Hello","there","people"]-- > True-- > $ "Bonjour" ? ["Hello","there","people"]-- > False(?)::Eqa=>a->[a]->Bool(?)=elem-- | Alias of as isInFixOf. Checks if list is a sublist of another list---- > $ "hello" ?? "Why hello there people"-- > True-- > $ [2,3] ?? [1,2,3,4]-- > True-- > $ "bonjour" ?? "why hello there people"-- > False (??)::Eqa=>[a]->[a]->Bool(??)=isInfixOf-- | Returns the index of the first occurance of an item if it is in a list. Otherwise gives an error. Starts counting from 0!---- NOTE: This is not like elemIndex! It does not return a Maybe Int it returns an error if the item is not in a list. Either use elemIndex or test using ? first.-- -- > $ 'n' ?! "banana"-- > 2-- > $ 'v' ?! "banana"-- > *** Exception: Item not in list(?!)::Eqa=>a->[a]->Int(?!)xy=fxy0wheref::Eqa=>a->[a]->Int->Intfx[]_=error"Item not in list"fx(y:ys)c|x==y=c|otherwise=fxys(c+1)-- | Takes a list and a pair (x,y) and inserts the item y into the list at position x---- > $ ["hello","there","people"] !/ (0,"bonjour")-- > ["bonjour","there","people"](!/)::[a]->(Int,a)->[a](!/)xs(i,y)|i>=lenxs=error"index too large"|otherwise=[ifn==ithenyelsex|(x,n)<-zipxs[0..]]-- | Like !! but returns Maybe a-- -- > $ [1,2,3,4] ! 5-- > Nothing-- > $ [1,2,3,4] ! 1-- > Just 2(!)::[a]->Int->Maybea(!)xsi=plingHelperxsi0plingHelper[]__=NothingplingHelper(x:xs)in|i==n=Justx|otherwise=plingHelperxsi(n+1)-- | alias of lengthlen::[a]->Intlen=length-- | alias of lengthcount::[a]->Intcount=length-- | Takes the unit list and returns the unit---- NOTE: Will return an error if not supplied with the unit list-- -- > $ the ["hello"]-- > "hello"-- > $ the ["hello","there"]-- > "*** Exception: function 'the' called with a list other than the unit list.the::[a]->athe[x]=xthe_=error"function 'the' called with a list other than the unit list."