MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Taking either a sequence or a list


I somtimes SetDelay expressions twice, as in

  Foo[L:{___Integer}] := StringJoin["* * * ", ToString[Length[L]], " *
* * "];
  Foo[n___Integer] := Foo[{n}];

reason being that I can then equivalently call either

  Foo[{1, 2, 3, 4, 5}]
  Foo[1, 2, 3, 4, 5]

and not have to worry about whether Foo[ ] takes a string or sequence
as argument. (StringJoin[ ] works the same way, which is where I grew
to like the idea.)

Question: is there a better way to accomplish this type of setting up
both a list-based and sequence-based interface to an expression, other
than twice calling SetDelay explicitly (perhaps by cleverly using
SetAttributes[ ])?

Trevor.


  • Prev by Date: Re: PDF/Illustrator Oddity
  • Next by Date: Re: How to compute this sum?
  • Previous by thread: Re: PDF/Illustrator Oddity
  • Next by thread: Re: Taking either a sequence or a list