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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:48:33+00:00 2026-05-23T08:48:33+00:00

my Haskell* is a bit rusty, so i can imagine that I’m missing the

  • 0

my Haskell* is a bit rusty, so i can imagine that I’m missing the obvious:

def any[A](s: Traversable[A], f: A => Boolean): Boolean = {
    s.foldLeft(false)((bool, elem) => bool || f(elem))
}

Does one of these properties apply to the it?

  1. predefined somewhere in the Scala libs
  2. circumstantial, and faster written as some one-liner
  3. wrong (I didn’t test it, sorry ;))

*actually SML, but that’s 99% the same, but known by nobody under the sun.

  • 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-23T08:48:33+00:00Added an answer on May 23, 2026 at 8:48 am
    1. It’s predefined and is called exists. And forall would be the “all” function you are looking for.

      scala> Vector(3, 4, 5).exists(_ % 2 == 0)
      res1: Boolean = true
      
      scala> Vector(3, 4, 5).forall(_ % 2 == 0)
      res2: Boolean = false
      
    2. You can make it more performant using a for loop with a break (from scala.util.control.Breaks). (See the standard library implementation of exists and forall.)

    3. It’s correct.

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

Sidebar

Related Questions

I am a bit rusty on my Haskell and am looking to ramp back
In Haskell, how can I generate Fibonacci numbers based on the property that the
I'm new to Haskell, and I'm trying a bit: isPrime :: Integer->Bool isPrime x
After playing around with haskell a bit I stumbled over this function: Prelude Data.Maclaurin>
I'm just digging a bit into Haskell and I started by trying to compute
A bit of a neophyte haskell question, but I came across this example in
Haskell provides the feature something like f = f1 . f2 How can I
In Haskell, is there a way to restrict a monad M a so that
In Haskell, lifted type products mean that there's a semantic difference between (a,b,c) and
I've been playing around with Haskell a fair bit, including practising writing functions in

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.