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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:56:24+00:00 2026-06-18T05:56:24+00:00

this is just a question regarding notation in OCaml. I am trying to test

  • 0

this is just a question regarding notation in OCaml.

I am trying to test the function

let rec add (x : 'a) (l : 'a set) : bool =
  begin 
    match l with
    | [] -> []
    | hd :: rest -> 
      if x = hd then rest 
      else (hd :: (add x rest))
  end

my test case is

let test () : bool =
add (3 [1; 2; 4]) = [1; 2; 3; 4]
;; run_test "add 3 [1; 2; 4]" test

I am getting an "this expression is not a function, cannot be applied" error

Is something wrong with my notation?

  • 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-18T05:56:25+00:00Added an answer on June 18, 2026 at 5:56 am

    OCaml doesn’t have a built-in set type (instead there is a Set module, or library). So, there’s also no built-in notation for set constants.

    For smallish sets, one often uses lists. And, in fact, List.mem is a function that operates on lists (not sets). The notation for a list is like this: [1; 2; 3; 4].

    (As a side comment, your function named add doesn’t add anything. But maybe you’re just getting started.)

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

Sidebar

Related Questions

This is just a simple question. I was trying to create a new object
I just have a simple question regarding dbms_stats.gather_table_stats. In our application this statement occurs
Just a quick question regarding re-useable code. Ive lately been trying to modularise my
Question regarding Maven Repository and Java EE specification. I just saw this question: Single/complete
I have a question regarding this article. Between this code function odds(n, p) {
This is just a design question regarding massive db design. For instance, if you
Just a quick question regarding the split function How can I split my string
I have a question regarding C++. This is my current function: string clarifyWord(string str)
I have a question regarding inheritance with function objects. I guess this must have
This is just a general question regarding the debate between self-signed certificates and CA

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.