Mercurial > hg > may
changeset 186:479a739c99b1
Put block arg at end of rangeOf (better for partial application, though name is not ideal now)
author | Chris Cannam |
---|---|
date | Sun, 05 May 2013 12:41:29 +0100 |
parents | fae36c4570d5 |
children | fd16551c2fc8 |
files | yetilab/block/block.yeti yetilab/block/blockfuncs.yeti yetilab/block/fvector.yeti yetilab/block/test/test_fvector.yeti yetilab/stream/framer.yeti yetilab/stream/syntheticstream.yeti |
diffstat | 6 files changed, 8 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/yetilab/block/block.yeti Sun May 05 11:56:29 2013 +0100 +++ b/yetilab/block/block.yeti Sun May 05 12:41:29 2013 +0100 @@ -38,7 +38,7 @@ empty? is block -> boolean, equal is block -> block -> boolean, copyOf is block -> block, - rangeOf is block -> number -> number -> block, + rangeOf is number -> number -> block -> block, //!!! not well-named now block arg is at the end resizedTo is number -> block -> block, concat is list?<block> -> block, }
--- a/yetilab/block/blockfuncs.yeti Sun May 05 11:56:29 2013 +0100 +++ b/yetilab/block/blockfuncs.yeti Sun May 05 12:41:29 2013 +0100 @@ -43,12 +43,12 @@ fftshift bl = (len = b.length bl; half = int(len/2 + 0.5); // round up for odd-length sequences - b.concat [b.rangeOf bl half (len-half), b.rangeOf bl 0 half]); + b.concat [b.rangeOf half (len-half) bl, b.rangeOf 0 half bl]); ifftshift bl = (len = b.length bl; half = int(len/2); // round down for odd-length sequences - b.concat [b.rangeOf bl half (len-half), b.rangeOf bl 0 half]); + b.concat [b.rangeOf half (len-half) bl, b.rangeOf 0 half bl]); { sum = sum',
--- a/yetilab/block/fvector.yeti Sun May 05 11:56:29 2013 +0100 +++ b/yetilab/block/fvector.yeti Sun May 05 12:41:29 2013 +0100 @@ -54,7 +54,7 @@ copyOf v is ~double[] -> ~double[] = Arrays#copyOf(v, list' v |> length); -rangeOf v start len is ~double[] -> number -> number -> ~double[] = +rangeOf start len v is number -> number -> ~double[] -> ~double[] = Arrays#copyOfRange(v, start, start + len); resizedTo n v is number -> ~double[] -> ~double[] =
--- a/yetilab/block/test/test_fvector.yeti Sun May 05 11:56:29 2013 +0100 +++ b/yetilab/block/test/test_fvector.yeti Sun May 05 12:41:29 2013 +0100 @@ -87,8 +87,8 @@ "rangeOf": \( v = vec.vector [1,2,3,4]; - vec.equal (vec.rangeOf v 0 4) v and ( - vec.equal (vec.rangeOf v 2 2) (vec.vector [3,4]) + vec.equal (vec.rangeOf 0 4 v) v and ( + vec.equal (vec.rangeOf 2 2 v) (vec.vector [3,4]) ) ),
--- a/yetilab/stream/framer.yeti Sun May 05 11:56:29 2013 +0100 +++ b/yetilab/stream/framer.yeti Sun May 05 12:41:29 2013 +0100 @@ -34,7 +34,7 @@ buffer = map2 do buf row: block.concat - [block.rangeOf buf hop (size-hop), + [block.rangeOf hop (size-hop) buf, block.resizedTo hop (m.getRow row)]; done buffer [0..stream.channels-1];
--- a/yetilab/stream/syntheticstream.yeti Sun May 05 11:56:29 2013 +0100 +++ b/yetilab/stream/syntheticstream.yeti Sun May 05 12:41:29 2013 +0100 @@ -46,7 +46,7 @@ get finished? () = not (n > position), read count = ch.deinterleaved 1 (rc = min count (n - position); - result = block.rangeOf data position rc; + result = block.rangeOf position rc data; position := position + rc; result), close = \(),