Skip to Content
深入理解運算原理|從簡單的機器到無所不能的程式
book

深入理解運算原理|從簡單的機器到無所不能的程式

by Tom Stuart
November 2017
Beginner to intermediate
344 pages
7h 2m
Chinese
GoTop Information, Inc.
Content preview from 深入理解運算原理|從簡單的機器到無所不能的程式
Toyland 程式設計
|
307
=> [
#<Sign positive>, #<Sign positive>, #<Sign positive>,
#<Sign positive>, #<Sign zero>, #<Sign positive>,
#<Sign positive>, #<Sign positive>, #<Sign positive>
]
>> outputs.uniq
=> [#<Sign positive>, #<Sign zero>]
沒有完成任何精巧的分析,這告訴我們,
#sum_of_squares
只會產生零或正數,絕不會產
生負數(這對受過教育的程式碼閱讀者顯然是個相當乏味的屬性),但這些不是機器可
以立即看出來。當然,這種技巧只能用在非常簡單的程式碼,但儘管是個玩具,它也證
明了抽象體可以讓困難的問題變得更容易駕馭。
靜態語意
截至目前,我們已經看到如何不需實際執行它們就能找出運算近似資訊的玩具範例。雖
然完成那些實際的運算可以讓我們學到更多,但是近似資訊比沒有更好,而且對某些應
用(例如路線規劃)來說,它可能全都是我們真正需要。
在乘法和加法的範例裡,我們只需將抽象值(而非具體數值)當作輸入傳給它,就能夠
將小程式轉換成更簡單、更為抽象的版本,但如果我們想鑽研更大更精細的程式,截至
目前我們就只能使用這種技術。如果想要建立能提供它們自己乘法和加法實作物的值,
是件很容易的事,但 Ruby 不允許值以更為普遍的方式控制它們自己的行為(例如在
if
陳述式使用它們), 因為它語法的特定部分應如何運作的規則已經寫死 ...
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

JSON實務手冊

JSON實務手冊

Tom Marrs

Publisher Resources

ISBN: 9789864766000