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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:27:18+00:00 2026-05-22T22:27:18+00:00

This is a question of design, not of existing functionality. I would like to

  • 0

This is a question of design, not of existing functionality.

I would like to use:

{1, 2, 3, 4, 5}[[{1 ;; 3, 2 ;; 5}]]

I expect:

{{1, 2, 3}, {2, 3, 4, 5}}

But it is not valid:

During evaluation of In[1]:= Part::pspec: Part specification {1;;3,2;;5} is neither an integer nor a list of integers. >>

I am not asking why this does not work (simple: it’s not supported).

Rather, is there a reason it should not work? That is, is there a logical reason this is not supported?


By the way, I specifically did not ask about the nested list syntax like:

{1, 2, 3, 4, 5}[[{{1, 2, 3}, {2, 3, 4, 5}}]]

because I believe that is less “regular” and more volatile, while Span is more defined and controlled.

  • 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-22T22:27:19+00:00Added an answer on May 22, 2026 at 10:27 pm

    I think the real question that you are asking is why this does not work:

    In[15]:= {1,2,3,4,5}[[{{1,2,3},{2,3,4,5}}]]
    
    During evaluation of In[15]:= Part::pspec: Part specification 
    {{1,2,3},{2,3,4,5}} is neither an integer nor a list of integers. >>
    
    Out[15]= {1,2,3,4,5}[[{{1,2,3},{2,3,4,5}}]]
    

    because Span seems to be a more high-level wrapper implemented on top of Part (this is a guess). This same question has been asked very recently on MathGroup. There wasn’t a satisfactory answer, and my feeling is that from the user’s viewpoint, this is just an omission – I don’t see a fundamental reason why this should not work. Moreover, this feature would make life a lot easier in some cases.

    From the technical/implementation viewpoint, I can speculate that this will go at odds with the extended Part assignment functionality. Specifically, we know that Part can be used not just for element extraction but for efficient element assignments, where whole regular structures (rectangular sub-matrices) can be assigned simultaneously, like

    In[18]:= 
    a = Table[i+j,{i,2},{j,4}]
    
    Out[18]= {{2,3,4,5},{3,4,5,6}}
    
    In[21]:= 
    a[[All,{2,3}]] = {{7,8},{9,10}};
    a
    
    Out[22]= {{2,7,8,5},{3,9,10,6}}
    

    Should Part allow nested lists specification for positions, it should immediately provide assignment functionality for the non-rectangular sub-structures, or it will become much less intuitive to use (since there will be corner cases, etc). And I suspect that the latter is not easy to implement, because extended Part assignment functionality is probably based directly on the array memory layout. This will also create problems with packed arrays (for the same reason – they can not be ragged, must be rectangular). Perhaps, should Mathematica have very efficient ragged array structure (like linked lists) built-in, and this could be solved.

    So, to summarize: it looks like, from the implementation viewpoint, such new functionality will introduce several tough problems, which may explain why this has not been done yet (again, this is a guess). Note also, that for element extraction, one can use Extract with prepared list of positions, to extract arbitrary substructures, and that will be almost as efficient as with using Part.

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

Sidebar

Related Questions

This is a design question: when do I need to create/use a static method
This should be a very basic design question, but for some reason it doesn't
This is issue about LANGUAGE DESIGN. Please do not answer to the question until
This question is more UI/Design-ish than hard-core programming is. Background: I've been coding in
Please note this question related to performance only. Lets skip design guidelines, philosophy, compatibility,
I'm working on a database design for an e-commerce web application. For this question
This is a design question, I noticed that by time by LINQ-to-SQL Context gets
This is a design question. I'm trying to decide between 2 implementations. In order
This is more of a design question. I have a template class, and I
This is a practical Domain Driven Design question: Conceptually, I think I get Aggregate

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.