owned this note
owned this note
Published
Linked with GitHub
# 程式語言期末考博物館(二館)
## [程式語言期中考博物館(一館)](https://hackmd.io/@frakw/Hkj_eqkOF)
---
## 注意事項
# <font color="#f00">部分有再修正過,請大家要再以細看,第6大題最後一題</font>
---
* Pass by value:是指主程式呼叫函數時,系統會將實際參數的數值傳遞並複製給函數中相對應的形式參數,形式參數值的變化不會影響主程式的實際參數的數值。
```
main( ) {
int x = 10;
func(x);
}
func(int y) {
y = 100;
}
```
* Pass by reference:是表示在呼叫函數時,系統並沒有分配實際的位址給函數的形式參數,而是將實際參數的位址直接傳遞給所對應的形式參數,形式參數值的變化會改變實際參數的數值。
```
main( ) {
int x = 10;
func(&x);
}
func(int *y) {
*y = 100;
}
```
* Pass by name:主程式呼叫副程式時,將主程式的參數名稱傳給副程式的參數,並取代副程式中相對應的所有參數名稱。
* Pass-by-value-result:呼叫程式呼叫被呼叫程式時,將呼叫程式中實際參數的值,傳給被呼叫程式中對應的型式參數,當被呼叫程式執行完畢時,會將被呼叫程式中型式參數的值,傳回給呼叫程式中對應的實際參數。
* Unconditional branch:非條件性的分支,不做判斷就直接跳到某一個 label。 例:goto、break……
* Horn clause:The clausal form of logic programming languages propositions. It’s either headed or headless.
* headed:在某種條件成立的條件下才為真的事情; grandfather(X,Y):-father(X,F),father(F,Y). is headed horn clause (用來描述事實之間的邏輯關係,即必須在某種條件成立的條件下才為真的事情。)
* headless:聲明一個事實。 father(X,Y). is headless horn clause (用來描述個體的性質或個體與個體之間的關係。);
* Actual parameter:實際呼叫函數時所提供的參數。
* Lazy evaluation:
* 表示式的執行可拖延到真正需要執行時才執行。
* 當我們真的需要用到值的時候才去求值
* Backward chaining:是由終點出發,回頭尋找起點,某些情況下,我們不清楚「規則」,不了解問題發生的原因,但知道其結果。只能找到小的set的答案
* Pre-test logical loop statement:執行loop時會先測試<條件>是否成立,當<條件>成立時,才會進入迴圈敘述執行,否則跳出迴圈結構。
* Formal parameter:被呼叫副程式的參數串列即稱為型式參數,又稱為虛擬參數(dummy parameter)。
* Lambda expressions:是用來描述nameless函數,表示方法則是將參數放在表示式後方,範例: ((x) x * x * x)(2)=8。
* Operator associativity rule | Operator precedence rule:
* 定義同一優先級的operator之間關聯性規則,如左關聯、右關聯
* 運算子優先度一樣時,要決定如何運算,如從左到右、從右到左
* Ex:A+B+C+D
(((A+B)+C)+D) 左關聯
(A+(B+(C+D))) 右關聯
* **Overloaded operator**:給予operator多種意義、用途
* Stack-dynamic allocation:在run time時候從stack分配出一塊動態大小的位置。
* CAR & CDR in LISP
CAR : return the first element of a list
e.g. CAR(A B C) => return A
CDR : return the other elements of a list except for the first one
e.g. CDR(A B C) => return(B C)
* Short-circuit evaluation:
* 是一種邏輯運算符的求值策略。只有當第一個運算數的值無法確定邏輯運算的結果時,才對第二個運算數進行求值。
* means that when evaluating boolean expressions (logical AND and OR) you can stop as soon as you find the first condition which satisfies or negates the expression.

