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 7854663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:08:17+00:00 2026-06-02T20:08:17+00:00

I am not really understand about the function ( parse_list ) at None ->

  • 0

I am not really understand about the function (parse_list) at

None -> List.rev is and None -> []

let try_parse parse x = try Some (parse x) with Error _ -> None;;

let parse_list parse =
  let rec aux is = function
    | [] -> List.rev is, []
    | (hd :: tl) as xs ->
    match try_parse parse hd with
      | Some i -> aux (i::is) tl
      | None -> List.rev is, xs
  in aux [];;

and

let parse_list parse =
  let rec aux is = function
    | [] -> List.rev is, []
    | (hd :: tl) as xs ->
    match try_parse parse hd with
      | Some i -> aux (i::is) tl
      | None -> [], xs
  in aux [];;

Are they different? could you please give me an example if they are different? Thank you very much

  • 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-02T20:08:18+00:00Added an answer on June 2, 2026 at 8:08 pm

    Yes, they are different.

    In the first one, when the parse function will fail, the function parse_list will return a partial list of “parsed” expression (List.rev is).

    In the second one, when the parse function will fail, you’ll get an empty list from parse_list ([]).

    Look this example with a parse function which will keep only integers lesser than 3:

    let test_parse x = if x < 3 then x else raise Error "error";;
    

    With the first implementation you’ll get:

    # parse_list test_parse [1; 2; 3; 4; 5];;
      - : int list * int list = ([1; 2], [3; 4; 5])
    

    wit the second one, you’ll get:

    # parse_list test_parse [1; 2; 3; 4; 5];;
      - : int list * int list = ([], [3; 4; 5])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I really do not understand how is this error happening at this code. Please
I do not really understand the proper usage pattern of SQLite transactions in Android.
i've often had this issue where i do not really understand how to pass
I dont really understand why this is not working, I am being returned to
This should really be allowed - I do not understand why it is not.
I've been struggling with some findBy using an entity and I really can't understand
I would like to fully understand what is exactly specified about how function call
When searching for everything about getchar() function in this really great site, I found
I'm not really that good with regex, but I understand the basics. I'm trying
Not really too sure how to word this question, therefore if you don't particularly

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.