Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8722347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:23:43+00:00 2026-06-13T07:23:43+00:00

My function is trying to read a textfile line by line and carry out

  • 0

My function is trying to read a textfile line by line and carry out a certain predefined function on each line called somefn and append the value of somefn to the function. The somefn is already defined above this and works fine.

fun extractline(infile:string)=
    let
    val insl=TextIO.inputLine(ins)
    case insl of
    NONE=> []
    |SOME(l)=>somefn(insl)::extractline(infile)
    in
    TextIO.closeIn(ins);
    end
;

I am having errors and cannot handle them.
I would appreciate some help.

Thank You.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:23:46+00:00Added an answer on June 13, 2026 at 7:23 am

    Remember, in let ... in ... end blocks, you place declarations you need between let and i n, and the resulting expression between in and end.

    As such, you need your case expression placed between in and end.

    You also never open the stream, ins. Make your function open the stream, and then work recursively on that stream in another function, however; you don’t want to open the file for each recursive call.

    You’ll want something on this form:

    fun extractline file =
      let
          val ins = TextIO.openIn file
    
          fun extractline_h () = (* do something with ins here *)
      in
          extractline_h () before
          TextIO.closeIn ins
      end
    

    Then you make extractline_h be recursive, and build up the list in that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to read a text file line by line, and add each line
I'm trying to read a text file and store each line in a node
I was trying to make a Read\Write function for websocket but i've a problem...
I'm trying to write a short function that will let me quickly read in
I'm trying to read from a text file using the read function and store
I am trying to read a full mp3 file in order to read out
I am trying to read a SQL Server table in C++ using a function
I'm trying to read a text file and then print out the integers in
I'm trying to read int and strings arrays in MATLAB of the following function:
I am trying to use the load() function in MATLAB to read in data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.