There are many ways of doing this, so here is one suggestion!!!
...
and make a script file (ind.m) that is this:
Hi Doug,
yes that was it. The following shell-script can be given a string of pairs of numbers, with each pair defining one set.
#!/bin/bash
# file: index.sh
octave -qH --eval "
indexes = [$1] ;
indexes = reshape(indexes,2,[])' ;
count = 1 ;
for R = 1:rows(indexes)
for C = 1:indexes(R,1)
printf('%d ' , count:count+indexes(R,2)-1)
printf('\n')
count+=indexes(R,2) ;
end
end
"
This can for for example be called like this:
$ ./index.sh "2 3 1 6 1 2"
1 2 3
4 5 6
7 8 9 10 11 12
13 14
to be processed further in the surrounding shell-script.
Very cool, thank you.
Stefan