open TextIO; load "Int"; local (* makeBinAux (is,os) TYPE: instream * outstream -> unit PRE: (none) POST: () SIDE-EFFECTS: writes the binary representations of the integers in the rows of is to os *) fun makeBinAux(is,os)= if endOfStream(is) then () else let val i = valOf(Int.fromString(inputLine(is))) val s = (Int.fmt StringCvt.BIN(i))^"\n" in output(os,s); makeBinAux(is,os) end in (* makeBin (fIn,fOut) TYPE: string * string -> unit PRE: (none) POST: () SIDE-EFFECTS: writes the binary representations of the integers in the rows of fIn to fOut EXAMPLES: 1005 ---> 1111101101 1014 ---> 1111110110 1019 ---> 1111111011 102 ---> 1100110 1025 ---> 10000000001 *) fun makeBin(fIn,fOut)= let val is = openIn fIn val os = openOut fOut in makeBinAux(is,os); closeIn(is); closeOut(os) end end