MathGroup Archive 2008

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

Search the Archive

Re: A set of several questions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg90173] Re: A set of several questions
  • From: Steven Siew <stevensiew2 at gmail.com>
  • Date: Tue, 1 Jul 2008 07:00:53 -0400 (EDT)
  • References: <g451va$pq7$1@smc.vnet.net> <g47l5a$t98$1@smc.vnet.net>

On Jun 29, 7:37 pm, David Bailey <dave at Remove_Thisdbailey.co.uk>
wrote:
> Let me concentrate on question 5. One way to effectively obtain the
> functionality of structures, is to pick a head that has no meaning and
> use it to make a structure:
>
> myStruct[a,b,4,e]
>
> Such an object could be passed to a function defined as:
>
> f[s_,x_]:= .......
>
> or, preferably
>
> f[s_myStruct,x_]:= .............
>
> The latter form will only accept a myStruct object as its first
> argument, and is thus preferable.
>
> To extract the fourth item of the structure (say), you could write
> Extract[s,4].


There is a much easier way to extract the fourth item. Just use

s=myStruct[a,b,4,e]

s[[4]]

Steven Siew


  • Prev by Date: Re: How to plot discontinuous functions?
  • Next by Date: Re: Re: Subscript Bug?
  • Previous by thread: Re: How to plot discontinuous functions?
  • Next by thread: Re: A set of several questions