diff --git a/Course Notes/Translation/Traditional Chinese/BeforeYouStartThisCourse-zh_TW.pdf b/Course Notes/Translation/Traditional Chinese/BeforeYouStartThisCourse-zh_TW.pdf new file mode 100644 index 0000000..5527903 Binary files /dev/null and b/Course Notes/Translation/Traditional Chinese/BeforeYouStartThisCourse-zh_TW.pdf differ diff --git a/Course Notes/Translation/Traditional Chinese/BeforeYouStartThisCourse-zh_TW.tex b/Course Notes/Translation/Traditional Chinese/BeforeYouStartThisCourse-zh_TW.tex new file mode 100644 index 0000000..1f7c402 --- /dev/null +++ b/Course Notes/Translation/Traditional Chinese/BeforeYouStartThisCourse-zh_TW.tex @@ -0,0 +1,168 @@ +\documentclass[]{article} + +\usepackage{amsmath} +\usepackage{amsfonts} +\usepackage{amssymb} +\usepackage{xcolor} +\usepackage{url} +\usepackage{graphicx} +\usepackage{geometry} +\usepackage[most]{tcolorbox} + +% {Begin zh_TW} +% Credit: XeLaTex 中文 · GitHub +% https://gist.github.com/iamalbert/1b87a5349f7e860bfe33 +\usepackage{fontspec} % 加這個就可以設定字體 +\usepackage{xeCJK} % 讓中英文字體分開設置 +\setCJKmainfont{微軟正黑體} % 設定中文為系統上的字型,而英文不去更動,使用原 TeX 字型 +\XeTeXlinebreaklocale "zh" % 這兩行一定要加,中文才能自動換行 +\XeTeXlinebreakskip = 0pt plus 1pt % 這兩行一定要加,中文才能自動換行 + +\defaultCJKfontfeatures{AutoFakeBold=6,AutoFakeSlant=.4} %以後不用再設定粗斜 +% {End zh_TW} + +\setlength{\parindent}{0em} +\setlength{\parskip}{3ex} +\geometry{left=3cm, top = 3cm, right = 3cm, bottom = 3cm} + +\newcommand{\ignore}[1]{} +\newcommand{\codequote}[1]{\colorbox{lightgray}{\tt #1}} + +\begin{document} + +\author{} \date{} +\title{第 0 課:開始本課程之前} +\maketitle + +\vspace{-4em} +----------------- + +\section*{目標} + +\begin{description} + \item[---] 說明本課程的方法、大綱和目標聽眾 + \item[---] 詳述完成本課程所需的基本電腦能力 + \item[---] 提供一些關於如何完成這門課程的建議(應該對那些想嘗試的人有所幫助) +\end{description} + +學完本課,你將能夠 +\begin{description} + \item[*] 決定是否開始學習這門課程 + \item[*] 確保你擁有所需的基本能力 +\end{description} + +\section*{目標聽眾和教學理念} + +本課是針對沒有任何程式設計經驗的人。它還旨在合宜於那些不確定程式設計是否適合他們的人:他們可能對電腦感到有點害怕,或者他們可能已在第一門程式設計課程中失去了信心。 + +我們的理念可以概括為以下口號:\emph{小步走,不留空隙,一切都有意義}。我們相信程式設計就像學習一門新語言一樣容易---對某些人來說很難,對所有人來說都應是可行的\footnote{也就是說,除了極少數嚴重殘疾的。}。這需要一些努力和堅持,僅此而已。當然,有些人會比其他人做得更快。那又如何? + +讓我們稍微解說一下口號,這也讓我們有機會說明清楚這門課程的限制。 + +\begin{description} + \item[\emph{小步走}] 初學者當然要小步走!對於那些已經知道如何程式設計的人來說,這可能會有點無聊,但本課程並不是針對他們的。對於那些對 Julia 語言的最佳和最不尋常的特性感興趣的人來說,這可能有點令人沮喪,但本課程也不適合他們! + \item[\emph{不留空隙}] 在許多課程中(不僅是在程式設計方面),學習者需要自己填補空白。而你自己,在成長過程中,做了很多填空,比如學習說話。課程中的空隙本身並不是一件壞事,但它們會妨礙對自己有點不確定的學習者。對於學習電腦語言尤其如此,因為電腦語言有如此嚴格的規則。我們對這個問題的解決方案有兩個部分:(1)我們用一整節課(即第 1 週的第 4 課)來解釋為什麼規則如此僵化,以及(2)我們努力確保我們解釋了與一個特定議題有關的所有內容。 + \item[\emph{一切都有意義}] 這一點的重要性不言而喻。但遺憾的是,我們無法完全確定我們最終實現了這一目標---請讓我們知道我們做得如何及不足的地方! +\end{description} + +一門不留空隙的短期課程不可能涵蓋像 Julia 這樣的整個語言。我們沒有提及讓 Julia 對專業人士如此有吸引力的一些事情,比如自我修改程式以及如何確保超快計算速度;我們不會探索你第一次啟動 Julia 時的 Julia 基礎之外擴展出的許多套件包的豐富功能\footnote{甚至沒有繪製簡單的圖!}。 + +而且,由於本課程針對的是大多數程式設計課程忽略的初學者,因此我們不強調數值範例。相反,我們專注於文字\footnote{並非所有文字!我們幾乎所有的例子都是英文的,其餘的都接近英文和羅馬字母。}。事實證明,我們可以使用文字來舉例說明 Julia 的幾乎所有基本元素。 + +非常重要的是,我們的方法意味著當我們討論一個主題時,例如字串或函數,我們的目標是對主題的\emph{一部分}進行完整的討論(沒有空隙,一切都有意義)。\footnote{無論如何,用戶很容易擴展 Julia,因此無法在有限的課程中涵蓋整個主題。}。這也意味著我們比初學者課程中的常規課程更全面地涵蓋了某些主題(例如,類型和範圍),因為我們需要它們來進行完整的解釋。請放心,我們只使用我們需要的量,不會更多,並且也許除了一個例外,這些主題本身並不困難。 + +不,程式設計並不難,但由於形式邏輯的主導作用,它可能會讓人感到奇怪。是沒有辦法解決這個問題的,你唯一能做的就是習慣它。你可能永遠不會停止感覺奇怪,但如果你知道它從何而來,你可以做的不僅僅是習慣它---你可以學會有效地使用它! + +\section*{完成本課程所需的電腦能力} + +你只需要三個項目: + +\begin{description} + \item[---] 建立文件夾和子文件夾(也稱為目錄和子目錄)並在它們之間移動的能力 + \item[---] 編寫和儲存純文字檔案的能力 + \item[---] 啟動 Julia REPL 的能力 +\end{description} + +其中,第一個是最有可能造成問題的,所以我們從那裡開始。 + +\subsection*{文件夾、子文件夾和在目錄結構中移動} + +為此,你可以使用檔案總管。Apple iOS、Microsoft Windows 和各種風格的 Linux 是人們使用的主要系統,它們的檔案總管彼此有很大不同。 +幸運的是,大多數檔案總管都包含類似瀏覽器的查看方式,因此我們從它們的共同功能開始本課程。在我的筆記型電腦上,新用戶的最上層文件夾(也稱為用戶的主目錄)可能如下所示: + +\includegraphics[scale = 0.25]{linuxthunar1.png} \hspace{1em} + +花點時間確定你的最上層目錄。對於初學者來說,正確地做到這一點很重要。在 Windows 系統上,你應該使用檔案總管 \footnote{不要與 IE 瀏覽器混淆,後者是瀏覽器,與 Firefox、Chrome 和 Safari 執行相同的工作,你可能也知道並使用過。它們用於上網---也就是說,它們讓你可以存取遠端系統上的內容。檔案總管用於在本地 Windows 系統上儲存、查找和移動內容。要確保你知道這兩者之間的區別!},並且在 iOS(即 Apple 設備)上你應該使用 Finder。 + +再花點時間將你的最上層目錄與上圖進行比較。你可能是一個全螢幕,你可能是一個名稱列表而不是圖標,你可能沒有像左側那樣的面板。確保你可以找到當前目錄的名稱。在我的系統上,用戶的最上層目錄與該用戶具有相同的名稱。所以它是上圖中的``typicaluser''。 + +\newpage 現在看下圖,它顯示了 typicaluser 的圖片文件夾\footnote{也就是,圖片子目錄}的內容。 + +\includegraphics[scale = 0.25]{linuxthunar2.png} + +現在文件夾的名稱只出現在一處。還要注意,在我的系統上,它給出的名稱不僅僅是``Pictures'',而是``/home/typicaluser/Pictures''。這被稱為提供完整路徑,它表示顯示的文件和/或子目錄包含在名為 Pictures 的文件夾中,該文件夾位於名為 typicaluser 的文件夾中,該文件夾位於名為 home 的文件夾中。 + +最後,如果這對你來說是全新的,請把玩\footnote{對大多數人來說最簡單的是使用滑鼠,但還有其他方法。但是,無論是單擊還是雙擊,是否可以拖放,是否可以使用多個按鈕等等,都取決於你的系統。}你的主目錄中的文件和文件夾。確保你可以從這個目錄移到另一個目錄,然後再返回。新增一個你自己輸入名稱的子文件夾,移到它(我也可以說``導航到它''),在這個新文件夾中建立一個文件檔案,重命名文件檔案,刪除文件檔案,移回到你的用戶目錄,並刪除你的新文件夾。 + +現在移動到一個完全不同的文件夾,如果可能的話不在你的個人用戶目錄中。確保你可以找到文件夾的名稱並且你可以移回你的個人用戶目錄。 + +這是本課程的一個非常重要的時刻:當你啟動電腦時,預設情況下,你們中的大多數人都會是在你的個人用戶目錄中,這使得上面的練習相對容易,但這還不夠。你需要能夠確定你在目錄結構中的位置、你正在查看的文件夾的確切名稱以及如何移動到結構的其他部分。為此,你通常可以像在此處一樣使用文件夾管理系統,但有時你必須用到你對所需文件夾路徑的了解。 + +最後,現在或之後,建立一個專用於本課程的文件夾。在其中,你將儲存從課程網站下載的所有內容、你為課程編寫的所有代碼以及你可能希望新增的其他內容。我建議你透過建立一些子文件夾來組織一下,可能一個稱為 CourseMaterials 用於你的下載,另一個可能稱為 MyCodeAnswers 用於你為解答我們設置的任務而編寫的 Julia 代碼。 + +恭喜!你已經完成了為本課程設置你的系統的最重要和最棘手的部分。 + +\subsection*{寫入和儲存素文字(plain text)檔案} + +(也稱為``純文字(text-only)檔案"。譯註:以下 plain text 統一譯為純文字。) + +無疑的,你熟悉電腦上的文件準備系統。畢竟,編寫文件是個人電腦最常見的用途之一。這些系統可以在本課程中使用,但不是很好用。使用 MS-Word 或 Pages 之類的東西,電腦付出很多努力讓你輕鬆編寫具有專業外觀的文件。這意味著他們在後台做一些事情,比如設置段落縮排和分段、選擇漂亮的字體、設置可調整的邊界和表格等等。你會看到結果,但不會看到它是如何完成的。但是,儘管你沒有看到,但資訊必須在文件中,因此典型的 .docx 和 .pdf 等文件包含許多讀者甚至編寫文件的人都看不到的資訊。在某些系統中,你可以要求查看一些額外的內容(例如,在 MS-Word 中,你可以要求查看非打印字符)。 + +所有這些額外的資訊對 Julia 程式來說都是致命的。你將在本課程中看到 Julia 只能處理包含有效 Julia 代碼的程式,僅此而已。因此,文件系統以 .doc、.pdf 和其他專用格式放置的所有格式和其他資訊對 Julia 來說就像毒藥。你必須堅持這些額外資訊均不在你儲存且將運行的檔案中。也就是說,你編寫的檔案必須是純文字檔案。 + +我發現使用像 Mousepad 或 Notepad+ 這樣的程式最容易,它專門用於建立純文字檔案,僅此而已。假如以這種方式使用 MS-Word 或 LibreOffice 可能很困難。這些系統確實可以建立純文字檔案,但標準的方法是在第一次儲存文件時選擇 .txt 副檔名。由於 Julia 程序使用 .jl 副檔名,這種方法通常意味著你首先使用 .txt 副檔名儲存它,然後轉到你的文件夾管理系統並重命名它。 + +作為練習,轉到本課程的文件夾並建立一個純文字檔案。在其中寫一條短訊息,只使用純文字(即標準國際鍵盤上的羅馬字母,沒有重音、符號、中文或漢字)。使用標準的 .txt 副檔名儲存此檔案。現在修改檔案,仍然只使用標準的羅馬字母,並使用不同的副檔名儲存它。使用不同的程式查看文件以確保它只包含你使用的字母、空格和標點符號,不多也不少(例如,在 MS-Word 中,以可見的非打印字符查看它)。最後,如果你有一個允許你這樣做的編輯器,則直接使用與 .txt 不同的副檔名建立一個純文字檔案。 + +\subsection*{啟動 Julia REPL} + +當然,我們假設你的電腦上安裝了 Julia\footnote{可以線上運行 Julia,最顯易的是透過登錄 juliabox.com 在 JuliaBox 上運行,但在這種情況下,你無法按照所寫的方式完成課程。你當然可以查看課程材料,但是你需要的 Julia 練習將不會按照我們的計劃進行。在 JuliaBox 上,你沒有 REPL,而是專門的 IJulia 環境。這與 REPL 有細微差異但在重要的方面有所不同。如果你更喜歡在沒有安裝 Julia 的情況下使用它,並且你不介意我們提到的差異,請隨時繼續。}。所以啟動它---確切地如何啟動一個程式取決於你的系統,可能是一個單擊或雙擊圖標,或者是在一個特殊的視窗輸入``julia''並按 Enter 。如果一切順利,你會看到一個新視窗打開,看起來像這樣: + +\includegraphics[scale=0.25]{REPL.png} + +這是 Julia REPL。請注意,它以 Julia 正在運行的訊息和版本開頭,以及有關官方文件和幫助系統中更多資訊的一些提示。然後,在新的一行上顯示文字 {\tt julia$ > $}。這是 Julia 提示,如果你在此視窗中輸入(你可能必須先單擊它),你應該會看到你輸入的內容出現在提示的右側。你將在本課程中進行大量此類輸入。完成輸入後,你通常會按 Enter,並且(也許一段時間後,可能會在你的電腦上發生一些可見到或可聽到的事情),你將再次看到 {\tt julia$ > $},等待你輸入更多 Julia 代碼。 + +要結束你的 REPL 會話,只需按 Ctrl-D(即按住鍵盤上的 Ctrl 按鈕並按 D 鍵,不必將其設為大寫字母,但也沒有任何區別)。或者,鍵入 \codequote{exit()} 並按 Enter。 + +\section*{關於如何完成本課程的簡要建議} + +正如我們在第 1 週的第 4 課中所堅持的那樣,Julia 是一種語言:學習語言的試驗是用它來表達自己。以程式設計為例,當你表達自己並運行你的程式時,電腦最終會做一些事情:它建立和顯示文字、繪製圖形、計算數字、在紙上列印東西、播放聲音等。 + +如果不練習表達自己,你就無法學會表達自己。所以主要的建議是:編寫大量的 Julia 表達式,看看當你嘗試運行生成的代碼時會發生什麼。如果你收到錯誤訊息,請不要擔心。相反的,請利用錯誤訊息(這包括忽略那些不重要的訊息)。 + +當然,跟著課程。但要能中斷,在 REPL 和 {\tt .jl} 檔案中嘗試一下。回顧你不確定的事情。關鍵是要保持活躍,而不是僅僅跟隨教材而陷入困境。 + +練習和評估也很重要,因為它們可以幫助你了解你已經走了多遠以及你是否準備好繼續。他們給你反饋---但最重要的反饋來源仍然是 REPL 本身。Julia 語言本身會教你如何使用它---你所要做的就是繼續和它對話。在這方面,它與學習任何其他語言沒有太大區別。 + +\section*{課程內容} +這裡是課程內容的總結(濃縮的,僅粗略按出現順序) + +--- 字串文字\\ +--- 名稱(包括保留字)\\ +--- 變數 \\ +--- 函數 \\ +--- 從 REPL 運行 Julia 代碼檔案 \\ +--- 除錯 \\ +--- 每種電腦語言的規則都是嚴格的,因為每種電腦語言都是透過形式邏輯構建的,但是 \\ +--- 一個人不需要知道形式邏輯來學習如何撰寫程式 \\ +--- 表達式(它們由值、名稱、分隔符號和運算子組成;Julia 代碼的每一部分都必須是有效的表達式)\\ +--- 字串運算子、比較運算子、邏輯運算子 \\ +--- 資料容器(字串和一維陣列)\\ +--- 算術 \\ +--- 類型系統和多重派遣 \\ +--- 範圍 \\ +--- 結構(特別是由關鍵字 \codequote{if}、\codequote{while} 和 \codequote{for} 引入的結構)\\ + +這為你將 Julia 用於非常有趣的專案奠定了基礎,正如我們在第 4 週的課程中所展示的那樣。當然,它仍遺漏了 Julia 語言的許多特別之處。在本課程的最後一課中,我們將簡要討論 Julia 的內容比本課程涵蓋的內容多出多少。我們還為你提供了繼續程式設計冒險的方法---我們希望是在 Julia,但不堅持是它! + +\end{document} diff --git a/Course Notes/Translation/Traditional Chinese/README.md b/Course Notes/Translation/Traditional Chinese/README.md new file mode 100644 index 0000000..35c4adb --- /dev/null +++ b/Course Notes/Translation/Traditional Chinese/README.md @@ -0,0 +1,2 @@ +# 課程筆記 +## (為了 Julia Programming for Nervous Beginners/緊張初學者的 Julia 程式設計) diff --git a/Course Notes/Translation/Traditional Chinese/REPL.png b/Course Notes/Translation/Traditional Chinese/REPL.png new file mode 100644 index 0000000..1a6dd0e Binary files /dev/null and b/Course Notes/Translation/Traditional Chinese/REPL.png differ diff --git a/Course Notes/Translation/Traditional Chinese/Week 1/L1W1_MinimalWorkingExample-zh_TW.pdf b/Course Notes/Translation/Traditional Chinese/Week 1/L1W1_MinimalWorkingExample-zh_TW.pdf new file mode 100644 index 0000000..c5f339a Binary files /dev/null and b/Course Notes/Translation/Traditional Chinese/Week 1/L1W1_MinimalWorkingExample-zh_TW.pdf differ diff --git a/Course Notes/Translation/Traditional Chinese/Week 1/L1W1_MinimalWorkingExample-zh_TW.tex b/Course Notes/Translation/Traditional Chinese/Week 1/L1W1_MinimalWorkingExample-zh_TW.tex new file mode 100644 index 0000000..e6a042b --- /dev/null +++ b/Course Notes/Translation/Traditional Chinese/Week 1/L1W1_MinimalWorkingExample-zh_TW.tex @@ -0,0 +1,117 @@ +\documentclass[]{article} + +\usepackage{amsmath} +\usepackage{amsfonts} +\usepackage{amssymb} +\usepackage{xcolor} +\usepackage{url} +\usepackage{graphicx} +\usepackage{geometry} +\usepackage[most]{tcolorbox} + +% {Begin zh_TW} +% Credit: XeLaTex 中文 · GitHub +% https://gist.github.com/iamalbert/1b87a5349f7e860bfe33 +\usepackage{fontspec} % 加這個就可以設定字體 +\usepackage{xeCJK} % 讓中英文字體分開設置 +\setCJKmainfont{微軟正黑體} % 設定中文為系統上的字型,而英文不去更動,使用原 TeX 字型 +\XeTeXlinebreaklocale "zh" % 這兩行一定要加,中文才能自動換行 +\XeTeXlinebreakskip = 0pt plus 1pt % 這兩行一定要加,中文才能自動換行 + +\defaultCJKfontfeatures{AutoFakeBold=6,AutoFakeSlant=.4} %以後不用再設定粗斜 +% {End zh_TW} + +\setlength{\parindent}{0em} +\setlength{\parskip}{3ex} +\geometry{left=3cm, top = 3cm, right = 3cm, bottom = 3cm} + +\newcommand{\ignore}[1]{} +\newcommand{\codequote}[1]{\colorbox{lightgray}{\tt #1}} + +\begin{document} + +\author{} \date{} +\title{第 1 週,第 1 課:一個最小的工作範例} +\maketitle + +\vspace*{-2cm} +----------------- + +\section*{目標} +\begin{description} + \item[*] 提供一個例子以開始談論 Julia +\end{description} + +----------------- + +在我們的第一課中,我們廣泛借用了第 0 課---關於你必須準備好來參加本課程的內容\footnote{啟動 Julia 並進入 REPL;編輯純文字檔案並將它們儲存在本課程的專用文件夾中。}。 + +我還想提醒你課程口號:{\bf 小步走,沒有空隙,永遠有意義}。目的是讓緊張的初學者保持參與! + +這節課我們從零開始,所以我們不能完全遵守口號的所有部分。這個想法是首先在本課中看到編碼的實際操作,然後在第 2 課中詳細解釋。 + +\section*{輸入 REPL 代碼} + +\begin{minipage}{7cm} +打開 REPL,輸入 \colorbox{lightgray}{\tt "Hello, world"}。 +\end{minipage} +\hspace{4em}\begin{minipage}{7cm} + 示範:在本課的影片中,我們精確地向你展示如何做到這一點。 + \end{minipage} + +\colorbox{lightgray}{\tt "Hello, world"} 是一個字串值。Julia 有許多其他類型的值:我們將看到其中的一些,例如數字值和字符值\footnote{即,作為字符的值。}。 + +\begin{minipage}{7cm} +現在輸入 \colorbox{lightgray}{\tt mystringexample1 = "Hello, world"}。 +\end{minipage} +\hspace{4em} \begin{minipage}{7cm} +這稱為\emph{指派值到變數}。 +\end{minipage} + +重要:\colorbox{lightgray}{\tt =} 符號將右側的字串值綁定到左側的變數名稱。這在三個地方更改了你的電腦的記憶體: +\begin{description} + \item[$\bullet$] 名稱 \colorbox{lightgray}{\tt mystringexample1} 被放入所謂的命名空間\footnote{實際上,當 Julia 運行時,它可以有多個命名空間,但這是我們在本課程中會不涉及的進階主題。一旦名稱位於命名空間中,它就會一直存在,直到你關閉整個命名空間。關閉 Julia 會話也會關閉所有命名空間。}。 + \item[$\bullet$] 字串值 \colorbox{lightgray}{\tt "Hello, world"} 被建立\footnote{ 與上面的分開但方式相同。}。 + \item[$\bullet$] 左側名稱和右側值之間的 \colorbox{lightgray}{\tt =} 符號建立了名稱和值之間的綁定。 + \item[$\bullet$] 透過將字串值綁定到名稱,Julia 將字串值儲存在你的電腦記憶體中,以便以後需要時可以使用該值。 +\end{description} + +\begin{minipage}{7cm} +輸入 \colorbox{lightgray}{\tt println(mystringexample1)} 。 +\end{minipage} +\hspace{4em} \begin{minipage}{7cm} + 示範:\codequote{println} 是內建函數 +\end{minipage} + +當這一行運行時會發生什麼\footnote{人們也說:``當這一行被執行時'',以及``當這一行被評估時''。}:\\ +函數 \colorbox{lightgray}{\tt println()} 接收變數名稱 \colorbox{lightgray}{\tt mystringexample1},獲取它的值(它是一個字串),重新格式化它,然後在螢幕上顯示字串並接上空行。 + +函數在 Julia 中非常非常重要。許多是內建的,例如 \colorbox{lightgray}{\tt println()},但 Julia 程式還建立了更多。在本課程中,你將學到很多關於 Julia 函數的知識! + +\section*{建立和運行代碼檔案} + +\begin{minipage}[t]{10.5cm} + 最後,建立{\tt myfirstfile.jl},作為純文字檔案(NB!),確切地包含我們上面使用的兩行代碼,將其儲存在你的課程文件夾\footnote{即建立一個 Julia 代碼檔案---此類檔案是第 0 課的主題之一。}。確保你的課程文件夾是你的工作目錄\footnote{使用 \colorbox{lightgray}{\tt pwd()} 來檢查你的工作目錄是什麼,並使用 \colorbox{lightgray}{\tt cd()} 來更改它。},然後輸入 \colorbox{lightgray}{\tt include("myfirstfile.jl")} + \end{minipage} +\hspace{4em} \begin{minipage}[t]{4.5cm} +示範:在影片中,我們展示了結果與我們之前使用的 REPL 代碼相同。 +\end{minipage} + +恭喜!你的第一個 Julia 程式!編碼就是這麼簡單。 + +\section*{回顧與總結} + +\begin{description} + \item[*] \colorbox{lightgray}{\tt "Hello, world"} 是一個字串值。 + \item[*] \colorbox{lightgray}{\tt println()} 是一個函數。 + \item[*] \colorbox{lightgray}{\tt mystringexample1} 是一個變數名稱。 + \item[*] \colorbox{lightgray}{\tt =} 是指派:右側的值綁定到左側的名稱。 + \item[*] 函數 \colorbox{lightgray}{\tt include()} 運行它從 Julia 代碼檔案接收的代碼行。 + \item[*] Julia 代碼檔案是副檔名為 {\tt .jl} 的純文字檔案 +\end{description} + +我們在本課中所做的,隨著課程的進行我們將一遍遍地做:一些新想法、一些範例(你可以隨著課程進行嘗試)以及一些供你編寫和執行的代碼檔案。 + +請在第 1 週第 2 課之前做測驗、練習和自評作業。他們很短!在繼續之前最好先做這些。 + +\end{document} diff --git a/Course Notes/Translation/Traditional Chinese/Week 1/L2W1_DeconstructingTheMinimalExample-zh_TW.pdf b/Course Notes/Translation/Traditional Chinese/Week 1/L2W1_DeconstructingTheMinimalExample-zh_TW.pdf new file mode 100644 index 0000000..4f006b1 Binary files /dev/null and b/Course Notes/Translation/Traditional Chinese/Week 1/L2W1_DeconstructingTheMinimalExample-zh_TW.pdf differ diff --git a/Course Notes/Translation/Traditional Chinese/Week 1/L2W1_DeconstructingTheMinimalExample-zh_TW.tex b/Course Notes/Translation/Traditional Chinese/Week 1/L2W1_DeconstructingTheMinimalExample-zh_TW.tex new file mode 100644 index 0000000..8220e05 --- /dev/null +++ b/Course Notes/Translation/Traditional Chinese/Week 1/L2W1_DeconstructingTheMinimalExample-zh_TW.tex @@ -0,0 +1,208 @@ +\documentclass[]{article} + +\usepackage{amsmath} +\usepackage{amsfonts} +\usepackage{amssymb} +\usepackage{xcolor} +\usepackage{url} +\usepackage{graphicx} +\usepackage{geometry} +\usepackage[most]{tcolorbox} + +% {Begin zh_TW} +% Credit: XeLaTex 中文 · GitHub +% https://gist.github.com/iamalbert/1b87a5349f7e860bfe33 +\usepackage{fontspec} % 加這個就可以設定字體 +\usepackage{xeCJK} % 讓中英文字體分開設置 +\setCJKmainfont{微軟正黑體} % 設定中文為系統上的字型,而英文不去更動,使用原 TeX 字型 +\XeTeXlinebreaklocale "zh" % 這兩行一定要加,中文才能自動換行 +\XeTeXlinebreakskip = 0pt plus 1pt % 這兩行一定要加,中文才能自動換行 +\defaultCJKfontfeatures{AutoFakeBold=6,AutoFakeSlant=.4} %以後不用再設定粗斜 +% {End zh_TW} + +\setlength{\parindent}{0em} +\setlength{\parskip}{3ex} +\geometry{left=3cm, top = 3cm, right = 3cm, bottom = 3cm} + +\newcommand{\ignore}[1]{} + +\begin{document} + +\author{} \date{} +\title{第 1 週,第 2 課:解構第 1 課} +\maketitle + +\vspace*{-2cm} +----------------- + +\section*{目標} + +--- 解構第 1 課中的代碼 \\ +--- 提供有關 Julia 中表示式的細節 \\ +--- 傳達有效代碼的重要性 \\ +--- 開始仔細學習 Julia 語言的過程 + +學完本課,您將能夠 \vspace{-3ex} \begin{description} + \item[*] 舉幾個 Julia 中有效表示式的例子 + \item[*] 根據名稱和值解釋變數的結構 + \item[*] 準確解釋 Julia 中的字串值是什麼 + \item[*] 廣義地解釋什麼是函數,以及 Julia 如何識別函數 + \item[*] 解釋運算子與其他類型函數的區別 + \item[*] 舉例說明一些 Julia 分隔符號及其用法 +\end{description} + +\section*{複習:第1課的代碼} + +在第 1 課中,您在 REPL 中運行了以下代碼 + +\colorbox{lightgray}{\tt mystringexample1 = "Hello, world"} \hspace{3cm} \ldots\ 行 1\\ +\colorbox{lightgray}{\tt println(mystringexample1) } \hspace{4.3cm} \ldots\ 行 2 + +您還建立了一個檔案,我們將其稱為 {\tt myfile.jl},儘管您可能使用了不同的名稱\footnote{在本課中,每當我們提到 {\tt myfile.jl},請注意我們指的是您建立的文件,並在您的腦海中(以及在代碼範例中)將其替換為您自己的檔案名。}。 + +\colorbox{lightgray}{\tt include("myfile.jl")} \hspace{5.5cm} \ldots\ 行 3 + +\section*{解構第 1 行,它建立了一個變數} + + + +如何閱讀第 1 行:它有一個左手邊,一個右手邊,用等號連接它們。 + +右側是一個字串值(更多內容見下文):\colorbox{lightgray}{\tt "Hello, world"}。 + +左側是變數的名稱:\colorbox{lightgray}{\tt mystringexample1}。 + +\colorbox{lightgray}{\tt =} 符號將變數名稱綁定到給定的值。 + +這實際上改變了電腦中的一些記憶體。就技術上來說,等號是一種特殊的函數,即運算子,它的全稱是``指派運算子''\footnote{所有電腦語言都至少有一個指派運算子。它們在影響電腦記憶體的細節方面有所不同,但在本課程中,我們先遠離這些細節。你需要知道的是,在 Julia 中,指派運算子將其右側的值綁定到其左側的變數名稱。}。 + +我們說第 1 行\emph{建立}了變數,因為在第 1 行之前 \colorbox{lightgray}{\tt mystringexample1} 不是命名空間的一部分。我們可以指派一個新值,例如使用此行 + +\colorbox{lightgray}{\tt mystringexample1 = "a new value"} + +在這種情況下,我們不會建立變數,只是將現有名稱綁定到新值。這個新值不必是字串,順便說一下,它可以是一個數字 + +\colorbox{lightgray}{\tt mystringexample1 = 1.1111} + +或者實際上是 Julia 可以使用的任何其他類型的值。如第 1 課所述,名稱不能從命名空間中刪除,只能新增。在本課程中,我們僅使用最上層命名空間,該命名空間的存在與你的 Julia 會話一樣長。 + +\section*{解構字串值} + +字串是一個字元序列。如你所見,在 Julia 中,我們透過將字串值括在一對雙引號中來表示它\footnote{Julia 有很多種類的值;在本課程中,我們只討論其中的幾個。請參閱第\ldots 課中對類型的討論。}。 + +我們之前已經簡要討論過字元。請注意,在 Julia 中,字元總是用單引號括起來。 + +[展示: \colorbox{lightgray}{\tt a = 'a', b = "a"}] + +在本課程中,我們將僅使用國際鍵盤的一次按鍵\footnote{可能透過 Ctrl 或 Tab 鍵修改}可用的字元來形成字串。但是更多的字元在 Julia 中是有效的\footnote{包括希臘語、阿拉伯語、梵語等字母表。事實上,在 Julia 中,不僅字母字元而且非字母字元(例如用於書寫普通話的字元)都是有效字元。} 稍後我們將簡要向你展示如何輸入它們。你可能希望開始在變數和函數名稱中使用它們,但學習這樣做是你自己的專案,它不是本課程的一部分。 + +\section*{解構變數名稱} + +只有部分在 Julia 字串值中可用的字元被允許作為變數名稱。 + +變數名稱必須以字母開頭\footnote{以及其他一些字元,但尤其不是數字,請參閱 Julia 文件了解詳細資訊。} 並且必須以字母、數字或底線或驚嘆號接續。在本課程中,我們僅使用羅馬字母表中的字母,但 Julia 接受的字母多於這些字母。 + +最佳做法是僅使用小寫字母和數字,並使用描述性名稱,例如 \colorbox{lightgray}{\tt mystringexample1}\footnote{Julia 社群通常遵守此規則。這使得驚嘆號具有非常特殊的含義,我們稍後會看到。儘管規則允許,但強烈不鼓勵在用戶代碼中使用底線;這個想法是將底線限制為 Julia 內部的特殊含義。}。 + +\section*{第 1 行是一個有效的 Julia 表示式} + +這一點非常重要:當 Julia 處理有效代碼時,電腦會發生變化---其中一些變化達到了代碼的目的(列印輸出、計算、圖片 \ldots)。第 1 行是有效的,因為: + +\begin{description} + \item[$\bullet$] 第 1 行包含 Julia 能識別的符號。 + \item[$\bullet$] 這些符號組合成三個有效群組。 + \item[$\bullet$] 這三個有效群組組合成一個有效表示式。 +\end{description} + +問題:Julia 能識別哪些符號? \\ +答:非常多! 但在本課程中,我們將只使用標準國際鍵盤上可見的符號,所有這些符號 Julia 都能識別。 + +問題:第 1 行中哪些是有效的符號群組?\\ +答:三個,分別是 \colorbox{lightgray}{\tt mystringexample1}、\colorbox{lightgray}{\tt =} 和 \colorbox{lightgray}{\tt "Hello, world"}。也就是說,Julia 識別出一個有效的變數名稱、一個有效的運算子和一個有效的字串\footnote{之間的空格不是必需的,正如 Julia 從其他線索中識別的那樣。然而,空格的存在/不存在有時在 Julia 中確實很重要,我們稍後會看到。}。 + +問題:為什麼這個有效符號群組的組合是一個有效的表示式?\\ +答:因為 \colorbox{lightgray}{\tt =} 運算子可以這樣運作。實際上,它\emph{只}能這樣運作:左邊的名字,中間的 \colorbox{lightgray}{\tt =} 和右邊的值。 + +只有當表示式的所有部分都被 Julia 正確識別並按照 Julia 的規則組合時,我們才有一個有效的 Julia 代碼表示式。生成有效代碼的規則非常嚴格,我們將在第 3 課中討論為什麼會這樣。 + +最後,讓我們注意第 1 行的某些部分本身就是有效代碼,即名稱和值。一個有效的表示式可以是一些更大的有效表示式的一部分。 + +\subsection*{評估無效代碼會產生錯誤訊息} +這裡有一些行話:我們說 Julia 評估它得到的每個表示式。這僅僅意味著 Julia 會嘗試執行代碼指示它執行的操作。 + +例如以下幾行無效代碼 + +\begin{minipage}{7cm} + \colorbox{lightgray}{\tt =}\\ + \colorbox{lightgray}{\tt = "Hello, world"}\\ + \colorbox{lightgray}{\tt mystringexample1 =}\\ + \colorbox{lightgray}{\tt mystringexample1 "Hello, world"}\\ + \colorbox{lightgray}{\tt "Hello, world" = mystringexample1} +\end{minipage} + +從 Julia 產生錯誤訊息,僅此而已\footnote{這不能完全保證,但絕對是 Julia 的創造者想要的!} 。在第 3 課中,我們將開始閱讀錯誤訊息和除錯無效代碼。 + +\subsection*{一個微妙的解釋} + +然而,這可能會讓你大吃一驚, + +\colorbox{lightgray}{\tt Hello, = mystringexample1} + +是有效代碼。這不是因為 \colorbox{lightgray}{\tt Hello,} 是一個有效的變數名稱,而是因為逗號的特殊作用。在這裡,因為它遵循指派運算子左側的有效名稱,所以逗號表示 Julia 應該執行多重指派。讓我們用一個左邊有兩個名字的例子: + +\colorbox{lightgray}{\tt Hello, world = mystringexample1 } \hspace{4.5cm} \ldots\ 行 4 + +\begin{minipage}[t]{8cm} +請注意,第 4 行引入了一種新的指派形式:右邊不是一個值,而是一個變數名稱。沒問題,Julia 只是使用綁定到變數名稱的值。 +\end{minipage} +\hfill +\begin{minipage}[t]{6cm} +展示:我們評估第 4 行,詢問它建立的變數名稱和值 +\end{minipage} + +多重指派的運作方式如下:在 \colorbox{lightgray}{\tt =} 的左側,變數用逗號分隔\footnote{如你所見,你可以只有一個變數後跟逗號,然後是 = 符號。}。獲得列表後,Julia 會在右側查找值。單個字串值可以提供多個單獨的值可能看起來很奇怪,但請記住,字串是一個字元序列。由於左側是一個序列,Julia 將右側視為一個序列。如你所見,右側的多餘項被忽略。 + +以這種方式使用逗號進行多重指派是 Julia 允許你建立非常緊湊且通常也很容易閱讀的代碼的方式之一。如果做得好,它確實可以幫助你編寫其他人喜歡閱讀的代碼,這可以極大地簡化協作。這包括與自己合作,幾個月或幾年後,當你嘗試使舊代碼適應新用途時。 + +\hspace*{1.5cm}\fbox{ \begin{minipage}{12 cm} + 不用擔心在 Julia 中編寫有效表示式的難度。正如你在第 1 課中看到的,這很容易。與任何電腦語言一樣,Julia 允許極長的有效表示式。是的,要確保這樣的表示式有效可能非常困難。但這一切都無關緊要。你可以用簡短的表示式做大量的事情! + + 而且你不必一次學習所有的 Julia。在本課程中,我們將逐步向你介紹越來越多的有效表示式形成方法,任何時候都不會太多。 + \end{minipage} +} + +\section*{第 2 行呼叫一個函數} + +當 Julia 代碼告訴一個函數做某事時,我們說它呼叫了這個函數。這裡我們使用一些輸入呼叫函數 \colorbox{lightgray}{\tt println}。這輸入是 \colorbox{lightgray}{\tt mystringexample1}, +即變數的名稱。 + +要使此代碼成為有效代碼,\colorbox{lightgray}{\tt println} 必須能夠格式化該變數的值\footnote{像\colorbox{lightgray}{\tt "Hello, world"} 這樣的普通字串是所有值中最容易格式化的。}。在 Julia 中呼叫函數會使事情發生。 + +你應該思考一下:函數呼叫\colorbox{lightgray}{\tt println(mystringexample1)}做了幾件事:首先它接受變數名稱,然後獲取變數的值,然後格式化它---在這種情況下,幾乎沒有什麼可做的---然後它會在螢幕上列印格式化的字串,然後在下一個\colorbox{lightgray}{\tt julia>}提示符之前顯示一個空行。 + +Julia 是如何知道一段代碼引用了一個函數的?很簡單:代碼是一個有效的變數名稱,後面緊跟括號 --- 也就是說,函數名稱後面沒有任何空格,下一個字元是\colorbox{lightgray}{\tt(}。之後是函數的輸入,輸入之後是關閉的\colorbox{lightgray}{\tt)}。 + +然而,\colorbox{lightgray}{\tt println} 實際上並不需要任何輸入:[展示:\colorbox{lightgray}{\tt println()}, \colorbox{lightgray}{\tt include()}]。你會看到 \colorbox{lightgray}{\tt println()} 的行為就好像你給了它一個空字串:它列印一行空的內容,然後跳到新行,然後跳到 \colorbox{lightgray}{\tt julia>} 提示符 . 另一方面,\colorbox{lightgray}{\tt include()} 會引發錯誤。 + +規則有一個例外,即 Julia 透過名稱後面的 \colorbox{lightgray}{\tt (} 識別函數。正如我們所指出的,運算子是一種特殊的函數。它們(大部分)是數學符號,例如 \colorbox{lightgray}{\tt - }、\colorbox{lightgray}{\tt +}、\colorbox{lightgray}{\tt >} 以及它們形成的表示式具有非常接近通常數學含義的規則\footnote{但請注意:數學含義只是一個指示。必須嚴格遵守規則,所以你必須知道它們!}。在本課程中,你將學習更多的 Julia 內建函數,並且你還將編寫自己的。很大一部分 Julia 代碼是透過函數編寫的。 + +\section*{最終解構:分隔符} + +我們在 \colorbox{lightgray}{\tt println()} 中使用的括號在 Julia 中起著重要作用:它們是分隔符。它們用於告訴 Julia 函數的輸入在哪裡開始和結束。同樣,字串周圍的雙引號是分隔符,逗號用於進行多重指派時也是如此。 + +請注意你輸入的內容以產生有效代碼:使用有效字元,你輸入了值、名稱、運算子和分隔符。這涵蓋了我們在本課程中使用的所有有效代碼\footnote{如前所述,我們僅使用 Julia 中有效字元的一小部分。同樣,我們只使用了 Julia 的一些運算子和分隔符。}。 + +%\newpage +\section*{回顧與總結} + +\begin{description} + \item[$\bullet$] Julia 代碼由有效的表示式組成。 + \item[$\bullet$] 在第 1 週,我們使用包含值、名稱、運算子和分隔符的有效表示式。 + \item[$\bullet$] Julia 中的名稱必須以字母開頭,並以字母或數字或底線或驚嘆號接續。 + \item[$\bullet$] 變數是綁定到值的名稱。 + \item[$\bullet$] 呼叫函數意味著在其名稱後面加上括號,將傳遞給函數的值和/或變數名稱括起來。 + \item[$\bullet$] 運算子是一種不需要括號的特殊函數---通常它們是像 \colorbox{lightgray}{\tt =}、 \colorbox{lightgray}{\tt +}、 \colorbox{lightgray}{\tt <} 等符號。 + \item[$\bullet$] 字串值周圍的 \colorbox{lightgray}{\tt " "} 對,和函數輸入周圍的括號 \colorbox{lightgray}{\tt ( )} 等分隔符有助於構建 Julia 代碼。 +\end{description} + +\end{document} diff --git a/Course Notes/Translation/Traditional Chinese/Week 1/L3W1_ErrorsAndDebugging-zh_TW.pdf b/Course Notes/Translation/Traditional Chinese/Week 1/L3W1_ErrorsAndDebugging-zh_TW.pdf new file mode 100644 index 0000000..1d7ea80 Binary files /dev/null and b/Course Notes/Translation/Traditional Chinese/Week 1/L3W1_ErrorsAndDebugging-zh_TW.pdf differ diff --git a/Course Notes/Translation/Traditional Chinese/Week 1/L3W1_ErrorsAndDebugging-zh_TW.tex b/Course Notes/Translation/Traditional Chinese/Week 1/L3W1_ErrorsAndDebugging-zh_TW.tex new file mode 100644 index 0000000..731ac66 --- /dev/null +++ b/Course Notes/Translation/Traditional Chinese/Week 1/L3W1_ErrorsAndDebugging-zh_TW.tex @@ -0,0 +1,105 @@ +\documentclass[]{article} + +\usepackage{amsmath} +\usepackage{amsfonts} +\usepackage{amssymb} +\usepackage{xcolor} +\usepackage{url} +\usepackage{graphicx} +\usepackage{geometry} +\usepackage[most]{tcolorbox} + +% {Begin zh_TW} +% Credit: XeLaTex 中文 · GitHub +% https://gist.github.com/iamalbert/1b87a5349f7e860bfe33 +\usepackage{fontspec} % 加這個就可以設定字體 +\usepackage{xeCJK} % 讓中英文字體分開設置 +\setCJKmainfont{微軟正黑體} % 設定中文為系統上的字型,而英文不去更動,使用原 TeX 字型 +\XeTeXlinebreaklocale "zh" % 這兩行一定要加,中文才能自動換行 +\XeTeXlinebreakskip = 0pt plus 1pt % 這兩行一定要加,中文才能自動換行 + +\defaultCJKfontfeatures{AutoFakeBold=6,AutoFakeSlant=.4} %以後不用再設定粗斜 +% {End zh_TW} + +\setlength{\parindent}{0em} +\setlength{\parskip}{3ex} +\geometry{left=3cm, top = 3cm, right = 3cm, bottom = 3cm} + +\newcommand{\ignore}[1]{} +\newcommand{\codequote}[1]{\colorbox{lightgray}{\tt #1}} + +\begin{document} + +\author{} \date{} +\title{第 1 週,第 3 課:錯誤訊息和除錯} +\maketitle + +\vspace{-2cm} +----------------- + +\section*{目標} +{\large +\begin{description} + \item[---] 學習閱讀錯誤訊息 + \item[---] 學習逐行除錯方法 +\end{description} +} +學完本課,你將能夠 +\begin{description} + \item[*] 在 Julia 的錯誤訊息中找到有用的資訊 + \item[*] 在單行 Julia 代碼中查找錯誤並修復它們 + \item[*] 逐行執行 Julia 代碼,在發現錯誤時修復它們 + \item[*] 偶爾回去修復你錯過的錯誤 +\end{description} + +\section*{除錯一些幾乎是第 1 課的代碼} + +假設我們錯誤地嘗試使用以下代碼運行第 1 課的練習\footnote{NB:如果你從新的 REPL 開始,這效果最好。 它包含拼寫錯誤,你應該小心地按原樣輸入下面的示例(拼寫錯誤及全部)。}. + +\codequote{mystiring1 = "Hello, world }\\ +\codequote{prinln(mystring1) } + +你會發現它沒有辦法順利運行(並且,依照你嘗試運行它的方式,你可能會看到一個錯誤訊息)。 + +透過逐行檢查代碼,你可以找出原因。 在這裡,當我們嘗試從 REPL 運行第一行時,它停住了,沒有任何錯誤消息。你現在的工作是找出原因,並從仔細查看代碼開始。它是有效的代碼嗎?不是!沒有結束雙引號字符來指出字串值的結尾。 正如 Julia 所見,你仍然在字串中輸入字符\footnote{如果將這兩行放在 .jl 檔案中並嘗試使用 {\tt include()} 運行它,則會看到錯誤訊息 +“LoadError: syntax: incomplete: invalid string syntax”,這會更有幫助,但不是很多。事實上,發生語法錯誤的方式有很多種,Julia 並沒有很努力地告訴你錯誤到底是什麼。}。 + +你可透過在結尾添加缺少的雙引號字符來修復該行。 + +在此有一個很好的技巧:在結束雙引號之後添加一個分號。 在 REPL 中,這會抑制該行的輸出,這意味著你需要閱讀的內容更少,干擾更少。 當然,在某些情況下,你會希望查看評估一行代碼的輸出,這並不總是正確的做法。 + +好的,現在代碼變成了 + +\codequote{mystiring1 = "Hello, world";}\\ +\codequote{prinln(mystring1)} + +當我們在 REPL 運行第一行時,正如預期的那樣看不到輸出。 所以我們運行第二行。 哦親愛的。 螢幕上突然出現很多行訊息,其中一些是紅色的! + +以 \textcolor{red}{ERROR} 開頭的行是重要的\footnote{非常重要,以至於在大多數終端中它都顯示為鮮紅色。}:這是錯誤訊息。 在其中,Julia 為你提供了可能存在的問題的一些指示。 在此,訊息是 \codequote{\textcolor{red}{UndefVarError: prinln not defined}}。 當然這也是很容易修復的,所以現在代碼變成了 + +\codequote{mystiring1 = "Hello, world";}\\ +\codequote{println(mystring1)} + +現在我們看到一個錯誤:訊息是 \codequote{\textcolor{red}{UndefVarError: mystring1 not defined}}。多麼出乎意料!這似乎是錯誤的:該行是有效的 Jullia 代碼!當我們檢查 \codequote{println()} 行時,變數名稱似乎沒有問題,它怎麼可能是未定義的??這在除錯中經常發生:一些錯誤掩蓋了其他錯誤。你修復了你找到的第一個錯誤,最終它們會揭示在你的代碼中更早地錯誤。當然,這裡在它上面的行中有一個拼寫錯誤。如果我們沒有立即發現,錯誤訊息說 \codequote{\textcolor{red}{mystring1 not defined}} 的事實應該會有所幫助。 這意味著這是 Julia 第一次看到名稱 \codequote{mystring1}。 我們認為稍早已創建它是錯誤的:要嘛根本沒有創建它的行,要嘛這行是錯誤的。 找到應該創建它的行,並修復錯誤。 最終,我們最後一次正確的更改為 + +\codequote{mystring1 = "Hello, world";}\\ +\codequote{println(mystring1)} + +\section*{關於除錯的一些要點} + +以這種方式逐行檢查絕不是發現錯誤的唯一方法,但它是開始學習如何除錯代碼的好地方。 你應該經常練習並能熟練地解讀錯誤訊息。 + +事實上,除錯對於程式設計師來說絕對是一項至關重要的技能。 就像編寫代碼一樣,這裡有很多很多風格的除錯方式\footnote{我們將在下一課中看到,編寫代碼從根本上是一種創造性表達的行為。 除錯也允許你按照自己的方式進行。}。但它們的核心是能夠以非常挑剔的眼光閱讀代碼。那個能力是你應該培養的。 + +如果你繼續進行大量編程,你可能希望了解可以幫助你完成任務的軟體。那裡有很多選擇\footnote{對於 Julia,主要支持的是 \codequote{Debugger.jl} 套件包,它非常有用但需要一段時間來學習,以及 \codequote{Juno} 開發介面,它雖不是專門用於除錯,但有很多功能可以有所幫助—這些功能可以通過使用 \codequote{Debugger.jl} 進行擴展。 },但在本課程中我們不會討論到。 + +\section*{回顧與總結} + +\begin{description} + \item[*] 逐行除錯是一項非常有用的技能學習。 + \item[*] Julia 中的錯誤訊息包含有用的提示及許多其他細節。 + \item[*] Julia\footnote{或任何其他語言,就此而言。} 中的錯誤訊息不能保證它們指向實際錯誤。 + \item[*] 在 REPL 和運行具有相同代碼的 .jl 檔案的逐行輸出並不完全相同。 + \item[*] 對於逐行輸出,在行尾使用分號來抑制輸出是很有幫助的。 + \end{description} +\end{document} diff --git a/Course Notes/Translation/Traditional Chinese/Week 1/L4W1_ProgrammingIsAppliedFormalLogic-zh_TW.pdf b/Course Notes/Translation/Traditional Chinese/Week 1/L4W1_ProgrammingIsAppliedFormalLogic-zh_TW.pdf new file mode 100644 index 0000000..11383a6 Binary files /dev/null and b/Course Notes/Translation/Traditional Chinese/Week 1/L4W1_ProgrammingIsAppliedFormalLogic-zh_TW.pdf differ diff --git a/Course Notes/Translation/Traditional Chinese/Week 1/L4W1_ProgrammingIsAppliedFormalLogic-zh_TW.tex b/Course Notes/Translation/Traditional Chinese/Week 1/L4W1_ProgrammingIsAppliedFormalLogic-zh_TW.tex new file mode 100644 index 0000000..96f78ca --- /dev/null +++ b/Course Notes/Translation/Traditional Chinese/Week 1/L4W1_ProgrammingIsAppliedFormalLogic-zh_TW.tex @@ -0,0 +1,369 @@ +\documentclass[]{article} + +\usepackage{amsmath} +\usepackage{amsfonts} +\usepackage{amssymb} +\usepackage{xcolor} +\usepackage{url} +\usepackage{graphicx} +\usepackage{geometry} +\usepackage[most]{tcolorbox} + +% {Begin zh_TW} +% Credit: XeLaTex 中文 · GitHub +% https://gist.github.com/iamalbert/1b87a5349f7e860bfe33 +\usepackage{fontspec} % 加這個就可以設定字體 +\usepackage{xeCJK} % 讓中英文字體分開設置 +\setCJKmainfont{微軟正黑體} % 設定中文為系統上的字型,而英文不去更動,使用原 TeX 字型 +\XeTeXlinebreaklocale "zh" % 這兩行一定要加,中文才能自動換行 +\XeTeXlinebreakskip = 0pt plus 1pt % 這兩行一定要加,中文才能自動換行 + +\defaultCJKfontfeatures{AutoFakeBold=6,AutoFakeSlant=.4} %以後不用再設定粗斜 +% {End zh_TW} + +\setlength{\parindent}{0em} +\setlength{\parskip}{3ex} +\geometry{left=3cm, top = 3cm, right = 3cm, bottom = 3cm} + +\newcommand{\ignore}[1]{} +\newcommand{\codequote}[1]{\colorbox{lightgray}{\tt #1}} + +\begin{document} + +\author{} \date{} +\title{{\color{gray}Lesson 4, Week 1: Programming is applied formal logic} +\\* +{第 1 週,第 4 課:程式設計是應用的形式邏輯}} +\maketitle + +\vspace{-2cm} +----------------- + +{\color{gray}This is the only theory lesson in the whole course. As such, it is very, very important!} +\\* +{這是整個課程中唯一的理論課。因此,這是非常非常重要的!} + +\begin{flushleft} + \section*{{\color{gray}AIM} + \\* + {目標}} +\end{flushleft} + +{\large +\begin{description} + \setlength{\itemindent}{-18pt} + \item[---] {\color{gray}to understand the difference between logic and formal logic} + \\* + {了解邏輯和形式邏輯的區別} + \item[---] {\color{gray}to understand how formal logic makes computer language possible} + \\* + {了解形式邏輯如何使電腦語言成為可能} +\end{description} +} +{\color{gray}After this lesson, you will be able to} +\\* +完成本節課後,你將能夠 +\begin{description} + \setlength{\itemindent}{-12pt} + \item[*] {\color{gray}explain what we mean by the word logic} + \\* + {解釋我們所說的邏輯這個詞的意思} + \item[*] {\color{gray}explain the difference between logic and formal logic} + \\* + {解釋邏輯和形式邏輯的區別} + \item[*] {\color{gray}explain why any computer must embody formal logic} + \\* + {解釋為什麼任何電腦都必須體現形式邏輯} + \item[*] {\color{gray}give a small example of a language that applies formal logic} + \\* + {舉一個應用形式邏輯的語言的小例子} + \item[*] {\color{gray}explain why writing computer programs is expressive, in the same way as writing poems or music} + \\* + {解釋為什麼編寫電腦程式是具有表現力的,就像寫詩或音樂一樣} +\end{description} + +\section*{{\color{gray}Why this lesson?} +\\* +{為什麼要上這節課?}} + +{\color{gray}Programming often feels very strange to beginners, and if they haven't worked much with mathematical formulae, it can feel utterly alien.} +\\* +{對於初學者來說,通常會對程式設計感到非常奇怪,如果他們也沒有接觸太多數學公式,那會完全陌生。} + +{\color{gray}This lesson cannot make the initial experience any less weird. Weird is part of the territory. But by explaining that it isn't arbitrary, nor aimed at keeping people out, but instead an essential aspect of any computer language, I hope to encourage you to persist until the Julia way of writing programs starts to feel natural. At that point, you will have learnt a new {\color{cyan}languge}.} +\\* +{本課程無法使初始體驗變得較不怪異。怪異是這個領域的一部分。但是,藉由解釋它不是任意的,也不是旨在拒人於外,而是任何電腦語言的基本,我希望鼓勵你堅持下去,直到對 Julia 的寫作方式開始感到自然。那時,你將學會一個新的語言。} + +{\color{gray}That is entirely serious: Julia, as I hope you will see below, is as rich and expressive in its own right as any natural language, such as Spanish, Mandarin and !Kung. Apart from implementing formal logic, there is no real difference with other languages. You could use it to write advertisements, love letters, novels, whatever! But mostly, since the formal logic can be implemented on a machine, you use it to write programs that make machines do things you want them to do.} +\\* +{這完全是認真的:Julia, 就如我希望你能在如下看到的,它本身就是豐富和有表現力的,就像任何自然語言,例如西班牙語,普通話和{ }!Kung 語, 除了實作正式邏輯外,和其他語言其實沒有真正的區別。你可以使用它來寫廣告,情書,小說等等!但是,大多數情況下,由於可以在電腦上實現形式邏輯,因此你可以使用它編寫讓機器做你想要它們做的事情的程式。} + +\section*{{\color{gray}Logic: the study of correct forms of reasoning} +\\* +{邏輯:對正確推理形式的研究}} + +{\color{gray}Reasoning is part of everyday life and language. It is simply the process of trying to make sense of things and expressing that as clearly as possible.} +\\* +{推理是日常生活和語言的一部分。這只是試圖理解事物並儘可能清楚地表達的過程。} + +{\color{gray}Unfortunately, there are many ways people use to make sense that actually are mistakes in reasoning. For example, it makes sense that raining wets grass, and this may lead people to reason as follows: if the grass is wet, there has been rain. Although this may often be true, it isn't always true: rain is not the only way grass can get wet. Strictly speaking, it is not correct. Reasoning correctly is quite hard!} +\\* +{不幸的是,人們用來理解的很多方法實際上在推理上是錯誤。例如,雨讓草濕了是有意義的,這可能會導致人們推理如下:如果草濕了,那就下雨了。儘管這通常可能是正確的,但這並不總是正確的:雨不是草濕的唯一途徑。嚴格來說,這是不正確的。正確推理非常困難!} + +{\color{gray}As far we know, the first people who became aware of this \emph{and} made a study of correct forms of reasoning lived approximately 100 generations ago. This occurred separately, in at least three places: in ancient China, ancient Greece and ancient India rules were formulated for reasoning correctly.} +\\* +{據我們所知,最早意識到這一點{\bfseries{並}}研究了正確的推理形式的人距今大約 100 個世代以前。這是分別發生的,至少在三個地方:在中國古代,古希臘和古代印度,規則是為了正確推理而制定的。} + +{\color{gray}The word logic is used in many different ways in ordinary language. In this course, we use it in only one sense: the study of correct forms of reasoning.} +\\* +{邏輯一詞在普通語言中以許多不同的方式使用。在本課程中,我們僅在一種意義上使用它:正確的推理形式的研究。} + +\section*{{\color{gray}Formal logic: using symbolic formulae to study and apply logic} +\\* +{形式邏輯:使用符號公式來研究和應用邏輯}} + +{\color{gray}Formal logic is simple to define: it uses symbols and formulae to study reasoning. This is fairly new discipline, it started only about 6 generations ago\footnote{{\color{gray}See \emph{Logicomix} by Doxiadis and Papadimitrou for an excellent and very human account of some of the most important episodes in the early history of formal logic.}}.} +\\* +{形式邏輯很容易定義:它使用符號和公式來研究推理。這是相當新的學科,它僅開始於大約 6 個世代以前\footnote{參見{ }Doxiadis{ }和{ }Papadimitrou{ }的{\bfseries{Logicomix}},以了解形式邏輯早期歷史上一些最重要情節的出色和非常人性化的話題。}。} + +{\color{gray}The aim of making logic formal was absolute precision in reasoning and absolute certainty about its correctness. It aims at this by using rules similar to the rules of algebra\footnote{{\color{gray}This goal has been considerably refined, because it was shown that a system cannot be consistent as well as complete and applicable to all of mathematics. For computers, it is not necessary to produce \emph{all} correct reasoning---it is enough to ensure that all the reasoning in your computer is completely correct.}}. By doing so, it reduces logical analysis to calculations which can be independently checked. In other words, it removes the need for intuition and insight from logical analysis.} +\\* +{製作邏輯形式的目的是推理的絕對精確性和關於其正確性的絕對確定性。它透過使用類似於代數規則的規則來實現這一目標\footnote{這個目標已經得到了很大的改進,因為它顯示系統無法一致且完整到適用於所有的數學。對於電腦,並不需要產生{\bfseries{所有}}正確的推理---它已足以確保電腦中的所有推理都是完全正確的。}。透過這樣做,它將邏輯分析減少到成為可以獨立檢查的計算。換句話說,它從邏輯分析中消除了對直覺和見解的需求。} + +{\color{gray}Formal logic has the strange property that something obvious and something baffling can sit side by side. For an example of the obvious, see the NOT, AND and OR truth tables below. Unfortunately, we you'll have to take our word {\color{cyan}for for} the ease with which baffling things come up quite unexpectedly (or read \emph{Logicomix}, in particular pages 164 to 168, about paradoxes).} +\\* +{正式的邏輯具有奇怪的屬性,即明顯的事情和令人困惑的東西可能並排坐。 有關明顯的示例,請參見下面的 NOT, AND 及 OR 的真值表。 不幸的是,你必須相信我們所說,以緩和令人困惑的事情出乎意料地出現(或閱讀{\bfseries{Logicomix}},特別是第 164 至 168 頁,關於悖論)。} + +\subsection*{{\color{gray}Truth tables for {\tt NOT}, {\tt AND}, {\tt OR}} +\\* +{{\tt NOT}, {\tt AND}, {\tt OR}的真值表} +} + +{\color{gray}In two-valued logic, which is by far the most common type of formal logic and also what Julia uses, there are two constant values, we denote them with {\tt true} and {\tt false} \footnote{{\color{gray}In Julia code they are the values \codequote{true} and \codequote{false}.}}. A statement is then something that is either {\tt true} or {\tt false}. As noted above, for a formal logic we need a symbol to stand for a statement, for example we can use $P$ to stand for the statement ``The earth spins on its axis" and $Q$ for the statement ``The earth is round"\footnote{{\color{gray}You may disagree with either of these; the first is much clearer than the second. Of course the earth is not perfectly round, but for practical purposes the imperfections are negligible, so it is perfectly reasonable to say that $ Q $ is true. This sort of thing is why ordinary language and everyday reasoning are very hard to represent in a formal language.}}.} +\\ +{在兩值邏輯中,這是迄今為止最常見的形式邏輯類型,也為 Julia 所使用,有兩個常數值,我們用{\tt true}和{\tt false}表示它們\footnote{在 Julia 代碼中,它們是值\codequote{true}和\codequote{false}。}. 一個陳述則會是真({\tt true})或假({\tt false})。如上所述,對於形式邏輯,我們需要一個符號來代表陳述,例如,我們可以使用 $P$ 來代表陳述「地球在其軸上旋轉」及 $Q$ 用於陳述「地球是圓形的」\footnote{你可能會不同意其中的任何一個。第一個比第二個要清楚得多。當然,地球不是完全圓形的,但是出於務實目的,這種不完美是可以忽略不計的,因此說$ Q $是正確的,這是完全合理的。這種事情就是為什麼普通語言和日常推理很難用形式語言表示的原因。}。} + +{\color{gray}So now we have two symbols $ P $ and $ Q $. Here are three more: $ \neg $, $ \land $, $ \lor $. With these, lets look at four valid formulae: $ \lnot P $, $ \lnot Q $, $ P \land Q $, $ P \lor Q$.} +\\* +{因此,現在我們有兩個符號$ P $和$ Q $。這裹還有三個:$ \neg $,$ \land $,$ \lor $。 透過這些,讓我們來看四個有效的公式:$ \lnot P $,$ \lnot Q $,$ P \land Q $,$ P \lor Q $。} + +{\color{gray}In words, these are ``The earth does not spin on its axis", ``The earth is not round", ``The earth spins on its axis and the earth is round", and ``The earth spins on its axis or the earth is round". That is, $ \neg $ means {\tt NOT}, $ \land $ means {\tt AND} and $ \lor $ means {\tt OR}.} +\\ +{用言語說,這些是「地球不在其軸上旋轉」,「地球不是圓形的」,「地球在其軸上旋轉,且地球是圓形的」,「地球在其軸上旋轉,或地球是圓形的」。也就是說,$ \neg $表示{\tt NOT},$ \land $表示{\tt AND},$ \lor $表示{\tt OR}。} + +{\color{gray}But what do these mean, in terms of formal logic? Well, they (may) change the truth values. For example, if $ P $ is true then $ \neg P $ must be false. A good way to summarise exactly what they mean is by means of truth tables. In a truth table, we specify the truth value of all valid combinations.} +\\* +{但是,就形式邏輯而言,這些意味著什麼? 好吧,他們(可能)改變真實價值觀。 例如,如果$ P $為true,則$ \neg P $必須為false。 透過真值表來總結它們的含義是一種好方法。 在真值表中,我們指定了所有有效組合的真值。} + +{\color{gray}So the truth table for $ \neg $ (equivalently, {\tt NOT}) is as follows (note that \emph{two} lines are needed to get both possibilities):} +\\* +{因此$ \neg $(等效地,{\tt NOT})的真值表如下(請注意,需要{\bfseries{兩}}行以獲得這兩種可能性): }\\ +\begin{tabular}{|c|c|} +$ P $ & $ \neg P $ \\ +{\tt true} & {\tt false} \\ +{\tt false} & {\tt true} +\end{tabular} + +{\color{gray}The truth table for $ \land $ (equivalently, {\tt AND}) requires four lines:} +\\* +{$ \land $(等效地,{\tt AND})的真值表需要四行:} \\ +\begin{tabular}{|c|c|c|} + $ P $ & $ Q $ & $ P \land Q $ \\ + {\tt true} & {\tt true} & {\tt true} \\ + {\tt true} & {\tt false} & {\tt false} \\ + {\tt false} & {\tt true} & {\tt false} \\ + {\tt false} & {\tt false} & {\tt false} +\end{tabular} \\ +{\color{gray}In other words, the combined forumula $ P\land Q $ is {\tt true} only when both are {\tt true}, and {\tt false} otherwise.} +\\* +{換句話說,組合的公式$ P \land Q $僅當兩者都是{\tt true}才會是{\tt true},其他則會是{\tt false}。} + +{\color{gray}The truth table for $ \lor $ (equivalently, {\tt OR}) is: } +\\* +{$ \lor $(等效地,{\tt OR})的真值表是:}\\ +\begin{tabular}{|c|c|c|} + $ P $ & $ Q $ & $ P \lor Q $ \\ + {\tt true} & {\tt true} & {\tt true} \\ + {\tt true} & {\tt false} & {\tt true} \\ + {\tt false} & {\tt true} & {\tt true} \\ + {\tt false} & {\tt false} & {\tt false} +\end{tabular} \\ +{\color{gray}In other words, the combined forumula $ P\lor Q $ is {\tt false} only when both are {\tt false}, and {\tt true} otherwise.} +\\* +{換句話說,組合的公式$ P \lor Q $僅當兩者都是{\tt false}才會是{\tt false},其他則會是{\tt true}。} + +{\color{gray}Because they may change truth values, {\tt NOT}, {\tt AND} and {\tt OR} are called operators. To be more specific, they are logical operators.} +\\* +{因為他們可能會修改真值,所以{\tt NOT}、{\tt AND}和{\tt OR}被稱為運算子。更具體地說,他們是邏輯運算子。} + +{\color{gray}The symbols we've seen are standard for research papers in formal logic, but not in progamming. In Julia, the symbol for {\tt NOT} is \codequote{!}, {\tt AND} is \codequote{\&\&} and {\tt OR} is \codequote{||} . We'll see these again later; the fact that we need two characters make one symbol is of no significance.} +\\* +{我們所看到的符號是形式邏輯研究論文的標準,但沒有用在程式設計上。在 Julia 中,{\tt NOT}的符號為 \codequote{!},{\tt AND}是 \codequote{\&\&} 和 {\tt OR}是\codequote{||}。我們稍後會再看到這些;我們需要兩個字元構成一個符號是無關緊要的。} + +\subsubsection*{{\color{gray}Why formal logic needs a formal language} +\\* +{為什麼形式邏輯需要形式語言}} + +{\color{gray}For formal logic to work, every expression must consist of symbols. In fact, it must consist of symbols that formal logic recognises---in exactly the same way that every expression in Julia must consist of symbols that Julia recognises\footnote{{\color{gray}Introductions to formal logic have to solve a bootstrap problem: until you know the symbols, you can't do formal logic. They tend to start as we did here: by translating some very simple sentences into symbols. This has the effect of making the very simple seem complicated. Weird, but very hard to avoid.}}.} +\\* +{為了讓形式邏輯運作,每個表示式都必須由符號組成。實際上,它必須由形式邏輯認可的符號組成---與 Julia 中的每個表示式完全一樣同時也為 Julia 所認可\footnote{對形式邏輯的介紹必須解決一個前導問題:在您知道符號之前,您無法進行正式邏輯。 它們傾向於像我們在這裡一樣開始:將一些非常簡單的句子轉換為符號。這會有讓非常簡單的反而顯得複雜的效果。很奇怪,但是很難避免。}。} + +{\color{gray}A formal language makes it possible to say exactly what symbols and expressions are valid in that language. It has to go beyond the three operators we've seen above. That is, in order to express something, one has to use symbols that can carry truth values. Above, we used $ P $ and $ Q $ for that, but that was for convenience only. There are much better ways, and Julia is one of those. +} +\\* +{一種形式的語言可以準確地說出哪些符號和表示式在該語言中有效。它必須超越我們上面看到的三個運算子。也就是說,為了表達某些內容,必須使用可以承載真值的符號。上面,我們為此使用了$ P $和$ Q $,但這僅是出於方便。有更好的一些方法,Julia 就是其中之一。 +} + +{\color{gray}Let's repeat that: Julia is a formal language\footnote{{\color{gray}In fact, every computer language is a formal language.}}. It uses characters to form values and names, and then it uses delimiters and operators to form the names and values into expressions. The rules of the formal logic that governs Julia then determine whether the expression is valid or not.} +\\* +{讓我們重複一遍: Julia 是一種形式語言\footnote{實際上,每種電腦語言都是形式語言。}。它使用字元組成值和名稱,然後使用定界符和運算子將名稱和值組成表示式。這些形式邏輯規則主宰著 Julia ,用以決定表示式是否有效。} + +{\color{gray}In other words, you can write an unbelievably large number of Julia programs, but in order for them to consist of valid expressions, you have to follow the rules of Julia's formal language and formal logic.} +\\* +{換句話說,你可以編寫令人難以置信數量的 Julia 程式,但是為了讓它們由有效的表示式組成,你必須遵循 Julia 的形式語言和形式邏輯的規則。} + +\subsubsection*{{\color{gray}Formal languages can generative and make computers possible} +\\* +{形式語言可以是生產的並使電腦成為可能}} + +{\color{gray}By ``generative'' I mean that one can make new expressions from old ones. A useful language with only a few valid expressions can certainly exist, but Julia and all major computer languages allow a great many valid expressions, and also set no limit on how many such expressions are used to write a program.} +\\* +{用``生產的''一詞我的意思是,人們可以從舊的表示式中製作出新的表示式。只有幾個有效表示式的有用語言肯定也是存在的,但是 Julia 和所有主要的電腦語言都允許很多有效的表示式,也沒有對使用多少此類表示式來編寫程式進行限制。} + +{\color{gray}Writing a poem is also the result of a generative process: you add one word after another, one line after another, and there is no set limit on how long your poem may be.} +\\* +{寫一首詩也是生產過程的結果:你新增一個又一個單詞,一行又一行,並且對你的詩也沒有設定的長度限制。} + +{\color{gray}But a formal language is not just generative: because the rules are completely fixed and explicit, they can be mechanised. They can be made to be part of a machine\footnote{{\color{gray}The earliest programmable computer design was by Charles Babbage over 150 years ago, for a machine to be driven by steam.}}; in such a machine you have a way to represent the values {\tt true} and {\tt false}. Then when you apply {\tt not} to a {\tt true} you get the value {\tt false}, and so on. Such a machine can produce and evaluate all the expressions of a formal language and its the formal logic.} +\\* +{但是形式語言不僅是生產的:由於規則是完全固定和明確的,因此可以機械化。他們可以成為機器的一部分\footnote{最早可程式設計的電腦設計是由 150 年前的查爾斯·巴巴奇(Charles Babbage)設計的,是一台由蒸汽驅動的機器。}; 在這樣的電腦中,你有一種表示值{\tt true}和{\tt false}的方法。然後,當你將{\tt not}應用於 {\tt true}時,你將獲得值{\tt false},依此類推。這樣的機器可以生產和評估形式語言及其形式邏輯的所有表示式。} + +{\color{gray}At the level of a microchip, all modern electronic digital computers contain many millions of tiny electrical circuits that are nothing but electronic versions of {\tt NOT} , {\tt AND}, {\tt OR}\footnote{{\color{gray}Of course, they contain much more than just these operators, but this is not a course in computer design.}}. Formal logic is what makes a computer possible; all modern computers are applications of formal logic. +} +\\* +{在晶片的層級上,所有現代的電子數位電腦都包含數百萬個微型電路,這些電路不過是{\tt not}、{\tt and}、{\tt or} 的電子版本\footnote{當然,它們包含不僅僅是這些運算子,但這不是電腦設計的課程。}。形式邏輯是使電腦成為可能的原因。所有現代電腦都是形式邏輯的應用。} + +\section*{{\color{gray}A formal language with just a few letters and rules} +\\* +{只有幾個字母和規則的形式語言}} + +{\color{gray}Let us look at brief example of a formal language, let's call it AdHoc1. It will be very simple, just a few letters and rules. They allow the formation of some sentences in English, but also of expressions that are very far from being English. That is, the valid expressions in this language include some English but not all of it, and includes non-English also. To specify AdHoc1, we give a full list of symbols and a full list of how rules for building expressions.} +\\* +{讓我們看看形式語言的簡短範列,讓我們稱其為 AdHoc1。這將非常簡單,只有幾個字母和規則。它們允許組成一些英語句子,但也允許表達遠非英語。也就是說,這種語言的有效表示式包括一些英語,但並非全部,也包括非英語。為了定義 AdHoc1,我們提供了符號的完整列表,並提供了建構表示式規則的完整列表。} + +{\color{gray}The symbols are a few characters: the letters {\tt a c e i f h l n s t} and the space character.} +\\* +{符號是幾個字元:字母{\tt a c e i f h l n s t}和空格字元。} + +{\color{gray}The rules are} +\\* +{規則是} +\begin{enumerate} + \item {\color{gray}Some letters are also vowels, they are: {\tt a e i}.} + \\* + {有些字母也是母音,它們是:{\tt a e i}。} + \item {\color{gray}Some letters are also consonants, they are {\tt c f h l n s t}.} + \\* + {有些字母也是子音,它們是 {\tt c f h l n s t}。} + \item {\color{gray}An expression must start with a consonant.} + \\* + {表示式必須從子音開始。} + \item {\color{gray}An expression may not contain two vowels next to each other.} + \\* + {表示式不能包含兩個連續母音。} + \item {\color{gray}Any expression can have a character added to it, except that} + \\* + {任何表示式都可以再新增一個字元,除了} + \begin{enumerate} + \item {\color{gray}No expression can have more than 100 characters} + \\* + {表示式不可超過 100 個字元} + \item {\color{gray}No expression can end with the space character} + \\* + {表示式不能以空格字元結束} + \end{enumerate} +\end{enumerate} + +{\color{gray}Note that some expressions made with AdHoc1 look like sentences in English, for example "that is it" and "that is it i think". But strangely enough, "i think that is it" is \emph{not} a valid expression in AdHoc1, because it violates rule 3. Some amusing expressions are possible, such as "the think that i think that i think that i that think thinks". Also the famous paradox "this sentence is false" is valid AdHoc1.} +\\* +{請注意,某些用 AdHoc1 寫成的表示式看起來像英語的句子,例如"that is it"和"that is it i think"。但是奇怪的是,"i think that is it"\emph{不}是在 AdHoc1 中的有效表示式,因為它違反了規則3。可能會有一些有趣的表示式,例如"the think that i think that i think that i that think thinks"。同時著名的悖論"this sentence is false"也是有效的 AdHoc1。} + +{\color{gray}However, by reading that last sentence as a paradox we are reading it as English. This is not part of AdHoc1, and requires an extension that applies AdHoc1 expressions to English. But most AdHoc1 expressions are not English, for example "ticillllll eee", so this extension is very informal\footnote{{\color{gray}Actually, no formal language exists that produces all the valid sentences in English and only those sentences. This is partly because people cannot agree on what all the valid sentences in English are.}} and relies a good deal on us as people who can read English.} +\\* +{無論如何,透過將最後一句話作為悖論,我們將其解讀為英語。這不是 AdHoc1 的一部分,並且需要將 AdHoc1 表示式擴展以應用於英語。但是大多數AdHoc1表示式不是英語,例如" ticillllll eee",因此此擴展是非常不正式的\footnote{實際上,沒有形式語言可以用英語產生所有有效的句子且全部僅有這些句子。部分的原因是因為人們無法就英語的所有有效句子達成共識。}且很依賴可以閱讀英語的我們。} + +{\color{gray}There are some other patterns to note (or oddities, if you prefer): you cannot form the empty expression (because of rule 3), you can't write more than one line (there is no newline character), there are no delimiters so you cannot do punctuation. All one has so far {\color{cyan}with with} AdHoc1 is {\color{cyan}a a} set of rules for {\color{cyan}making}} +\\* +{還有其他一些模式要注意 (或怪事,如果你喜歡如此說): 你不能組成空表示式 (由於規則3), 你不能寫超過一行 (沒有換行字元),沒有定界符,因此你不能做標點。到目前為止,所有人在 AdHoc1 有的是一組規則來製作} + +{\color{gray}Let us also note that AdHoc1 cannot be a computer language, because it has no way of making the computer do anything. For that, there needs to be a number of expressions in the language that cause something to happen inside the computer. An example in Julia is the \codequote{println} function. In fact both lines of code in your first computer program makes something happen in or via the computer. Most of the details of this is hidden from the user of Julia---and this is one of the reasons for choosing Julia as a first programming language to learn.} +\\* +{我們同時還要注意 AdHoc1不能是電腦語言,因為它無法讓電腦做任何事情。為此,語言中需要有許多表示式,這些表示式能讓電腦內發生某些事情。Julia中的一個範列是\codequote{println}函數。實際上,你的第一個電腦程式中的兩行代碼都可以在電腦中或透過電腦中發生。大多數的細節對 Julia 的使用者都隱藏起來了---這是學習電腦語言時選擇 Julia 作為第一個語言的原因之一。} + +\section*{{\color{gray}Programming, poetry and truth} +\\* +{程式設計,詩歌和真理}} + +\begin{quote} +{\color{gray} 'Beauty is truth, truth beauty,---that is all \\ + Ye know on earth, and all ye need to know.' \hspace{3em} (Keats) +} +\\* +{ '美即是真,真即是美, \\ +---這是你們在世上所知道的和應該知道的一切。' \hspace{3em} (濟慈) +} +\end{quote} + +{\color{gray}As we have repeatedly seen, a programming language like Julia allows you make many, many expressions. When you choose what names your variables are to have, which functions to employ, how to structure the logical operators in your program, and so on, you are using the language to express yourself. You are doing much the same as a poet.} +\\* +{正如我們一再看到的那樣, Julia這樣的程式設計語言讓你可以做出許多許多表示式。當你選擇要如何命名變數,要使用什函數,如何建構程式中的邏輯運算子等等時,你正在使用語言來表達自己。你做的與詩人大致相同。} + +{\color{gray}Moreover, you cause things to happen: certain numbers are calculated, pictures are drawn, documents are printed. A poet aims at different effects: reactions from readers/listeners, memorable descriptions, catching the mood. But like a poet, the programmer is using their skill to achieve definite purposes.} +\\* +{此外,你讓一些事情發生:計算某些數字,繪製圖片,並列印文件。一位詩人的目標是不同的影響:讀者/聽眾的反應,令人難忘的描述,引發情緒。但是像詩人一樣,程式設計師正在利用他們的技能來實現明確的目的。} + +{\color{gray}Let us not forget truth: it is central to logic, as we saw above. Computer programs utterly rely on the programmer keeping a very strict eye on whether their logic maintains truth. Paraphrasing Keats, one might say: ``Code is truth, truth code,---that is all you need at the keyboard''.} +\\* +{讓我們不要忘記真理:正如我們在上面看到的那樣,這對於邏輯是核心。電腦程式完全依靠程式設計師非常嚴格地關注他們的邏輯是否保持真理。解碼濟慈,可能會說:``碼即是真,真即是碼,---這就是你在鍵盤上所需要的一切''。} + +{\color{gray}The kind of truth that is embodied in fine pottery is not same as the truth in beautiful poetry, and the truth that is captured in a computer program is far from both of these. But in the end, all three these forms use the expressive power of the medium to get at truth.} +\\* +{體現在精美陶器中的真理與美麗詩歌中的真理不同,電腦程式中捕獲的真理遠非這兩者。但是最後,這三種形式都使用媒介的表達力來實現真理。} + +{\color{gray}Programmers are, in that sense, like artists and poets\footnote{{\color{gray}But also like storytellers, stand-up comedians, composers and basket-weavers. All of these aim at certain effects which in some sense set a standard of truth. }}.} +\\* +{從這個意義上來說,程式設計師像藝術家和詩人一樣\footnote{但也像講故事的人,站立喜劇演員,作曲家和籃子編織師一樣。所有這些目的都是針對某種意義上樹立真理標準的某些效果。}.} + +\section*{{\color{gray}Review and summary} +\\* +{回顧與總結}} + +\begin{description} + \setlength{\itemindent}{-12pt} + \item[*] {\color{gray}Logic (in this course) is the study of correct forms of reasoning} +\\* +{邏輯(在本課程中)是對正確推理形式的研究} + \item[*] {\color{gray}Formal logic is the use of formulae to do logic} +\\* +{形式邏輯是使用公式來執行邏輯} + \item[*] {\color{gray}Truth tables spell out exactly how logical operators work} +\\* +{真值表準確地闡明了邏輯運算子的運作方式} + \item[*] {\color{gray}To be useful, a formal logic must be part of a formal language} +\\* +{為了有用,形式邏輯必須是正式語言的一部分} + \item[*] {\color{gray}A formal language is a set of symbols and a set of rules for combining them} +\\* +{形式語言是一組符號及一組合併它們的規則} + \item[*] {\color{gray}Julia is itself a formal language} +\\* +{Julia 本身就是一種形式語言} + \item[*] {\color{gray}A programming language is capable of endless variety of expression} +\\* +{程式設計語言可以有無窮的各種{\color{blue}表示式}} + \item[*] {\color{gray}Writing code is a creative as much as writing poetry or music.} +\\* +{編寫代碼與寫詩歌或音樂一樣是創作。} +\end{description} +\end{document} +% 012 \ No newline at end of file diff --git a/Course Notes/Translation/Traditional Chinese/Week 1/README.md b/Course Notes/Translation/Traditional Chinese/Week 1/README.md new file mode 100644 index 0000000..ca9fe47 --- /dev/null +++ b/Course Notes/Translation/Traditional Chinese/Week 1/README.md @@ -0,0 +1,26 @@ +## 第 1 週筆記 + +課程開始! + +這裹總共有九課 PDF,都是基本的。我們強烈建議你按順序學習(`L1W1_MinimalWorkingExample.pdf` 是第一個)。 + +在本週結束(當然,這可能需要比一個日曆週更長或更短的時間來完成)你應該會具備 Julia REPL 的工作知識,理解程式設計是藉由*應用形式邏輯(applied formal logic)*做*形式語言(formal language)*的*表達性使用(expressive use)*,並且能夠開始在 Julia 中編寫代碼。 + +### 課程影片連結 +[第 1 課](https://www.youtube.com/watch?v=L0TDqQCHigg&list=PLP8iPy9hna6Qpx0MgGyElJ5qFlaIXYf1R&index=2) + +[第 2 課](https://www.youtube.com/watch?v=60pReAo0kL0&list=PLP8iPy9hna6Qpx0MgGyElJ5qFlaIXYf1R&index=3) + +[第 3 課](https://www.youtube.com/watch?v=fSxJ0rdrpeY&list=PLP8iPy9hna6Qpx0MgGyElJ5qFlaIXYf1R&index=4) + +[第 4 課](https://www.youtube.com/watch?v=ZuALresPQY4&list=PLP8iPy9hna6Qpx0MgGyElJ5qFlaIXYf1R&index=5) + +[第 5 課](https://www.youtube.com/watch?v=JuJGBx1EBkQ&list=PLP8iPy9hna6Qpx0MgGyElJ5qFlaIXYf1R&index=6) + +[第 6 課](https://www.youtube.com/watch?v=dJ4PnBXkzXI&list=PLP8iPy9hna6Qpx0MgGyElJ5qFlaIXYf1R&index=7) + +[第 7 課](https://www.youtube.com/watch?v=LLpeFe0OaiY&list=PLP8iPy9hna6Qpx0MgGyElJ5qFlaIXYf1R&index=8) + +[第 8 課](https://www.youtube.com/watch?v=plSsEoRojr0&list=PLP8iPy9hna6Qpx0MgGyElJ5qFlaIXYf1R&index=9) + +[第 9 課](https://www.youtube.com/watch?v=xIJJ-dcVBpQ) diff --git a/Course Notes/Translation/Traditional Chinese/Week 2/README.md b/Course Notes/Translation/Traditional Chinese/Week 2/README.md new file mode 100644 index 0000000..0095d3f --- /dev/null +++ b/Course Notes/Translation/Traditional Chinese/Week 2/README.md @@ -0,0 +1,17 @@ +## 第 2 週筆記 + +這週有六節課。 內容還是很基礎的,符合“小步走(Small Steps)”和“不留空隙(Leave No Gaps)”的口號,但 Julia 的特色會被清晰地展現出來。 + +### 課程影片連結 + +[第 1 課](https://www.youtube.com/watch?v=Ums8TvvBd48&list=PLP8iPy9hna6Qpx0MgGyElJ5qFlaIXYf1R&index=11) + +[第 2 課](https://www.youtube.com/watch?v=GHWfIz5s7uY&list=PLP8iPy9hna6Qpx0MgGyElJ5qFlaIXYf1R&index=12) + +[第 3 課](https://www.youtube.com/watch?v=wVSoKw3abaU&list=PLP8iPy9hna6Qpx0MgGyElJ5qFlaIXYf1R&index=13) + +[第 4 課](https://www.youtube.com/watch?v=D9zqoB2b1SI&list=PLP8iPy9hna6Qpx0MgGyElJ5qFlaIXYf1R&index=14) + +[第 5 課](https://www.youtube.com/watch?v=ULgawRM-4nU&list=PLP8iPy9hna6Qpx0MgGyElJ5qFlaIXYf1R&index=15) + +[第 6 課](https://www.youtube.com/watch?v=ZLACmxWXiy8&list=PLP8iPy9hna6Qpx0MgGyElJ5qFlaIXYf1R&index=16) diff --git a/Course Notes/Translation/Traditional Chinese/Week 3/README.md b/Course Notes/Translation/Traditional Chinese/Week 3/README.md new file mode 100644 index 0000000..9807325 --- /dev/null +++ b/Course Notes/Translation/Traditional Chinese/Week 3/README.md @@ -0,0 +1,17 @@ +## 第 3 週筆記 + +本週的五節課完成你對基本 Julia 的學習。在結束時,你應該具備函數(function)、多重分派(multiple dispatch)、分支(branching)和迭代(iteration)的基礎知識。這些應該為你提供編寫 Julia 代碼的絕佳起始平台。 + +#### 當然,這是除了能夠在 Julia 中編寫有效的表達式、在純文字文件中編寫代碼(code)並運行(run)它們以及除錯(debugging)代碼之外。 + +### 課程影片連結 + +[第 1 課](https://www.youtube.com/watch?v=ICMWs31Ky80&list=PLP8iPy9hna6Qpx0MgGyElJ5qFlaIXYf1R&index=17) + +[第 2 課](https://www.youtube.com/watch?v=CTscZ5zEfQM&list=PLP8iPy9hna6Qpx0MgGyElJ5qFlaIXYf1R&index=18) + +[第 3 課](https://www.youtube.com/watch?v=IciH1VQquzA&list=PLP8iPy9hna6Qpx0MgGyElJ5qFlaIXYf1R&index=19) + +[第 4 課](https://www.youtube.com/watch?v=Xdu7g-Jx_08&list=PLP8iPy9hna6Qpx0MgGyElJ5qFlaIXYf1R&index=20) + +[第 5 課](https://www.youtube.com/watch?v=jQnMrZGWeQA&list=PLP8iPy9hna6Qpx0MgGyElJ5qFlaIXYf1R&index=21) diff --git a/Course Notes/Translation/Traditional Chinese/Week 4/README.md b/Course Notes/Translation/Traditional Chinese/Week 4/README.md new file mode 100644 index 0000000..93f914c --- /dev/null +++ b/Course Notes/Translation/Traditional Chinese/Week 4/README.md @@ -0,0 +1,15 @@ +## 第 4 週筆記 + +在這最後一週,你將看到一些創造力並在行動中發揮作用,正如第 1 週第 4 課中所承諾的那樣。 + +這將佔用了前三節課,然後是第四課,沒有新的 Julia 內容,只是提供了片刻的反思。 + +### 課程影片連結 + +[第 1 課](https://www.youtube.com/watch?v=1U3h6Tb0i78&list=PLP8iPy9hna6Qpx0MgGyElJ5qFlaIXYf1R&index=22) + +[第 2 課](https://www.youtube.com/watch?v=PerqyXWdRJQ&list=PLP8iPy9hna6Qpx0MgGyElJ5qFlaIXYf1R&index=23) + +[第 3 課](https://www.youtube.com/watch?v=Z43TRLsWRs8&list=PLP8iPy9hna6Qpx0MgGyElJ5qFlaIXYf1R&index=24) + +[第 4 課](https://www.youtube.com/watch?v=v3aPcIrXWZQ&list=PLP8iPy9hna6Qpx0MgGyElJ5qFlaIXYf1R&index=25) diff --git a/Course Notes/Translation/Traditional Chinese/linuxthunar1.png b/Course Notes/Translation/Traditional Chinese/linuxthunar1.png new file mode 100644 index 0000000..c4ccb91 Binary files /dev/null and b/Course Notes/Translation/Traditional Chinese/linuxthunar1.png differ diff --git a/Course Notes/Translation/Traditional Chinese/linuxthunar2.png b/Course Notes/Translation/Traditional Chinese/linuxthunar2.png new file mode 100644 index 0000000..baf3fde Binary files /dev/null and b/Course Notes/Translation/Traditional Chinese/linuxthunar2.png differ diff --git a/Course Notes/Week 3/README.md b/Course Notes/Week 3/README.md index 809166a..ae2c473 100644 --- a/Course Notes/Week 3/README.md +++ b/Course Notes/Week 3/README.md @@ -1,6 +1,6 @@ ## Week 3 -The five lessons of this week complete your study of basic Julia. At the end of it, you should have the basics of functions, multiple dispatch, branching, and iteration. These should give you an excellenyt starting platform for writing Julia code. +The five lessons of this week complete your study of basic Julia. At the end of it, you should have the basics of functions, multiple dispatch, branching, and iteration. These should give you an excellent starting platform for writing Julia code. #### Of course, this is in addition to being able to write valid expressions in Julia, write your code in plain text files and run them, and debugging your code. diff --git a/Course Notes/Week 4/README.md b/Course Notes/Week 4/README.md index 2a31846..39031ae 100644 --- a/Course Notes/Week 4/README.md +++ b/Course Notes/Week 4/README.md @@ -1,6 +1,6 @@ ## Week 4 -In this final week, you get to see some creativity and play in action, as promissed in Lesson 4 of Week 1. +In this final week, you get to see some creativity and play in action, as promised in Lesson 4 of Week 1. That takes up the first three lessons, and then there's a fourth lesson with no new Julia material, but rather just offering a moment of reflection.