Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #4573 > unrolled thread
| Started by | DrMajorBob <btreat1@austin.rr.com> |
|---|---|
| First post | 2011-08-26 09:27 +0000 |
| Last post | 2011-08-26 09:27 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Replace DrMajorBob <btreat1@austin.rr.com> - 2011-08-26 09:27 +0000
| From | DrMajorBob <btreat1@austin.rr.com> |
|---|---|
| Date | 2011-08-26 09:27 +0000 |
| Subject | Re: Replace |
| Message-ID | <j37otm$4ie$1@smc.vnet.net> |
list = RandomInteger[10, {10, 2}]
{{2, 3}, {8, 5}, {8, 0}, {7, 4}, {8, 8}, {1, 0}, {10, 4}, {8, 3}, {5,
10}, {3, 9}}
list /. {x_, y_} :> x | y
{2 | 3, 8 | 5, 8 | 0, 7 | 4, 8 | 8, 1 | 0, 10 | 4, 8 | 3, 5 | 10,
3 | 9}
or
Replace[list, {x_, y_} :> x | y, {1}]
{2 | 3, 8 | 5, 8 | 0, 7 | 4, 8 | 8, 1 | 0, 10 | 4, 8 | 3, 5 | 10,
3 | 9}
The first version (but not the second) will fail if you have only two
pairs.
Bobby
On Thu, 25 Aug 2011 06:06:37 -0500, Sam Korn <sam@kornfamily.com> wrote:
> Hi, another stupid question. I have a list, and each element in the list
> is
> a sublist with a pair of integers. How do I replace each element along
> the
> lines of "{5,6}" with "(5|6)"?
>
> I know it's a stupid question, and there's probably something really
> obvious
> I'm missing, but I'm really new to Mathematica.
>
> Thanks!
> -Sam
--
DrMajorBob@yahoo.com
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web