(hmm..I added a comment and it vanished. Try again)

I was confused by value.length until I read the caller code in another file. I think this function would be clearer if 'value' were spelt 'ary'.