MathGroup Archive 2006

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

Search the Archive

Re: need to make a special function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg68308] Re: [mg68284] need to make a special function
  • From: "Carl K. Woll" <carlw at wolfram.com>
  • Date: Tue, 1 Aug 2006 06:59:29 -0400 (EDT)
  • References: <200607310745.DAA26885@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Nabeel Butt wrote:
> Dear Users,
>         I need help on making a special type of function which has the
> following properties.
>    f[1]={{0},{1}}
>    f[2]={{0,0},{0,1},{1,0},{1,1}}
>    f[3]={{0,0,0},{0,0,1},{0,1,0},{0,1,1},{1,0,0},{1,0,1},{1,1,0},{1,1,1}}
> .............so on you can see the pattern emerging.
>  I need a very efficient code to perform the above evaluation in some
> optimization problem.
>     Thanks in advance.
>      regards,
>         Nabeel

In version 5.1 you can use Tuples:

In[7]:= Tuples[{0, 1}, 1]

Out[7]= {{0}, {1}}

In[8]:= Tuples[{0, 1}, 2]

Out[8]= {{0, 0}, {0, 1}, {1, 0}, {1, 1}}

In[9]:= Tuples[{0, 1}, 3]

Out[9]= {{0, 0, 0}, {0, 0, 1}, {0, 1, 0}, {0, 1, 1}, {1, 0, 0},
{1, 0, 1}, {1, 1, 0}, {1, 1, 1}}

Carl Woll
Wolfram Research


  • Prev by Date: Re: Mouse wheel scroll speed
  • Next by Date: Jacobi Elliptic Function definition
  • Previous by thread: Re: need to make a special function
  • Next by thread: Re: need to make a special function