Skip to main content
added 231 characters in body
Source Link

Look at this list

list={1,2,3,4}

Obiously

list[[1, 2]]

throws the error:

During evaluation of Part::partd: Part specification {1,2,3,4}[[1,2]] is longer than depth of object.

However:

list[[1,All]]

yields (Mathematica 12 on Windows)

Integer[]

which does not make much sense to me. Moreover, weird constructs like list[[All,All,All,All,All]] do not throw an error.

Can this (at least to me) strange behaviour of the basic command Part[] be explained? (Needless to say, that this is just a simple demonstration of the effect, but it occured during execution a larger program with strange consequences.)

EDIT: I just realized that this question is closely related to mine and adds some more aspects to it.

Look at this list

list={1,2,3,4}

Obiously

list[[1, 2]]

throws the error:

During evaluation of Part::partd: Part specification {1,2,3,4}[[1,2]] is longer than depth of object.

However:

list[[1,All]]

yields (Mathematica 12 on Windows)

Integer[]

which does not make much sense to me. Moreover, weird constructs like list[[All,All,All,All,All]] do not throw an error.

Can this (at least to me) strange behaviour of the basic command Part[] be explained? (Needless to say, that this is just a simple demonstration of the effect, but it occured during execution a larger program with strange consequences.)

Look at this list

list={1,2,3,4}

Obiously

list[[1, 2]]

throws the error:

During evaluation of Part::partd: Part specification {1,2,3,4}[[1,2]] is longer than depth of object.

However:

list[[1,All]]

yields (Mathematica 12 on Windows)

Integer[]

which does not make much sense to me. Moreover, weird constructs like list[[All,All,All,All,All]] do not throw an error.

Can this (at least to me) strange behaviour of the basic command Part[] be explained? (Needless to say, that this is just a simple demonstration of the effect, but it occured during execution a larger program with strange consequences.)

EDIT: I just realized that this question is closely related to mine and adds some more aspects to it.

Tweeted twitter.com/StackMma/status/1122923748003319808
Became Hot Network Question
edited tags
Link
Michael E2
  • 244.9k
  • 18
  • 351
  • 774
Source Link

Surprising behavior of Part[ ]

Look at this list

list={1,2,3,4}

Obiously

list[[1, 2]]

throws the error:

During evaluation of Part::partd: Part specification {1,2,3,4}[[1,2]] is longer than depth of object.

However:

list[[1,All]]

yields (Mathematica 12 on Windows)

Integer[]

which does not make much sense to me. Moreover, weird constructs like list[[All,All,All,All,All]] do not throw an error.

Can this (at least to me) strange behaviour of the basic command Part[] be explained? (Needless to say, that this is just a simple demonstration of the effect, but it occured during execution a larger program with strange consequences.)