Jump to content

FizzBuzz/AWK: Difference between revisions

m
(-Version #)
Line 95:
<lang AWK># usage: awk -v n=42 -f fizzbuzzRepeatPattern.awk
#
function prt(nx,v) {
if(v==0) {printf("%3d ",nx); return} # print number
printf fb[v] # else: print text
}
BEGIN {
Line 108:
while (i<n) {
i++; sel++;
prt(i, substr(pattern,sel,1) ); # select currentwhich variant to use from pattern
if(sel>length(pattern)) { sel=1; }
}
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.