MathGroup Archive 2004

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

Search the Archive

Re: Re: All combinations


*This message was transferred with a trial version of CommuniGate(tm) Pro*
On 12 Apr 2004, at 16:44, Harold Noffke wrote:

> Andrzej:
>
> Where is the form "S_List" documented?  What does this notation, with
> the underscore embedded between two strings, signify?  I don't recall
> seeing it before.
>
> Thanks.
> Harold
>
>
>
It represents a pattern named S whose head is List. If you define a 
function f using

f[S_List]:= body

then f[something] will return the result of substituting evaluated 
something into body only if evaluated something has head S, otherwise 
the LHS will be returned unevaluated. This has many uses. One is that 
you cna define f to use a different rule for different heads, e.g.

f[S_List]:= body1

f[S_]:=body2

will use body1 only for lists and body2 for everything else. Another 
use is to prevent your function form trying to work on input for which 
it does not make sense.

Andrzej


  • Prev by Date: Re: NET/Link graphics
  • Next by Date: Re: NDSolve for Newtonian Orbits Question
  • Previous by thread: Re: All combinations
  • Next by thread: Re: All combinations