Skip to Content
Mathematica 錦囊妙計
book

Mathematica 錦囊妙計

by Sal Mangano
April 2014
Beginner to intermediate
830 pages
15h 21m
Chinese
GoTop Information, Inc.
Content preview from Mathematica 錦囊妙計
130
|
第三章
一般 Mathematica 程式設計師都會不假思索地以這個顯而易見的方式實作。然而這個
方 法 是 靜 態 的(static), 但 大 多 數 關 聯 式 資 料 結 構 需 為 動 態 的(dynamic), 當 然 對
Mathematica 而言這也不是問題,因為你可以隨時刪除 downvalue。
11779 的關聯數值便消失了,此時 Mathematica 會回傳原表示式。
但這還 不夠,關聯 式資料 結構必 須能取出 所有鍵 值及對 應數值。當 然, 這也難 不倒
Mathematica。[Page-131]
因此,所有的必備特性都可以使用 Mathematica 內建核心實作關聯式資料結構。剩下的
僅是將這些功能集中並定義統一使用方式。
討論說明
首先我們需要關聯數組的建構指令。如前文所提及的,我們以符號來解決此問題,至於
實作上符號的名稱並不重要,重要的是它必須是 Mathematica 內獨一無二的符號;很幸
運的,Mathematica 提供了
Unique
指令可建立獨特的符號;以此符號的 downvalue 建立
關聯數組,其起始狀態對所有鍵值均輸出空串列。此符號將被包裝在
Dictionary
標頭內
作為回傳值。
我們也需要一個方式刪除關聯數組及其所有內容,
Remove
指令可以達到這一點。
ch03.indd 130 2014/4/2 上午 05:19:25
3.13 善用 Mathematica 內建關聯查表功能
|
131
雖然前文提及其實沒有必要知道內部符號
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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Mathematica Cookbook

Mathematica Cookbook

Sal Mangano
人工智能技术与大数据

人工智能技术与大数据

Posts & Telecom Press, Anand Deshpande, Manish Kumar

Publisher Resources

ISBN: 9789863470106