Skip to Main Content
Mathematica 錦囊妙計
book

Mathematica 錦囊妙計

by Sal Mangano
April 2014
Beginner to intermediate content levelBeginner to intermediate
830 pages
15h 21m
Chinese
GoTop Information, Inc.
Content preview from Mathematica 錦囊妙計
148
|
第四章
Rules(規則式)
規則式把模式匹配的功能帶到了新的層次,它用來對匹配表示式進行轉換,規則式整
Mathematica 心, 解( 11.6)、
Options
使 用( 2.17
SparseArrays
義( 3.8),
Rules
Mathematica 的符號功能的基礎。每位 Mathematica 使用者都不應忽略。[Page-150]
將符合模式的位元串列轉換為整數,使用 RuleDelayed 指令是因為 b 在匹配之前並沒有定義
Pi 數值取代每個 x
想了解
->
:>
的差異有個不錯的方式,參考下以的亂數取代規則式。
的方式在匹配時會馬上計算,因此取代結果均為相同數值
:→
的方式會在每次達成匹配時均重新計算
延伸資訊
Mathematica 教學文件
tutorial/PatternsAndTransformationRules
提供了絕佳的學習資源,
詳加閱讀將可顯著加強 Mathematica 程式功力。
4.1 取出匹配(或不匹配)模式的元素
問題點
你想取出串列或表示式中匹配模式的項目,找出這些項目同時也希望對其進行轉換。
ch04.indd 148 2014/4/2 上午 05:39:00
4.1 取出匹配(或不匹配)模式的元素
|
149
解決方案
使用
Cases
取出串列或表示式中匹配模式的項目。[Page-151]
使用規則式
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Ubuntu for Non-Geeks, 4th Edition

Ubuntu for Non-Geeks, 4th Edition

Rickford Grant, Phil Bull

Publisher Resources

ISBN: 9789863470106