AQA A Level · Computer Science 7517

Writing functional programs:練習問題

その場で採点される選択問題 5 問と、解説つきの記述問題 5 問。すべて「Writing functional programs」からの出題です。

10 問25 無料・登録不要
問 1
1

In Haskell, given the list [10, 20, 30], what is the tail of this list?

問 2
1

What is the result of the following function composition?
Let \(f(x) = x + 1\) and \(g(x) = x^2\).
Find \((g \circ f)(3)\).

問 3
1

Given the following Haskell-style list definition:
myList = [x * 2 | x <- [1..5], x > 2]

What is the final value of myList?

問 4
1

In a functional language like Haskell, if a list is defined as [7, 2, 9], what are the head and tail of this list respectively?

問 5
1

Which functional programming operation is best described as reducing a list of values to a single value by repeatedly applying a combining function?

問 6
2

Identify the result of applying the list operation tail to the Haskell list \([10, 20, 30]\).

まず自分で答えを書いてから、解説と照らし合わせましょう。

問 7
3

Explain the difference between a higher-order function and a standard first-order function.

まず自分で答えを書いてから、解説と照らし合わせましょう。

問 8
5

A list is represented in Haskell notation as head:tail. If a list is defined as \(L = [7]\), state the values of the head and the tail.

まず自分で答えを書いてから、解説と照らし合わせましょう。

問 9
3

Describe the purpose of the following higher-order functions commonly used in functional programming:

(a) map
(b) filter
(c) reduce (also known as fold)

まず自分で答えを書いてから、解説と照らし合わせましょう。

問 10
7

A high-order function foldright (or reduce) is defined. It takes a combining function \( f \), an initial value \( z \), and a list.

Let \( f(x, acc) = x - acc \) and the initial value \( z = 0 \).

(a) Calculate the result of applying this fold operation to the list \( [5, 10, 15] \) using right-associativity: \( f(5, f(10, f(15, 0))) \).
(b) Explain how the result would differ if left-associativity (foldleft) was used with the same function and initial value: \( f(f(f(0, 5), 10), 15) \).
(c) Why is the choice of associativity important for non-commutative operations like subtraction?

まず自分で答えを書いてから、解説と照らし合わせましょう。

※ thinkaのコンテンツはAIにより生成されているため、内容が正確でない場合があります。補助教材としてご使用いただき、公式の教材と合わせてご確認ください。

模範解答は見ました。次はあなたの答案を採点します。

このページは良い答案の形を示せますが、あなたの答案に何が足りないかは教えられません。thinka は実際の採点基準に沿って記述答案を約 15 秒で採点します。

同じような問題をもっと解きたい?このトピックの新しい問題を、解きながら採点。

練習を始める