Re: vector C++ version of IDL where statement? [message #30725] |
Wed, 15 May 2002 16:40 |
Sean Dettrick
Messages: 12 Registered: April 2002
|
Junior Member |
|
|
Thanks James. It's hairy-looking syntax to me, but after poring over my
C++ book I'm beginning to get the point.
Cheers,
Sean
James Kuyper wrote:
>
> Sean Dettrick wrote:
>
>> Hi,
>> this is a hybrid C++/IDL newsgroup question, but I shall risk your
>> wrath:
>>
>> Does anybody know how to do an IDL WHERE statement in C++ ??
>>
>> e.g.
>> IDL> x=findgen(100)
>> IDL> w=where(x gt 50)
>> IDL> x(w)=50
>>
>> how do you convert to C++?
>
> // You'll need these:
> #include <algorithm>
> #include <functional>
>
> // Once you've set up 'x', then it's simple:
> std::replace_if(x.begin(), x.end(),
> std::bind2nd(std::greater, 50), 50);
|
|
|
Re: vector C++ version of IDL where statement? [message #30729 is a reply to message #30725] |
Wed, 15 May 2002 16:04  |
James Kuyper
Messages: 425 Registered: March 2000
|
Senior Member |
|
|
Sean Dettrick wrote:
> Hi,
> this is a hybrid C++/IDL newsgroup question, but I shall risk your
> wrath:
>
> Does anybody know how to do an IDL WHERE statement in C++ ??
>
> e.g.
> IDL> x=findgen(100)
> IDL> w=where(x gt 50)
> IDL> x(w)=50
>
> how do you convert to C++?
// You'll need these:
#include <algorithm>
#include <functional>
// Once you've set up 'x', then it's simple:
std::replace_if(x.begin(), x.end(),
std::bind2nd(std::greater, 50), 50);
|
|
|