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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:25:33+00:00 2026-06-18T14:25:33+00:00

So I wrote a function filter that is applied to the given predicate to

  • 0

So I wrote a function “filter” that is applied to the given predicate to each element in the input list and checks whether it should be included in the output.

let rec filer (pred: 'a -> bool) (l: 'a list) : 'a list =
begin match l with
| [] -> []
| hd :: rest -> if (pred hd) then hd :: (filter pred rest) else filter pred rest
end

Now I’m writing a predicate that can be passed to filter to keep just multiples of five.

let multiples_of_five_pred: int -> bool =
filter (fun (x: int) -> x mod 5)

I don’t know what I’m missing here…I’m getting a syntax error that says “this expression has type int but an expression was expected of type bool”.

  • 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-18T14:25:34+00:00Added an answer on June 18, 2026 at 2:25 pm

    The function given to filter needs to produce an boolean, but as the error message is telling you, the function you give to filter produces an integer, not a boolean. You need to change it to produce a boolean instead.

    Once you fix that, you’ll have another type error: Applying filter to a function that takes an integer will produce a function of type int list -> int list, but according to your type signature, you want the type int -> bool.

    Also note that you say that multiples_of_five_prod should be a function that is given to filter, but you actually call filter inside the function. That doesn’t fit. You should remove the call to filter.

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

Sidebar

Related Questions

I am trying to write a function that will filter a list of tuples
I wrote this function to filter a list to show all items after a
I am trying to write a filter function for my application that will take
I wrote function onclick of a element <div class=left_collapsed>Որոնում</div> <div class=container style=display: none;> <ul>
I wrote a function that will open a file dialog, but it won't return
In a piece of example code I wrote var as = toArray(document.getElementsByClassName(false)).filter(function (el) {
I wrote a action filter which is similar to a log function : public
I wrote a function that selects all the users from my database and all
This drives me mad. I just can't understand it. I wrote a filter-function based
I have this really simple c++ function I wrote myself. It should just strip

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.