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 秒完成。

想多做几道同类题目?立即开始练习这个课题,边做边批改。

立即练习