dalittle has asked for the wisdom of the Perl Monks concerning the following question:
> test($ref);my $ref = [ 5.0e-5,4.2e-5,4.3e-5,4.4e-5,4.4e-5,4.2e-5,4.2e-5,4.0e- +5]; use Inline C => <<'END_OF_C_CODE'; void test(SV* sv, ...) { I32 i; I32 arrayLen; AV* data; float retval; SV** pvalue; Inline_Stack_Vars; data = SvUV(Inline_Stack_Item(0)); /* Determine the length of the array */ arrayLen = av_len(data); // sort sortsv(AvARRAY(data),arrayLen+1,Perl_sv_cmp_locale); for (i = 0; i < arrayLen+1; i++) { pvalue = av_fetch(data,i,0); /* fetch the scalar located at i + .*/ retval = SvNV(*pvalue); /* dereference the scalar into a numb +er. */ printf("%f \n",newSVnv(retval)); } } END_OF_C_CODE
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perl inline::c sorting problem
by whakka (Hermit) on Apr 30, 2009 at 03:08 UTC | |
by syphilis (Archbishop) on Apr 30, 2009 at 04:40 UTC | |
by BrowserUk (Patriarch) on Apr 30, 2009 at 06:47 UTC | |
by dalittle (Novice) on Apr 30, 2009 at 18:44 UTC | |
by BrowserUk (Patriarch) on May 01, 2009 at 01:52 UTC | |
|