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

  • Home
  • SEARCH
  • 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 6194667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:20:06+00:00 2026-05-24T03:20:06+00:00

I have defined a type and a function: type element = … let merge

  • 0

I have defined a type and a function:

type element = ...

let merge (x0: element) (x1: element): element * bool = ...

The second part of the return of merge represents if x0 and x1 are merge-able. If so, the first part of the return is the result of merging, otherwise the first part could be ignored.

Then I would like to realize a function restructure: element list -> element list which keeps merging as long as any 2 elements of the list are merge-able (we replace the 2 elements by the result of their merging of couse) the order of merging is not important.

I guess it must be a recursive function, and a little bit complicated for me at this stage, could anyone help?

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-05-24T03:20:07+00:00Added an answer on May 24, 2026 at 3:20 am

    Ok, I could post a solution but that’s neither fun nor very instructive for you :). Instead let me try to give a few hints and if you’re still stucked I’ll try to help more.

    • Indeed, as Nathan suggested, it sounds like your merge function should return option(element), which is a classical way to return optional results of functions.
    • To write restructure I suggest you start with a function merge_into(res : element, elts : element list) which will try to merge elts into res. That should, hopefully, be easier than restructure.
    • How do you implement restructure using merge_into?

    Don’t hesitate to let me know if you still have problems… happy coding! 🙂

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

Sidebar

Related Questions

I have a function that creates a state. A state is defined as: type
The jQuery validation plugin breaks for elements that have a HTML5 type defined. $(document).ready(function(){
Suppose I have a user defined type: CREATE OR REPLACE TYPE TEST_TYPE AS OBJECT
if I have two classes, and have defined an explicit type conversion between them,
I have defined a custom file type with these lines: syn region SubSubtitle start=+=+
I have defined a custom list template type for SharePoint . I install it
I have a Enum defined as Type public Enum **Type** { OneType, TwoType, ThreeType
I have a user-defined table type. I want to check it's existence before editing
If I have a type defined as a set of an enumerated type, it's
If I have defined the following types: type category = Noun | Verb |

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.