Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1996
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1996

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

Search the Archive

Re: Question?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg4102] Re: Question?
  • From: rhall2 at umbc.edu (hall robert)
  • Date: Tue, 4 Jun 1996 02:18:41 -0400
  • Organization: University of Maryland, Baltimore County
  • Sender: owner-wri-mathgroup at wolfram.com

In article <4obgli$opu at dragonfly.wolfram.com>,
Borworn Wongsaengchantra  <wborworn at vt.edu> wrote:

>I am a novice for Mathematica and I have a problem with Mathematica's command.

Yea, me too. ;)

>I want to show out put like this:
>   /out/ {f1[x],f2[x],f3[x],...,fn[x]}
>Do you know how to use that command?

Here's my best guess:

In[188]:=
  addParts[f_Symbol, var_Symbol] := f[var];
  Outer[
	addParts,
	ToExpression[StringJoin["f", #]& /@ Map[ToString, Range[5]]],
	{x}
  ] // Flatten
Out[188]=
  {f1[x], f2[x], f3[x], f4[x], f5[x]}

or

In[199]:=
  addParts[f_Symbol, var_Symbol] := f[var];
  SetAttributes[addParts, Listable];
  ToExpression[StringJoin["f", #]& /@ Map[ToString, Range[5]]];
  addParts[%, x]
Out[202]=
  {f1[x], f2[x], f3[x], f4[x], f5[x]}

Anybody know how to do this without converting from expression
to string and back?

If you're willing to live with subscripts, another way is:

In[136]:=
  Table[Subscripted[f[i]][x], {i, 1, 5}]
Out[136]=
  {f [x], f [x], f [x], f [x], f [x]}
    1      2      3      4      5

If you don't like the subscripts but can tolerate an additional
space, try this:

In[147]:=
  Table[SequenceForm[f i[x]], {i, 1, 5}]
Out[147]=
  {f 1[x], f 2[x], f 3[x], f 4[x], f 5[x]}

-- 
Bob Hall            | "Know thyself? Absurd direction!
rhall2 at gl.umbc.edu  |  Bubbles bear no introspection."  -Khushhal Khan Khatak

==== [MESSAGE SEPARATOR] ====


  • Prev by Date: Re: question
  • Next by Date: Loading packages
  • Previous by thread: Re: question
  • Next by thread: Loading packages