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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:03:07+00:00 2026-05-22T23:03:07+00:00

The Phobos documentation shows the following example of ranges passed to a variadic function

  • 0

The Phobos documentation shows the following example of ranges passed to a variadic function

int[] a = [ 1, 2, 4, 5, 7, 9 ];
int[] b = [ 0, 1, 2, 4, 7, 8 ];
int[] c = [ 0, 1, 4, 5, 7, 8 ];
assert(equal(setIntersection(a, a), a));
assert(equal(setIntersection(a, b), [1, 2, 4, 7][]));
assert(equal(setIntersection(a, b, c), [1, 4, 7][]));

But what if you have a range of ranges, and you don’t know in advance how many elements it will contain, like

int[][] a = [[1,2,3,4],[1,2,4,5],[1,3,4,5]];

The only thing I can think of is

if (a.length > 1) {
    auto res = array(setIntersection(a[0], a[1]));
    for (int i = 2; i < a.length; i++)
        res = array(setIntersection(res, a[i]));
    writeln(res);
}

Which works. But I was hoping to be able to pass the argument directly to the function, like setIntersection(a.tupleof) or something like that (I know that tupleof doesn’t work here).

  • 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-22T23:03:08+00:00Added an answer on May 22, 2026 at 11:03 pm

    if you don’t know how many elements a will have you won’t be able to expand it into a tuple at compile time (and consequently pass it into a function)

    so that for loop is your best bet (or implement your own setIntersection that can take a range of ranges)

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

Sidebar

Related Questions

The jQuery documentation lists the following example of using $.getJSON to request JSONP: $.getJSON(http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any&format=json&jsoncallback=?,
The aws-s3 documentation says: # Copying an object S3Object.copy 'headshot.jpg', 'headshot2.jpg', 'photos' But how
I haven't found any documentation on this or seen this done before, but is
I have read the Apple documentation. They list the apps registered, yet in their
Apple's NSURLCache class has decent documentation , but it doesn't say what caching algorithm
I'm trying to learn D but am struggling with lack of documentation (or my
I combed through the Facebook documentation but didn't see an obvious way to return
Using D1 with phobos I have a text entry field, instance of gtk.Entry.Entry ,
Why does Phobos use enum to define constants? For example, in std.math: enum real
For photos, I use Flickr. But for other documents...Which web based online application (hosted

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.