Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #11326 > unrolled thread
| Started by | benp84@gmail.com |
|---|---|
| First post | 2012-08-14 08:22 +0000 |
| Last post | 2012-08-22 07:54 +0000 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
How to use Pick[]; Is this a bug? benp84@gmail.com - 2012-08-14 08:22 +0000
Re: How to use Pick[]; Is this a bug? Peter Pein <petsie@dordos.net> - 2012-08-15 07:34 +0000
Re: How to use Pick[]; Is this a bug? awnl <awnl@gmx-topmail.de> - 2012-08-22 07:54 +0000
| From | benp84@gmail.com |
|---|---|
| Date | 2012-08-14 08:22 +0000 |
| Subject | How to use Pick[]; Is this a bug? |
| Message-ID | <k0d1sm$lvc$1@smc.vnet.net> |
In[1]:= Pick[{1, 2, 3, 4, 5}, {9, 0, 7, 0, 6}, Except[0]]
Out[1]:= {1, 2, 3, 4, 5}
Shouldn't this return {1, 3, 5}, since these are the corresponding elements that match Except[0]?
[toc] | [next] | [standalone]
| From | Peter Pein <petsie@dordos.net> |
|---|---|
| Date | 2012-08-15 07:34 +0000 |
| Message-ID | <k0fje4$q8n$1@smc.vnet.net> |
| In reply to | #11326 |
Am 14.08.2012 10:22, schrieb benp84@gmail.com:
> In[1]:= Pick[{1, 2, 3, 4, 5}, {9, 0, 7, 0, 6}, Except[0]]
> Out[1]:= {1, 2, 3, 4, 5}
>
> Shouldn't this return {1, 3, 5}, since these are the corresponding elements that match Except[0]?
>
Hi,
the whole list {9, 0, 7, 0, 6} is unequal to the Integer 0.
What you want is:
Pick[{1, 2, 3, 4, 5}, {9, 0, 7, 0, 6}, Except[0, _Integer]]
Cheers,
Peter
[toc] | [prev] | [next] | [standalone]
| From | awnl <awnl@gmx-topmail.de> |
|---|---|
| Date | 2012-08-22 07:54 +0000 |
| Message-ID | <k12385$eo$1@smc.vnet.net> |
| In reply to | #11358 |
Hi,
>> In[1]:= Pick[{1, 2, 3, 4, 5}, {9, 0, 7, 0, 6}, Except[0]]
>> Out[1]:= {1, 2, 3, 4, 5}
>>
>> Shouldn't this return {1, 3, 5}, since these are the corresponding elements that match Except[0]?
>>
>
> the whole list {9, 0, 7, 0, 6} is unequal to the Integer 0.
that's an explanation of what goes wrong, but it still looks very much
like a bug to me: Nothing in the documentation gives a hint that the
second argument as a whole would ever be tried to match the third
argument -- and it wouldn't seem to make any sense to do so for the
given functionality...
> What you want is:
>
> Pick[{1, 2, 3, 4, 5}, {9, 0, 7, 0, 6}, Except[0, _Integer]]
that's of course a very useful workaround
cheers,
albert
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web