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