AQA A Level · Computer Science 7517

函數式程式設計中的列表:練習題

5 條多項選擇題即時批改,另有 5 條文字題附完整解題步驟,全部圍繞「函數式程式設計中的列表」。

10 條題目23 免費,無需登記
第 1 題
1

In functional programming, a list can be defined as a concatenation of two specific components. What are these two components called?
Example: in Haskell, the list \([4, 3, 5]\) can be written as \(4:[3, 5]\).

第 2 題
1

Given the list \(L = [10, 20, 30, 40]\), what would be the result of the operation prepend \(5\) to \(L\)?

第 3 題
1

Let \(L = [5, 12, 18, 21]\). Consider a recursive function f:
\(f([]) = 0\)
\(f(head:tail) = 1 + f(tail)\)

What is the result of applying \(f(L)\)?

第 4 題
1

If a list \(L\) is defined as \(7:[2, 9, 1]\), what is the result of the operation that returns the tail of the list?

第 5 題
1

In functional list processing, how is the list \([1, 2, 3, 4]\) represented using recursive construction with the empty list symbol \([]\)?

第 6 題
2

What is the resulting list when you prepend the item \( 5 \) to the list \( [12, 15] \)?

先自己寫一次答案,再對照解題步驟。

第 7 題
3

A programmer uses a function to test for an empty list. If the input is \( head:tail \), what is the Boolean result of this test?

先自己寫一次答案,再對照解題步驟。

第 8 題
5

A programmer is using Lists in functional programming. If a list is constructed as \( L = x:xs \), describe the result of the operation head(tail(tail([1, 2, 3, 4]))).

先自己寫一次答案,再對照解題步驟。

第 9 題
3

A list in a functional language is often represented as a head and a tail.

(a) Define what is meant by the 'head' and 'tail' of a list.
(b) Given the list \( L = [10, 20, 30, 40] \), show how this list would be represented using the construction operator (often denoted as a colon \( : \) in Haskell) and the empty list symbol \( [] \).

先自己寫一次答案,再對照解題步驟。

第 10 題
5

A programmer is writing a functional program to process a list of integers.

(a) Write a recursive definition for a function length(L) that returns the number of elements in a list \( L \). You should use the concepts of head, tail, and empty list.
(b) Trace your function with the list \( [7, 3] \), showing each recursive call.

先自己寫一次答案,再對照解題步驟。

* thinka提供的內容由AI生成,可能並非總是準確或最新。請將其用作輔助資源,並與官方材料進行核實。

你已看過標準答案,接下來輪到批改你的答案。

這一頁可以告訴你好答案的樣子,卻無法指出你的答案欠缺什麼。thinka 按真實評分準則批改你的文字答案,約 15 秒完成。

想多做幾條同類題目?立即開始練習呢個課題,即做即批改。

立即練習