Re: Just one "1" in a list

• To: mathgroup at smc.vnet.net
• Subject: [mg78187] Re: Just one "1" in a list
• From: "Sem" <sarner2006-sem at yahoo.it>
• Date: Sun, 24 Jun 2007 05:50:04 -0400 (EDT)
• References: <f5j11r\$d0m\$1@smc.vnet.net>

```Hello Diana,
you could use Pick[] to extract elements that matched your rule:
In[1]:= l={{1,2},{1,3},{2,3},{2,1},{1,1,2},{1,2,2},{2,1}};

In[2]:= Pick[l, Count[#,1]&/@l, 1]
Out[2]= {{1,2},{1,3},{2,1},{1,2,2},{2,1}}

Best regards,
Sem

"Diana" <diana.mecum gmail com> news:f5j11r\$d0m\$1 at smc.vnet.net...
> Math folks,
>
> Can someone tell me what command I would use to pick out sublists
> which contain just one "1"?
>
> For example, if I have the following list,
>
> {{1,2}, {1,3}, {2,3}, {2,1}, {1,1,2}, {1,2,2}, {2,1}},
>
> I would like to just pull the terms,
>
> {{1,2}, {1,3}, {2,1}, {1,2,2}, {2,1}}.
>
> Can someone help? Thanks, Diana M.

```

• Prev by Date: Quaternions
• Next by Date: Tick Marks on Label
• Previous by thread: Just one "1" in a list
• Next by thread: Re: Just one "1" in a list