回答編集履歴
2
typo
test
CHANGED
@@ -8,25 +8,41 @@
|
|
8
8
|
|
9
9
|
val listC = listOf(3, 2, 5, 15, 7, 19, 20, 4, 13)
|
10
10
|
|
11
|
+
```
|
11
12
|
|
12
13
|
|
14
|
+
|
13
|
-
リストAのうちBに含まれており、
|
15
|
+
> リストAのうちBに含まれており、
|
16
|
+
|
17
|
+
```shell
|
14
18
|
|
15
19
|
>>> listA.intersect(listB)
|
16
20
|
|
17
21
|
res13: kotlin.collections.Set<kotlin.Int> = [4, 6, 19, 13, 20]
|
18
22
|
|
23
|
+
```
|
19
24
|
|
20
25
|
|
26
|
+
|
21
|
-
リストAのうちBに含まれており、Cに含まれていない
|
27
|
+
> リストAのうちBに含まれており、Cに含まれていない
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
```shell
|
22
32
|
|
23
33
|
>>> listA.intersect(listB).subtract(listC)
|
24
34
|
|
25
35
|
res14: kotlin.collections.Set<kotlin.Int> = [6]
|
26
36
|
|
37
|
+
```
|
27
38
|
|
28
39
|
|
40
|
+
|
29
|
-
新しいリストDを作成
|
41
|
+
> 新しいリストDを作成
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
```shell
|
30
46
|
|
31
47
|
>>> val listD = listA.intersect(listB).subtract(listC).toList()
|
32
48
|
|
1
追記
test
CHANGED
@@ -24,4 +24,14 @@
|
|
24
24
|
|
25
25
|
res14: kotlin.collections.Set<kotlin.Int> = [6]
|
26
26
|
|
27
|
+
|
28
|
+
|
29
|
+
新しいリストDを作成
|
30
|
+
|
31
|
+
>>> val listD = listA.intersect(listB).subtract(listC).toList()
|
32
|
+
|
33
|
+
>>> listD
|
34
|
+
|
35
|
+
res18: kotlin.collections.List<kotlin.Int> = [6]
|
36
|
+
|
27
37
|
```
|