text: function max_element(f, l, r) {
      if (equal(f, l)) return l;
  
      var m = f;
      f = successor(f);
  
      while ( ! equal(f, l)) {
          if ( ! r(source(f), source(m))) {
              m = f;
          }
          f = successor(f);
      }
      return m;
  }
  
  function usage() {
      var s = sequence(array_random(), "s");
  
      var l = end(s);
      
      var m = max_element(begin(s), l, lt);
      if ( ! equal(m, l)) {
          print("The max element is: " + source(m));
      } else {
          print("An empty sequence has no max element");
      }
  }
  
  function attributes() {
      return {
          class: ['Selection'],
          complexity: 'n - 1 comparisons',
          "type requirements": ['f, l: I: Iterator \u2227 Readable',
                                'r: R: StrictWeakOrdering relation',
                                'Domain(R) = ValueType(I)'],
          precondition: 'readable_bounded_range(f, l)',
          postcondition: 'source(m) = sort_stable_copy(f, l, r)[0]',
          other: ['Stable'],
      };
  }