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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:48:18+00:00 2026-06-17T12:48:18+00:00

I have the following recursive function: fun tester (f:’a -> ‘b, tl:(string * ‘a

  • 0

I have the following recursive function:

fun tester (f:'a -> 'b, tl:(string * 'a * 'b) list) =
    case tl of
    [] => []
     | (t, c, e)::rest => 
       let val tr = f (c)
       in
           if tr <> (e)
           then ((t), (e), tr)::(tester (f, rest))
           else tester (f, rest)
       end;

When loading it I get “Error: operator and operand don’t agree [UBOUND match]’:

lec1test.sml:17.5-19.26 Error: operator and operand don't agree [UBOUND match]
  operator domain: ''Z * ''Z
  operand:         'b * 'Y
  in expression:
    tr <> e

uncaught exception Error
  raised at: ../compiler/TopLevel/interact/evalloop.sml:66.19-66.27
             ../compiler/TopLevel/interact/evalloop.sml:44.55
             ../compiler/TopLevel/interact/evalloop.sml:296.17-296.20

I have figured out that I think it has something with the generic binding of tr, but I can’t see why that is a problem. I am assigning trto a value of the function from f, which returns 'b. I then compare the result with the last value in the tuple which also is of type 'b. Can someone explain why this is giving me an error?

  • 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-17T12:48:19+00:00Added an answer on June 17, 2026 at 12:48 pm

    Not all types support the equality operators = and <>, only so-called equality types. For example, int or string list or bool * unit are equality types, but e.g. function types t -> u never are, because there is no reasonable (decidable) way to compare functions.

    Values of a polymorphic type like 'a are not equality types either, because the type variable can be instantiated by any type. To get a polymorphic type restricted to equality types, you need to write a type variable with a double tick, e.g. ''a.

    In your case, changing the first line to

    fun tester (f : ''a -> ''b,  tl : (string * ''a * ''b) list) =
    

    should fix it for you.

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

Sidebar

Related Questions

I have the following recursive function which works... up until a point. Then the
sorry to overflow with so many questions. I have the following: (defun recursive-function (string)
I have a problem providing an edge case for the following recursive function that
I have the following recursive function prototype: public void calcSim(Type<String> fort, Integer metric) Integer
I have the following recursive function: ALTER FUNCTION [dbo].[ListAncestors] ( @Id int ) RETURNS
I have the following recursive function that won't return anything if it has to
I have the following recursive function for project euler question no. 74 : chain
I'm learning Lisp and have written the following function to collect a list of
I have the following recursive function public int Factorial(int number_to_calculate) { if (StackChanged !=
I have the following example of a recursive function, and what I don't understand

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.