class Lists {

  public static <X> List<X> distinct(List<X> inputs) {
    if (null == inputs) {
      return null;
    }

    return foldLeft(new ArrayList<X>(), inputs, new Aggregator<X, List<X>>() {
      private Set<X> mSeen = new HashSet<X>();

      @Override
      public List<X> eval(X input, List<X> out) {
        if (!mSeen.contains(input)) {
          out.add(input);
          mSeen.add(input);
        }
        return out;
      }
    });
  }

  private  Lists();

}