Skip to content

added conversion of list of lists to a single list #325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
```