* Declarative programming language:是一種程式設計範式,與命令式程式設計相對立。它描述目標的性質,讓電腦明白目標,而非流程。
* Shallow Binding:所使用自由變數,在執行函數時的環境所決定
* Deep Binding:所使用自由變數,在定義函數時的環境所決定
* Referential transparency:程式中任意兩處具有相同輸入值的函數調用能夠互相置換,而不影響程式的運作。

## (第2大題)
* **2006**

* a. ( ( ( x * y )<sup>1</sup> - 6)<sup>2</sup> + z)<sup>3<sup>
* b. ( ( -x )<sup>1</sup> || ( (w=z)<sup>2</sup> && z )<sup>3</sup> )<sup>4</sup>
* **2008 Spring**

* a. ( ( ( x<=y )<sup>3</sup> && ( !w )<sup>1</sup> )<sup>5</sup> || ( z >= ( -10 )<sup>2</sup> )<sup>4</sup> )<sup>6</sup>
* b. ( ( ( x * y )<sup>1</sup> mod ( 1 / c )<sup>2</sup> )<sup>3</sup> mod z )<sup>4</sup>
* **2008 Fall**

* a. ( ( -x )<sup>1</sup> ) || ( ( w = y )<sup>2</sup> && z )<sup>3</sup> )<sup>4</sup>
* b. ( ( ( x * y )<sup>1</sup> mod ( 1 / c )<sup>2</sup> )<sup>3</sup> mod z )<sup>4</sup> **
* **2009 Fall**

* a. ( ( -x )<sup>2</sup> || ( ( w = y )<sup>3</sup> && ( z-- )<sup>1</sup> )<sup>4</sup> )<sup>5</sup>
* b. ( ( x * y )<sup>2</sup> mod ( 1 / ( c mod z )<sup>1</sup> )<sup>3</sup> )<sup>4</sup>
* **2010**

* a. ( ( ( --x )<sup>1</sup> >= w )<sup>4</sup> || ( y && ( ( z % x )<sup>2</sup> * w )<sup>3</sup> )<sup>5</sup> )<sup>6</sup>
* b. ( ( ( x * ( y mod 1 )<sup>1</sup> )<sup>2</sup> / c )<sup>3</sup> mod z )<sup>4</sup>
* **2019**

* a. ( ( ( w / x )<sup>2</sup> % y )<sup>3</sup> || ( z && ( ( a-- )<sup>1</sup> < b )<sup>4</sup> )<sup>5</sup> )<sup>6</sup>
* b. ( ( ( a - w )<sup>2</sup> mod ( z * y )<sup>1</sup> )<sup>3</sup> mod a )<sup>4</sup>
## (第3大題)
* **2006**
無此題型的題目
* **2008 Spring**
無此題型的題目
* **2008 Fall**
無此題型的題目
* **2009 Fall**
無此題型的題目
* **2010**

* **2019**

## (第4大題)

* **2006**

* Passed by value: {1, 2, 3}
* Passed by reference: {1, 5, 8}
* Passed by value-result: {1, 5 , 8}
* **2008 Spring**

* Passed by value: x=5, y=15
* Passed by reference: x=30, y=15
* Passed by name: x=32, y=15
* **2008 Fall**

* Passed by value: {1, 2, 3}
* Passed by reference: {1, 5, 8}
* Passed by name: {1, 5, 8}
* **2009 Fall**

* Passed by value: x=5, y=15
* Passed by reference: x=45, y=15
* Passed by name: x=37, y=7
* **2010**

* Passed by value: {1, 2, 3}
* Passed by reference: {4, 2, 7}
* Passed by name: {4, 2, 7}
* **2019**

* Passed by value: x={3, 2, 1}, y=0
* Passed by reference: x={6, 2, 1}, y=3
* Passed by name: x={6, 2, 1}, y=3
## (第5大題)
* **2008 Spring**



* **2008 Fall**


* **2009 Fall**




* **2019**


## (第6大題)
* **2010**

* **2019** <font color="#f00">此題應該有改錯</font>

