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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:39:46+00:00 2026-06-05T02:39:46+00:00

Why does List.range(0,100).contains(2) Work, while List.range(0,100).par.contains(2) Does not? This is planned for the future?

  • 0

Why does

 List.range(0,100).contains(2)

Work, while

 List.range(0,100).par.contains(2)

Does not?

This is planned for the future?

  • 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-05T02:39:47+00:00Added an answer on June 5, 2026 at 2:39 am

    The non-teleological answer is that it’s because contains is defined in SeqLike but not in ParSeqLike.

    If that doesn’t satisfy your curiosity, you can find that SeqLike‘s contains is defined thus:

    def contains(elem: Any): Boolean = exists (_ == elem)
    

    So for your example you can write

    List.range(0,100).par.exists(_ == 2)
    

    ParSeqLike is missing a few other methods as well, some of which would be hard to implement efficiently (e.g. indexOfSlice) and some for less obvious reasons (e.g. combinations – maybe because that’s only useful on small datasets). But if you have a parallel collection you can also use .seq to get back to the linear version and get your methods back:

    List.range(0,100).par.seq.contains(2)
    

    As for why the library designers left it out… I’m totally guessing, but maybe they wanted to reduce the number of methods for simplicity’s sake, and it’s nearly as easy to use exists.

    This also raises the question, why is contains defined on SeqLike rather than on the granddaddy of all collections, GenTraversableOnce, where you find exists? A possible reason is that contains for Map is semantically a different method to that on Set and Seq. A Map[A,B] is a Traversable[(A,B)], so if contains were defined for Traversable, contains would need to take a tuple (A,B) argument; however Map‘s contains takes just an A argument. Given this, I think contains should be defined in GenSeqLike – maybe this is an oversight that will be corrected.

    (I thought at first maybe parallel sequences don’t have contains because searching where you intend to stop after finding your target on parallel collections is a lot less efficient than the linear version (the various threads do a lot of unnecessary work after the value is found: see this question), but that can’t be right because exists is there.)

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

Sidebar

Related Questions

Why does this work: List<?> list = new LinkedList<Integer>(); while this gives a type
I keep getting a 'List does not exist' error whenever I try and use
I'm trying to build expandableList with SimpleCursorTreeAdapter but my list does not make groups,
I have a list of linear ranges which represent one big range: X' 100
How to group symbols for not in range expression in PHP? <li class=first>list item
does List Sort modify the collection? I think it must as I get a
Does len(list) calculate the length of the list every time it is called, or
Does a List have a property or mechanism by which I can prevent duplicate
Does some basic list operation in Haskell(e.g. ghc) are optimized equivalently to their imperative
If you add grouping to a list view does it inheretly improve performance when

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.