Mathematica:摆脱“x ->”在 FindInstance 结果中
假设我有以下结果:
a=FindInstance[2*b^2 + b^3 == b^4 + t && t < 10 && t > -1, {b, t},
Integers, 20]
{{b -> -1, t -> 0}, {b -> 0, t -> 0}, {b -> 1, t -> 2}, {b -> 2,
t -> 0}}
如何去掉“b->”然后就得到 b 答案的数组?我可以做到一半:
a[[All,1]]
{b -> -1, b -> 0, b -> 1, b -> 2}
但我怎样才能做到:
{-1, 0, 1, 2}
谢谢
Suppose I have the following results:
a=FindInstance[2*b^2 + b^3 == b^4 + t && t < 10 && t > -1, {b, t},
Integers, 20]
{{b -> -1, t -> 0}, {b -> 0, t -> 0}, {b -> 1, t -> 2}, {b -> 2,
t -> 0}}
How can I get rid of the "b->" and just get the array of b answers? I can get halfway there with:
a[[All,1]]
{b -> -1, b -> 0, b -> 1, b -> 2}
but how can I get to just:
{-1, 0, 1, 2}
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我可能会从 dreeves 的答案中遗漏一些东西,但我一直相信你这样做的方式只是通过写作:
Solve
函数的文档,它使用相同的输出样式。I might be missing something from dreeves' answer, but the way I always believed you do this was simply by writing:
There is an example of this in the "Basic Examples" section of the documentation for the
Solve
function, which uses the same output style.尽管威尔的答案是规范的方法,但我将提供一些替代方案只是为了好玩。
Though Will's answer is the canonical way to do it, I'll provide a few alternatives just for fun.