#!/usr/local/bin/perl -w # DS.p - read in integer list difference set # and write out top row of a binary file that describes the set # see qecc/DDS # and dds.p $S = 0 ; # the set size from which points are drawn 0..S-1 # expect input like this # D=1 I=9 S=73: 0 1 11 20 38 43 59 67 71 - OK!! # D=2 I=3 S=4: 0 1 2 - OK!! $v=0; # $cyclic=0; # whether to print out the whole cyclic code. eval "\$$1=\$2" while @ARGV && $ARGV[0]=~ /^(\w+)=(.*)/ && shift; while ( <> ) { next if (/^\#*\s*\n/) ; if ( /^([^\:]+)\:\s*(.*)/ ) { $ss=$1 ; $l = $2 ; print "ss = $ss\n" if($v); if ( $ss =~ /S=(\d+)/ ) { $S = $1 ; } else { print STDERR "can't find S in input\n" ;} } else { print STDERR "input not of standard form\n" ; $l = $_ ; } print STDERR "S = $S " ; $_ = $l ; print "l = $l;\n" if ($v) ; s/^\s+// ; s/[^\s\d]/ /g ; # remove non-numbers # prepend boundary conditions #$s[-1] = -1 ; #$s[$I] = $S ; $_ = "-1 ".$_." $S" ; @s = split ; $I = $#s ; printf STDERR " I = %d\n" ,$I-1; if ( $s[1] != 0 ) { print STDERR "unusual value of s[1] = $s[0]\n" ; } $ans="" ; for ( $i = 1; $i <= $I ; $i ++ ) { print "i=$i s[i] = $s[$i]\n" if($v); $delta = $s[$i] - $s[$i-1] -1 ; # this is the number of 0s to print $ans .= "0 "x$delta ; if ( $i < $I ) { $ans .= "1 " ; } } print $ans."\n" ; }