Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #4596

Re: Replace

From Peter Pein <petsie@dordos.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Replace
Date 2011-08-26 09:35 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <j37pdu$4n2$1@smc.vnet.net> (permalink)
References <j35am1$og8$1@smc.vnet.net>

Show all headers | View raw


Am 25.08.2011 13:12, schrieb Sam Korn:
> 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

Hi Sam,

  apply the function {Alternatives[##]}&

In[1]:= lst = RandomInteger[9, {5, 2}]
Out[1]= {{0, 5}, {5, 6}, {7, 9}, {8, 8}, {9, 8}}

In[2]:= Apply[{Alternatives[##1]} & , lst, {1}]
Out[2]= {{0 | 5}, {5 | 6}, {7 | 9}, {8 | 8}, {9 | 8}}


Peter

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Replace Sam Korn <sam@kornfamily.com> - 2011-08-25 11:12 +0000
  Re: Replace Ray Koopman <koopman@sfu.ca> - 2011-08-26 09:27 +0000
  Re: Replace "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2011-08-26 09:30 +0000
  Re: Replace Peter Breitfeld <phbrf@t-online.de> - 2011-08-26 09:31 +0000
  Re: Replace Armand Tamzarian <mike.honeychurch@gmail.com> - 2011-08-26 09:33 +0000
    Re: Replace Armand Tamzarian <mike.honeychurch@gmail.com> - 2011-08-27 12:22 +0000
      Re: Replace Peter Pein <petsie@dordos.net> - 2011-08-28 08:09 +0000
    Re: Replace Armand Tamzarian <mike.honeychurch@gmail.com> - 2011-08-29 07:49 +0000
  Re: Replace Peter Pein <petsie@dordos.net> - 2011-08-26 09:35 +0000
  Re: Replace Murray Eisenberg <murray@math.umass.edu> - 2011-08-27 12:25 +0000
    Re: Replace Ray Koopman <koopman@sfu.ca> - 2011-08-28 08:06 +0000
  Re: Replace Murray Eisenberg <murray@math.umass.edu> - 2011-08-28 08:13 +0000

csiph-web