Skip to content

Commit

Permalink
Merge pull request #325 from d4v1d03/main
Browse files Browse the repository at this point in the history
added conversion of list of lists to a single list
  • Loading branch information
Peefy authored Mar 28, 2024
2 parents b2336ca + a420b0c commit 998aff8
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion docs/user_docs/support/faq-kcl.md
Original file line number Diff line number Diff line change
Expand Up @@ -2517,7 +2517,7 @@ raw_s: Hello ${worldString}

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:

``KCL
```KCL
f1 = lambda t: Type1 {
Type2 {}
} # The type of f1 is (Type1) -> Type2
Expand All @@ -2526,3 +2526,24 @@ f2 = lambda t: Type1 -> Type2 {
Type2 {}
} # The type of f2 is (Type1) -> Type2
```

## 60. How to convert a list of lists to a single list in KCL?

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:

```KCL
final_list = sum([[1,2],[3,4]],[5,6])
```

The above KCL code gives the output:

```bash
final_list:
- 5
- 6
- 1
- 2
- 3
- 4
```

0 comments on commit 998aff8

Please sign in to comment.