create_list makelist possible bugs



On Mon, Sep 8, 2008 at 8:35 PM, Robert Dodier <robert.dodier at gmail.com>
wrote:

> (2) Are you really going to call inpart ? I don't know what you are trying
> to do, but part hacking is rarely necessary. If you just want the first
> and second arguments of expr, why not first(expr) and second(expr) ?
>

If expr is a list, then expr[1] and expr[2] are the best way to get its
first and second elements.

For non-list expressions, first(expr) and second(expr) are just synonyms for
part(expr,1) and part(expr,2) and share the disadvantage that they reformat
(nformat) the whole expression:

  qq: expand((1+1/x)^100)$
  thru 100000 do part(qq,2)  => 7.35 s
  thru 100000 do inpart(qq,2)=> 0.54 s
  thru 100000 do second(qq)  => 7.44 s

For sophisticated users, inpart is much better.

Though it is tempting to optimize part so that it has its own private
partial nformat, that makes for very hard-to-maintain code if part is going
to remain completely aligned with the display of expressions (under a
variety of parameter settings), which it has to be.

              -s