Thanks. I don't have time to try it right now but the meaning of the code is pretty clear and I should be able to adapt it without much trouble.
David On Fri, Jun 26, 2009 at 2:59 PM, Craig DeForest <[email protected]>wrote: > use this: > > sub pdlstr { > my($pdl,$indent) = @_; > > return "$indent$pdl" unless($pdl->ndims); > return "$indent\{" . join(", ", list $pdl) . "\}" if($pdl->ndims==1); > > return "$indent\{\n" . > join(",\n", map { pdlstr( $_, " $indent" ) } $pdl->dog ) . "\n" > . > "$indent\}"; > } > > > On Jun 26, 2009, at 8:36 AM, David Mertens wrote: > > Hey folks - > > I am pretty new to PDL but I'm having a lot of fun learning the language. > I'm working on a graphics module that allows me to interface with Asymptote, > a vector graphics scripting language. Asymptote has no interface to its > internals so instead I open a pipe to the interpreter and send commands > directly to the interpreter. > > My question is this. I would like to send piddles to Asymptote and have it > read them in as arrays. This way, I could use PDL for my file handling and > data processing and then easily send the data to be plotted to Asymptote. I > could almost do this with pdl's print function, simply printing the pdl > straight to the pipe, except that Asymptote expects braces and comma > delimiters, so in PDL I would get > [ > [ 1 2 3 ] > [ 4 5 6 ] > [ 7 8 9 ] > ] > but for Asymptote I would want to have, preferably without the newlines, > { > {1, 2, 3}, > {4, 5, 6}, > {7, 8, 9} > } > > I think I could implement this with PDL::PP (though I'm not sure how to > handle the output with C code and I've not played around with PP yet), but > I'd rather just find the original code for pdl's print statement and hijack > it for my command. > > Presently, by the way, I'm accomplishing this by opening a filehandle to a > perl *string*, using pdl's print statment to print to that, processing it > using regexp's, and then sending that along to the Asymptote pipe. It works > but I'm sure it's memory inefficient and slow; there's gotta be a better > way. > > Thanks! > David > _______________________________________________ > Perldl mailing list > [email protected] > http://mailman.jach.hawaii.edu/mailman/listinfo/perldl > > >
_______________________________________________ Perldl mailing list [email protected] http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
