Question
my code compiles fine, but when i call the - strip(input.txt,output.txt); stdIn:2.1-2.32 Error: operator and operand do not agree [tycon mismatch] operator domain: string operand:
my code compiles fine, but when i call the - strip("input.txt","output.txt"); stdIn:2.1-2.32 Error: operator and operand do not agree [tycon mismatch] operator domain: string operand: string * string in expression: strip ("input.txt","output.txt") - strip'("input.txt","output.txt")'; stdIn:2.19 Error: illegal token
i get this error.
How do I fix this!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!11111
open TextIO
fun strip (inputFile:string) (outputFile:string) : unit =
let
val input = TextIO.openIn inputFile
(* open the output file for writing *)
val output = TextIO.openOut outputFile
fun processLine (line: string option) : unit =
(* check if the end of the file has been reached *)
if line = NONE then
(* close the input and output files *)
(TextIO.closeIn input; TextIO.closeOut output)
else
let val str = valOf(line)
in
(* check if the line is empty *)
if str = "" then
(* if empty, move to the next line *)
processLine (TextIO.inputLine input)
(* check if the line can be converted to an integer *)
else if Int.fromString(str) <> NONE then
(* if it can be converted, convert it and write it to the output file *)
(TextIO.output (output, (Int.toString (valOf (Int.fromString str))));
processLine (TextIO.inputLine input))
else
(* if it can't be converted, move to the next line *)
processLine (TextIO.inputLine input)
end
in
(* start processing the input file from the first line *)
processLine (TextIO.inputLine input)
end
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started