Provide an efficient implementation of ‘elem’
Provide an efficient implementation of ‘elem’

The one in Nixpkgs is O(n^2), this one is O(n).  Big reduction in the
number of list allocations.

Statistics before (on a NixOS system config):

  time elapsed: 1.17982
  size of a value: 24
  environments allocated: 1543334 (39624560 bytes)
  list elements: 9612638 (76901104 bytes)
  list concatenations: 37434
  values allocated: 1854933 (44518392 bytes)
  attribute sets allocated: 392040
  right-biased unions: 186334
  values copied in right-biased unions: 591137
  symbols in symbol table: 18272
  number of thunks: 1392467
  number of thunks avoided: 1507311
  number of attr lookups: 430801
  number of primop calls: 691600
  number of function calls: 1492502

Statistics after:

  time elapsed: 1.08683
  size of a value: 24
  environments allocated: 1384376 (35809568 bytes)
  list elements: 6946783 (55574264 bytes)
  list concatenations: 37434
  values allocated: 1760440 (42250560 bytes)
  attribute sets allocated: 392040
  right-biased unions: 186334
  values copied in right-biased unions: 591137
  symbols in symbol table: 18273
  number of thunks: 1297673
  number of thunks avoided: 1380759
  number of attr lookups: 430802
  number of primop calls: 628912
  number of function calls: 1333544

ehmry/nix,joelmo/nix,nbp/nix,peti/nix,wmertens/nix,gebner/nix,ttuegel/nix,NixOS/nix,vizanto/nix,aucampia/nix,zimbatm/nix,acowley/nix,ehmry/nix,dtzWill/nix,shlevy/nix,ehmry/nix,ehmry/nix,offlinehacker/nix,bennofs/nix,vcunat/nix,dtzWill/nix,shlevy/nix,gridaphobe/nix,aucampia/nix,bennofs/nix,gebner/nix,garbas/nix,tchajed/nix,tchajed/nix,rowhit/nix,layus/nix,ysangkok/nix,nbp/nix,wmertens/nix,vizanto/nix,peti/nix,NixOS/nix,layus/nix,dezgeg/nix,offlinehacker/nix,puffnfresh/nix,bjornfor/nix,shlevy/nix,layus/nix,rycee/nix,dtzWill/nix,edolstra/nix,vcunat/nix,pikajude/nix,vcunat/nix,garbas/nix,zimbatm/nix,ysangkok/nix,NixOS/nix,rycee/nix,vizanto/nix,ehmry/nix,dezgeg/nix,puffnfresh/nix,rowhit/nix,vcunat/nix,joelmo/nix,ttuegel/nix,ttuegel/nix,gridaphobe/nix,edolstra/nix,gebner/nix,jcumming/nix,acowley/nix,ehmry/nix,joelmo/nix,bjornfor/nix,garbas/nix,nbp/nix,edolstra/nix,NixOS/nix,puffnfresh/nix,NixOS/nix,ysangkok/nix,acowley/nix,peti/nix,rowhit/nix,vizanto/nix,jcumming/nix,aucampia/nix,dtzWill/nix,garbas/nix,layus/nix,offlinehacker/nix,layus/nix,zimbatm/nix,pikajude/nix,bjornfor/nix,wmertens/nix,tchajed/nix,gebner/nix,gridaphobe/nix,offlinehacker/nix,garbas/nix,bennofs/nix,rycee/nix,bennofs/nix,tchajed/nix,jcumming/nix,dtzWill/nix,jcumming/nix,shlevy/nix,shlevy/nix,edolstra/nix,dezgeg/nix,peti/nix,nbp/nix,dezgeg/nix,wmertens/nix,aucampia/nix,dezgeg/nix,peti/nix,rycee/nix,rycee/nix,acowley/nix,joelmo/nix,bjornfor/nix,pikajude/nix,gridaphobe/nix,edolstra/nix,rowhit/nix,puffnfresh/nix,ttuegel/nix,zimbatm/nix