#!/bin/rc rfork en fn usage { echo usage: $0 '[-x var] [-i ''[min [inc]] max]''] [file] expr' exit usage } bnds=() while(~ $1 -*){ switch($1){ case -x var=$2 shift case -i l=`{ echo $2} for(i in $l) bnds=($i $bnds) l=() shift case -* usage } shift } if(! ~ $#* 1 2) usage if(~ $#* 2){ funcs=$1 shift } if(~ $var '') var=α fn holoop { switch($#bnds){ case 0 bnds=(4 1 0) case 1 bnds=($bnds 1 0) case 2 bnds=($bnds(1) 1 $bnds(2)) } echo -n 'for(i='$bnds(3)'; i<'$bnds(1)'; i+='$bnds(2)')' echo -n '{ print i print ' read -n 1 echo ' print "\n" }' } fn hocomp { if(! ~ $funcs '') cat $funcs || exit error holoop } echo $1 | sed 's/'^$var^'/i/g' | hocomp | hoc | gview