pl_2f_bf_ac_bd_c0_b9_ae_c1_a62
'전자정보공학부 200012911 박동희 '
<code>
open TextIO;
(* ri 함수 고치기*) val file = openIn(“ttt”);
fun ri(f, i) =
let
val c = inputN(f, 1);
in
if c = "\n" then i
else ri(f, 10*i+valOf(Int.fromString(c))-valOf(Int.fromString("0")))
end;
(* 파일 읽어서 제곱하여 결과 출력하기 *) fun exlist(h::nil) = [h*h]
| exlist(h::t) = [h*h]@exlist(t)
fun readlist(infile) =
if endOfStream(infile) then nil else [inputLine(infile)]@readlist(infile)
fun readlist(infile,list) =
let
val c = inputN(infile,1);
in
if c = "\n" then list@["\n"]
else readlist(infile, list@[c])
end;
fun parsestrlst(list) =
if list = nil then []
else
if hd(list) = "\n" then []
else
if hd(list) = " " then parsestrlst(tl(list))
else hd(list)::parsestrlst(tl(list))
else concat[hd(list),hd(tl(parsestrlst(list)))]::parsestrlst(tl(list))
if hd(list) = “\n” then list@nil
val file = openIn(“ttt”);
fun ri(f, i)
let
val c = inputN(infile,1);
in
if c = "\n" then list@["\n"]
else readlist(infile, list@[c])
end;
fun parsestrlst(list) =
if list = nil then []
else
if hd(list) = "\n" then []
else
if hd(list) = " " then parsestrlst(tl(list))
else hd(list)::parsestrlst(tl(list))
else concat[hd(list),hd(tl(parsestrlst(list)))]::parsestrlst(tl(list))
if hd(list) = “\n” then list@nil
fun intTostrl(h::nil) = [Int.toString(h)]
| intTostrl(h::t) = [Int.toString(h)]@intTostrl(t);
fun strTointl(h::nil) = [valOf(Int.fromString(h))]
| strTointl(h::t) = [valOf(Int.fromString(h))]@strTointl(t);
fun printList(nil) = ()
| printList(x::xs) = (
print(x);
print" ";
printList(xs)
);
fun ex2(f:instream) =
let
val c = readlist(f)
in
printList(c);
if c = [] then 1
else ex2(f)
end;
pl_2f_bf_ac_bd_c0_b9_ae_c1_a62.txt · Last modified: 2018/07/18 14:10 by 127.0.0.1