Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #9076
| From | Sseziwa Mukasa <mukasa@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: How can I make a sequence that includes lists? |
| Date | 2012-03-15 05:26 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <jjruhh$94c$1@smc.vnet.net> (permalink) |
| References | <201203140542.AAA25812@smc.vnet.net> |
One option is to use Apply:
IndexedVariable[f, ##] & @@ {{1, x1}, {2, x2}, {3, x3}}
Regards,
Sseziwa
On Mar 14, 2012, at 1:42 AM, JasonE wrote:
> Hello folks,
>
> How can I make a sequence that includes lists?
> Ex:
> Sequence[apple, {rock, tree), {ocean, lake}]
>
> Here is my specific problem:
>
> I use this function to make associative arrays:
> =
IndexedVariable[var_,indicesValues__]:=With[{dict=List[indicesValues]},Scan[(var[#[[1]]]=#[[2]])&,dict]]
>
> (I got it from: =
http://www.physic.ut.ee/~kkannike/english/prog/mathematica/index.html#true_dict)
>
>
> Here is an example of how it takes arguments:
> IndexedVariable[f, {1, "a"}, {2, "b"}, {3, "c"}]
>
> In[2]:= f[1]
> Out[2]= a
>
> In[3]:= f[2]
> Out[3]= b
> ect...
>
> You can imagine, some associations are too long to type out by hand.
> Ex: {1, x1}, {2, x2}...{1000, x1000}
>
> When I make these associations programtically, I get a list back:
> {{1, x1}, {2, x2},...{1000, x1000}}
>
> IndexedVariable[f,{{1, x1}, {2, x2}, {3, x3}...{1000, x1000}}]
> does not work.
>
> It wants a sequence.
>
>
> How can I make a sequence that includes lists?
>
> Thanks,
> Jason
>
> Jason Ebaugh
> Contact: jasonebaugh@jasonebaugh.info
> LinkedIn: www.linkedin.com/in/jasonebaugh
>
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: How can I make a sequence that includes lists? Sseziwa Mukasa <mukasa@gmail.com> - 2012-03-15 05:26 +0000
csiph-web