Skip to content

Commit 998aff8

Browse files
authored
Merge pull request #325 from d4v1d03/main
added conversion of list of lists to a single list
2 parents b2336ca + a420b0c commit 998aff8

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

docs/user_docs/support/faq-kcl.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2517,7 +2517,7 @@ raw_s: Hello ${worldString}
25172517

25182518
For lambda(s),KCL automatically infers the return value type in the function body, although we can explicitly specify it. An example KCL code over here is:
25192519

2520-
``KCL
2520+
```KCL
25212521
f1 = lambda t: Type1 {
25222522
Type2 {}
25232523
} # The type of f1 is (Type1) -> Type2
@@ -2526,3 +2526,24 @@ f2 = lambda t: Type1 -> Type2 {
25262526
Type2 {}
25272527
} # The type of f2 is (Type1) -> Type2
25282528
```
2529+
2530+
## 60. How to convert a list of lists to a single list in KCL?
2531+
2532+
To convert a list of lists into a single list, we use the `sum()` function. For example if we have a number of lists such as [[1,2],[3,4]], [5,6], we use the KCL code given below to convert these three lists into a single list:
2533+
2534+
```KCL
2535+
final_list = sum([[1,2],[3,4]],[5,6])
2536+
```
2537+
2538+
The above KCL code gives the output:
2539+
2540+
```bash
2541+
final_list:
2542+
- 5
2543+
- 6
2544+
- 1
2545+
- 2
2546+
- 3
2547+
- 4
2548+
```
2549+

0 commit comments

Comments
 (0)