• 検索結果がありません。

complang1 2002 02 04

N/A
N/A
Protected

Academic year: 2018

シェア "complang1 2002 02 04"

Copied!
1
0
0

読み込み中.... (全文を見る)

全文

(1)

2002-02-04 担当教官: 國島

2001 年度計算機言語 I 定期試験

1. 次の問いに答えよ。

(a) 次の ML の式の型を答えよ。 i. [[1, 2], nil, [3]]

ii. (1.0, [(3, “char′′), (2, “string′′)])

(b) リスト L = [3, 5, 2, 4] に対して、次の式を評価した結果を答えよ。評価できない場合は

「値なし」と答え、その理由を述べよ。 i. hd(tl(L))

ii. tl(hd(L))

2. 次の関数を ML で実装せよ。

(a) 整数のリストの先頭から 2 つずつ要素を組にしたリストを求める関数 combine(L)。た とえば、combine([1, 3, 4, 5]) = [(1, 3), (4, 5)] となる。元のリストの要素数が奇数の場合 は、最後に0 を補うこととする。

(b) 2 分木 (図 1) の要素を前順序 (preorder) で並べたリストを返す関数 preOrder。中順序 とは深さ優先探索の一種で、自分自身をたどってから部分木をたどる探索順序である。 3. 集合 S の部分集合すべて (空集合や S 自身も含む) からなる集合を S の超集合 (power set) と

いう。ここでは集合をリストで表現するものとし、超集合を計算する関数をML で実装する ことを考える。

(a) 集合 S = [2, 4, 5] の超集合を書け。

(b) 集合の集合 s を考える。このとき、s の要素すべてに a を挿入する関数 consset(a, s) を 実装せよ。たとえば、consset(1, [[2, 3], [4, 5, 6], nil]) = [[1, 2, 3], [1, 4, 5, 6], [1]] となる。 (c) 整数の集合 S からその超集合を求める関数 powerset(S) を、前述の関数 consset を用

いて実装せよ。S はint list だとしてよい。 datatype ’label btree =

Empty |

Node of ’label * ’label btree * ’label btree;

(* btree の例 *) val t = Node("ML",

Node("as",

Node("a", Empty, Empty), Node("in", Empty, Empty)), Node("types", Empty, Empty));

図1: 2 分木を表すデータ構造とその例

参照

関連したドキュメント

約 4 ~約 60km/h 走行時 作動条件 対車両 ※1.

[r]

PowerSever ( PB Edition ) は、 Appeon PowerBuilder 2017 R2 日本語版 Universal Edition で提供される PowerServer を示しており、 .NET IIS

Appeon and other Appeon products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of Appeon Limited.. SAP and other SAP

Program’s name number 1 02:30 203°F 300G. 300G

項目 MAP-19-01vx.xx AL- ( Ⅱシリーズ初期データ編集ソフト) サポート OS ・ Microsoft Windows 7 32 ( ビット版). ・ Microsoft Windows Vista x86

There is a bijection between left cosets of S n in the affine group and certain types of partitions (see Bjorner and Brenti (1996) and Eriksson and Eriksson (1998)).. In B-B,

“Breuil-M´ezard conjecture and modularity lifting for potentially semistable deformations after