Jump to content

General FizzBuzz: Difference between revisions

m
→‎{{header|AWK}}: Print() to redirect status-messages to stderr
m (→‎{{header|REXX}}: reinstituted deleted text again.)
m (→‎{{header|AWK}}: Print() to redirect status-messages to stderr)
Line 66:
<lang awk># usage: awk -f fizzbuzzGen.awk > fizzbuzzCustom.awk
#
function Print(s) {
BEGIN { print "# Generate:"
print s > "/dev/stderr"
}
BEGIN { printPrint( "# FizzBuzz-Generate:" )
q2 = "\""
fN = "numbers.txt"
Line 72 ⟶ 75:
}
 
NF==1 { printPrint( "# ", $1, " Numbers:" )
for( i=1; i <= $1; i++ )
print( i ) > fN # (!!) write to file not #allowed (!!)in sandbox at ideone.com
 
printPrint( "# Custom program:" )
print "BEGIN {print " q2 "# CustomFizzBuzz:" q2 "} \n"
next
}
 
NF==2 { #printPrint( "# ", $1 "-->" $2 ) ##
print "$1 % "$1" == 0 {x = x "q2 $2 q2 "}"
next
}
 
END { print ""
print "!x {print $1; next}"
print " {print " q2 " " q2 ", x; x=" q2 q2 "}"
 
print "END \nEND {print " q2 "# Done." q2 "}"
print Print( "# Done." )
}</lang>
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.