static L map(Iterable l, O f) { ret map(f, l); }

static L map(O f, Iterable l) {
  L x = emptyList(l);
  if (l != null) for (O o : l)
    x.add(callF(f, o));
  ret x;
}

ifclass F1
  static <A, B> L<B> map(Iterable<A> l, F1<A, B> f) { ret map(f, l); }

  static <A, B> L<B> map(F1<A, B> f, Iterable<A> l) {
    L x = emptyList(l);
    if (l != null) for (A o : l)
      x.add(callF(f, o));
    ret x;
  }
endif

static <A, B> L<B> map(Iterable<A> l, IF1<A, B> f) {
  L x = emptyList(l);
  if (l != null) for (A o : l)
    x.add(f.get(o));
  ret x;
}
  
static <A, B> L<B> map(A[] l, IF1<A, B> f) {
  L x = emptyList(l);
  if (l != null) for (A o : l)
    x.add(f.get(o));
  ret x;
}
  
static L map(O f, O[] l) { ret map(f, asList(l)); }
static L map(O[] l, O f) { ret map(f, l); }

static L map(O f, Map map) {
  ret map(map, f);
}

// map: func(key, value) -> list element
static L map(Map map, O f) {
  new L x;
  if (map != null) for (O _e : map.entrySet()) {
    Map.Entry e = (Map.Entry) _e;
    x.add(callF(f, e.getKey(), e.getValue()));
  }
  ret x;
}