Oops. Those $'s were typos that I introduced while writing the email. The actual error still occurs.
It has something to do with the "? 1 : 0" part. When I do the following it works. However, how does one handle the ternary operator '?:' assuming I want to set the values to something other than 1 or 0 ? thread_define 'myfunc(o(n);h(n);l(n);c(n); [o]e(n))', over { $_[4] .= (($_[1] - $_[2]) > ($_[3] - $_[0])); }; Thanks Vikas On 09/17/2014 04:23 PM, Chris Marshall wrote: > Your signature argument to thread_define() is > not valid. You can read the refs but the problem > is the $'s. > > --Chris > > On Wed, Sep 17, 2014 at 1:37 PM, Vikas N Kumar <vi...@cpan.org> wrote: >> Hi >> >> I am trying to write a function using thread_define that does some >> conditional checks and creates a PDL with the output. I know I can use >> PDL::PP to do this but that is not what I want here. I want to >> auto-generate some PDL code at runtime to be used like apply()/sapply() >> in R. >> >> However, I am getting stuck at a trivial point and I keep getting an >> error that says "multielement piddle in conditional expression". >> >> Here is an example that reproduces the error: >> >> use PDL; >> use PDL::NiceSlice; >> >> my $ohlc = ones(100, 4) + sequence(100, 4) * 0.05; >> >> thread_define 'myfunc($o(n);$h(n);$l(n); $c(n); [o]$e(n))', over { >> $_[4] .= ($_[1] - $_[2]) > ($_[3] - $_[0]) ? 1 : 0; >> }; >> >> my $b = null; >> myfunc($ohlc(,(0)), $ohlc(,(1)), $ohlc(,(2)), $ohlc(,(3)), $b); >> print $b, "\n"; >> >> >> I am not able to understand why there is a multielement piddle problem. >> Each piddle is of the same dimension except for the output $b which is >> null() and hence can grow in size as needed. >> >> Please advise. >> >> Thanks >> Vikas. >> >> >> _______________________________________________ >> Perldl mailing list >> Perldl@jach.hawaii.edu >> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl > _______________________________________________ Perldl mailing list Perldl@jach.hawaii.edu http://mailman.jach.hawaii.edu/mailman/listinfo/perldl