Re: need to make a special function

• To: mathgroup at smc.vnet.net
• Subject: [mg68297] Re: [mg68284] need to make a special function
• From: Adriano Pascoletti <pascolet at dimi.uniud.it>
• Date: Tue, 1 Aug 2006 06:59:09 -0400 (EDT)
• References: <200607310745.DAA26885@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Nabeel,

f[i] is the list of binary representations of integers from 0 to
2^i-1 (left padded with 0's):

f = Function[i, IntegerDigits[#, 2, i] & /@ Range[0, 2^i - 1]];

For instance f[3] gives
{{0,0,0},{0,0,1},{0,1,0},{0,1,1},{1,0,0},{1,0,1},{1,1,0},{1,1,1}}

A solution in based on Distribute

f1 = Distribute[Table[{0, 1}, {#}], List, List] &;

f1[3] gives

{{0,0,0},{0,0,1},{0,1,0},{0,1,1},{1,0,0},{1,0,1},{1,1,0},{1,1,1}}

On 31 lug 2006, at 09:45, 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
> --
> Nabeel Butt
> LUMS,Lahore
>
>

```

• Prev by Date: Re: need to make a special function
• Next by Date: Re: need to make a special function
• Previous by thread: Re: need to make a special function
• Next by thread: Re: need to make a special function