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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:33:06+00:00 2026-06-17T18:33:06+00:00

I am trying to create a simple function that takes two dates of format

  • 0

I am trying to create a simple function that takes two dates of format int*int*int and return if the first one is older than the second or not.

fun is_older (date1: (int*int*int), date2: (int*int*int)) =
    val in_days1 = (#1 (date1) * 365) + (#2 (date1) * 30) + #3 date1;
    val in_days2 = (#1 (date2) * 365) + (#2 (date2) * 30) + #3 date1;

    if in_days1 < in_days2
    then true
    else false

I get this error:

hwk_1.sml:1.53 Error: syntax error: inserting EQUALOP

uncaught exception Compile [Compile: “syntax error”]

raised at: ../compiler/Parse/main/smlfile.sml:15.24-15.46

../compiler/TopLevel/interact/evalloop.sml:44.55

../compiler/TopLevel/interact/evalloop.sml:296.17-296.20

Can anyone help please?

  • 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-17T18:33:07+00:00Added an answer on June 17, 2026 at 6:33 pm

    In addition to what has already been mentioned, you also ought to use pattern matching to decompose that 3-tuple. Doing this, you can also throw away the type annotations, as it is now clear that this is a 3-tuple (both for the reader, but more importantly also the type system).

    fun is_older ((y1, m1, d1), (y2, m2, d2)) =
        let
          val days1 = y1 * 365 + m1 * 30 + d1
          val days2 = y2 * 365 + m2 * 30 + d2
        in
          days1 < days2
        end
    

    However you could do this a bit smarter. If you have multiple functions working with dates, you could create a nice little helper function toDays. In the below example i have just included inside the isOlder function, but you could put it at top level or inside a local-declaration if you wan’t to hide it away

    fun isOlder (date1, date2) =
        let
          fun toDays (y, m, d) = y * 365 + m * 30 + d
        in
          toDays date1 < toDays date2
        end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a function that takes two functions as arguments and
I am trying to create a function in VC++ that takes a function pointer
I am trying to create a user-defined command in VIM that takes one argument
I am trying to create a simple function that can take a parameter and
i'm trying to create a simple autocomplete textbox that takes the suggestions from an
i was trying to create a function that takes a list of lists an
I am trying to write a list function that takes a simple list and
So, I'm currently working with JSF trying to create a simple project that takes
I am trying to create a simple page that takes a binary file and
I'm trying to create a simple program or function that will take the users

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.