[erlang-questions] Can I do the same with a fold easily
Éric Pailleau
eric.pailleau@REDACTED
Mon Oct 19 22:53:52 CEST 2015
Hi,
I agree but like Joe says: let it work, then optimize if needed.
My main remark was: Splitting odd and even does not need to check odd then even, but check it is odd Else it is even (or contrary).
Regards
Le 19 oct. 2015 4:54 AM, ok@REDACTED a écrit :
>
> "Éric Pailleau" <eric.pailleau@REDACTED>
>
> > A number cannot be both even and odd, so simply take odd numbers in a
> > variable O from list L , even numbers will be L -- O.
>
> Here we run into the question "what does BEST mean?"
>
> Now Xs -- Ys cannot assume anything about the contents of Xs or Ys,
> other than them both being well formed lists. So while it *could*
> be implemented in O(|Xs|+|Ys|+|Xs|lg|Ys|) time by building some kind
> of balanced search tree from Ys, or even better by building some
> kind of hashed set, the cost of building the supporting data structure
> would likely be worse than the cost of traversing L twice or using
> lists:partition/2.
>
>
>
More information about the erlang-questions
mailing list