1

InputForm[{a, b, c, d, e, f}]{a, b, c, d, e, f}

InputForm[Characters["SOMETHING"]]{"S", "O", "M", "E", "T", "H", "I", "N", "G"}

但是为什么不Drop[InputForm[Characters["SOMETHING"]],1]{"O", "M", "E", "T", "H", "I", "N", "G"}

但给出一个 InputForm[] 而没有别的?

我怎样才能做到这一点?

谢谢你

4

1 回答 1

4

当你评估

InputForm[Characters["SOMETHING"]]

Mathematica 内部产生结果

InputForm[List["S","O","M","E","T","H","I","N","G"]]

即,它是一个带有InputForm作为头部的表达式,它包含ListList["S","O","M","E","T","H","I","N","G"]作为它的第一个子表达式。当 Mathematica 显示表达式时,您看不到InputForm头部,因为前端仅使用它作为表达式应该如何显示的提示,但它仍然存在于幕后。

然后,当您使用 时Drop[..., 1],它会查看给定的表达式,挑选出第一个子表达式,即List["S","O","M","E","T","H","I","N","G"],然后丢弃它。就这样离开了InputForm[]

打个比方:如果你评估

Drop[List[List["S","O","M","E","T","H","I","N","G"]], 1]

你会明白为什么你会得到一个空列表,对吧?这是同样的事情。

于 2012-11-24T21:47:48.197 回答