Permalink
Browse files

Added octave support

  • Loading branch information...
spencertipping committed May 21, 2015
1 parent 24ccf99 commit 98d09d257600f98af158eecdc078e00c8f7abc46
Showing with 21 additions and 0 deletions.
  1. +21 −0 nfu
View
21 nfu
@@ -522,6 +522,7 @@ my %arity = (
tcp => 1,
http => 1,
repeat => 2,
+ octave => 1,
);
my %usages = (
@@ -581,6 +582,7 @@ my %usages = (
tcp => 'TCP server (emits fifo filenames)',
http => 'HTTP adapter for TCP server output',
repeat => 'repeat count, pseudofile to repeat',
+ octave => 'pipe through octave; vector is called xs',
);
my %env_docs = (
@@ -1333,6 +1335,25 @@ my %functions = (
}
},
+ octave => sub {
+ my ($commands) = @_;
+ my $temp = tmpnam;
+ open my $fh, '>', $temp or die $!;
+ be_verbose_as_appropriate(length), print $fh $_ while <>;
+ close $fh;
+
+ system 'octave',
+ '-q',
+ '--eval', "xs = load(\"$temp\");"
+ . "$commands;"
+ . "save -ascii $temp xs";
+
+ open $fh, '<', $temp;
+ print while <$fh>;
+ close $fh;
+ unlink $temp;
+ },
+
stateful_unary_fn('average',
sub {my ($size, $n, $total) = ($_[0] // 0, 0, 0);
[$size, $n, $total, []]},

0 comments on commit 98d09d2

Please sign in to comment.