Mercurial > hg > may
changeset 435:bdda1da38eb1
A couple of short circuits
author | Chris Cannam |
---|---|
date | Tue, 08 Oct 2013 08:43:01 +0100 |
parents | 6920a0f107a6 |
children | 563d52c00f06 |
files | src/may/stream/audiofile.yeti src/may/vector/blockfuncs.yeti |
diffstat | 2 files changed, 7 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/may/stream/audiofile.yeti Tue Oct 08 08:18:22 2013 +0100 +++ b/src/may/stream/audiofile.yeti Tue Oct 08 08:43:01 2013 +0100 @@ -153,6 +153,7 @@ n = AudioSystem#write(new AudioInputStream(new StreamAdapter()), AudioFileFormat$Type#WAVE, f); str.close (); +//!!! no, the header size is included in the return value! n / (channels * bitdepth)); {
--- a/src/may/vector/blockfuncs.yeti Tue Oct 08 08:18:22 2013 +0100 +++ b/src/may/vector/blockfuncs.yeti Tue Oct 08 08:43:01 2013 +0100 @@ -101,10 +101,14 @@ vec.vector out); scaled n v = - vec.fromList (map (* n) (vec.list v)); + if n == 1 then v + else vec.fromList (map (* n) (vec.list v)); + fi; divideBy n v = // Not just "scaled (1/n)" -- this way we get exact rationals - vec.fromList (map (/ n) (vec.list v)); + if n == 1 then v + else vec.fromList (map (/ n) (vec.list v)); + fi; sqr v = multiply v v;