docs: def RRlist2bitmap(lst):
      """
      Encode a list of integers representing Resource Records to a bitmap field 
      used in the NSEC Resource Record.
      """
      # RFC 4034, 4.1.2. The Type Bit Maps Field
  
      import math
  
      bitmap = b""
      lst = list(set(lst))
      lst.sort()
      
      #lst = filter(lambda x: x <= 65535, lst)
      #lst = map(lambda x: abs(x), lst)
      lst = [ abs(x) for x in lst if x<= 65535 ]
  
      # number of window blocks
      max_window_blocks = int(math.ceil(lst[-1] / 256.))
      min_window_blocks = int(math.floor(lst[0] / 256.))
      if min_window_blocks == max_window_blocks:
          max_window_blocks += 1
  
      for wb in range(min_window_blocks, max_window_blocks+1):
          # First, filter out RR not encoded in the current window block
          # i.e. keep everything between 256*wb <= 256*(wb+1)
          #rrlist = filter(lambda x: 256*wb <= x and x < 256*(wb+1), lst)
          rrlist = [ x for x in lst if 256*wb <= x and x < 256*(wb+1) ]
          rrlist.sort()
          if rrlist == []:
              continue
       
          # Compute the number of bytes used to store the bitmap
          if rrlist[-1] == 0: # only one element in the list
              bs = 1
          else:
              max = rrlist[-1] - 256*wb
              #bs = int(math.ceil(max / 8)) + 1  # use at least 1 byte
              bs = int(max // 8) + 1  # use at least 1 byte
          if bs > 32: # Don't encode more than 256 bits / values
              bs = 32
  
          bitmap += struct.pack("B", wb)
          bitmap += struct.pack("B", bs)
  
          # Generate the bitmap
          for tmp in range(bs):
              v = 0
              # Remove out of range Ressource Records
              #tmp_rrlist = filter(lambda x: 256*wb+8*tmp <= x and x < 256*wb+8*tmp+8, rrlist)
              tmp_rrlist = [ x for x in rrlist if 256*wb+8*tmp <= x and x < 256*wb+8*tmp+8 ]
              if not tmp_rrlist == []:
                  # 1. rescale to fit into 8 bits
                  tmp_rrlist = map(lambda x: (x-256*wb)-(tmp*8), tmp_rrlist)
                  # 2. x gives the bit position ; compute the corresponding value
                  tmp_rrlist = map(lambda x: 2**(7-x) , tmp_rrlist)
                  # 3. sum everything
                  #v = reduce(lambda x,y: x+y, tmp_rrlist)
                  v = sum(tmp_rrlist)
              bitmap += struct.pack("B", v)
     
      return bitmap