Print EAN13 Barcodes by m.ukai

open Printf
let s=[|39;51;27;33;29;57;5;17;9;23;13;25;19;61;35;49;47;59;55;11|]let rec(@)x i=i>0&(print_char" #".[x mod 2];x/2@i-1)and(!)x=s.(x)@7and w _=w(Scanf.scanf"%d %1d%1d%1d%1d%1d%d %1d%1d%1d%1d%d
"(fun a b c d e f g h i j k l->let(%)b?(d=1 lsl a)c=s.(c-d land b/d*10+10)lxor 127@7and
m=(-a-c-e-g-i-k-3*(b+d+f+h+j+l-90))mod 10in
for q=0to 9do
20@5;1023%b;15%c;401%d;563%e;229%f;841%g;10@5;!h;!i;!j;!k;!l;!m;printf"# #
"done;printf"%d # #%4d%7d%7d%7d%7d%7d    # #%5d%7d%7d%7d%7d%7d   # # >

"a b c d e f g h i j k l m));;w()

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page