On 9/24/16 8:29 AM, Christian Franke wrote: > - Method-2 could be significantly speed up if the order of the array > accesses is reversed: > > for (( i=0; i<N-1; i++)); do > if (( -(Pi[i] - Pi[i+1]) < min )); then > min=$((-(Pi[i]-Pi[i+1]))) > fi > done > > Result: ~3 seconds > (using 'let' in the 'min' assignment failed with syntax error - Bug?)
I assume you mean that you used something like let min=-(Pi[i]-Pi[i+1]) That's a syntax error because `(' is a shell operator, and it needs to be quoted if you want it to appear in a word. Since `let' is a builtin, not part of the shell syntax, you have to make sure that all arguments to it are valid shell words. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/