Skip to content

chore: sync faq documents between the latest doc and v0.8 doc #334

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
Apr 15, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion docs/user_docs/support/faq-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ If you don't want to perform these steps every time you open an application, you
Open the terminal and run the following command:

```shell
xattr -rd com.apple.quarantine /path/to/kcl
xattr -d com.apple.quarantine /path/to/kcl
```

Where `/path/to/kcl` is the complete path of the kcl application. After running the command, the application will be added to the whitelist and Gatekeeper will no longer prevent it from running.
Expand Down
17 changes: 8 additions & 9 deletions docs/user_docs/support/faq-kcl.md
Original file line number Diff line number Diff line change
Expand Up @@ -2499,7 +2499,7 @@ alice: Person = config

In KCL, we can use `${..}` for string interpolation. But in some cases, we don't want to escape it. Therefore, we use create a raw string by prefixing the string literal with `'r'` or `'R'`. An example KCL code over here is:

```KCL
```python
worldString = "world"
s = "Hello ${worldString}"
raw_s = r"Hello ${worldString}"
Expand All @@ -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
```python
f1 = lambda t: Type1 {
Type2 {}
} # The type of f1 is (Type1) -> Type2
Expand All @@ -2529,25 +2529,24 @@ f2 = lambda t: 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:
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])
```python
final_list = sum([[1,2],[3,4],[5,6]], [])
```

The above KCL code gives the output:

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

## 61. What does `version: "v1" = "v1"` mean?

The first `"v1"` over here denotes that the type of version is of string literal type. The second `"v1"` denotes that the default value of version is `"v1"`.

The first `"v1"` over here denotes that the type of the variable `version` is of string literal type. The second `"v1"` denotes that the default value of the variable `version` is `"v1"`.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ MacOS 提示无法打开 "kcl",因为 Apple 无法检查其是否包含恶意
打开终端并输入以下命令:

```shell
xattr -rd com.apple.quarantine /path/to/kcl
xattr -d com.apple.quarantine /path/to/kcl
```

其中,/path/to/kcl 是 kcl 应用程序的完整路径。运行命令后,应用程序将被添加到白名单中,Gatekeeper 将不再阻止其运行。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2519,3 +2519,40 @@ worldString: world
s: Hello world
raw_s: Hello ${worldString}
```

## 59. 在 KCL 中如何推断 lambda 函数的返回值类型?

对于 Lambda 函数,KCL 可以自动推断函数体中的返回值类型,尽管我们也可以明确指定它。下面是一个 KCL 代码示例:

```python
f1 = lambda t: Type1 {
Type2 {}
} # f1 的类型是 (Type1) -> Type2
f2 = lambda t: Type1 -> Type2 {
Type2 {}
} # f2 的类型是 (Type1) -> Type2, 在这个例子中,我们显式指定了返回值类型为 Type2
```

## 60. 在 KCL 中如何将列表的列表转换为单个列表?

要将列表的列表转换为单个列表,我们可以使用 sum() 函数。例如,如果我们有多个列表,比如 `[[1,2],[3,4],[5,6]]`,我们可以使用以下 KCL 代码将这三个列表转换为单个列表:

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

上述 KCL 代码的输出如下:

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

## 61. KCL 代码片段 `version: "v1" = "v1"` 是什么意思?

这里的第一个 `"v1"` 表示变量 `version` 的类型是字符串字面类型。第二个 `"v1"` 表示变量 `version` 的默认值是 "v1"。
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ MacOS 提示无法打开 "kcl",因为 Apple 无法检查其是否包含恶意
打开终端并输入以下命令:

```shell
xattr -rd com.apple.quarantine /path/to/kcl
xattr -d com.apple.quarantine /path/to/kcl
```

其中,/path/to/kcl 是 kcl 应用程序的完整路径。运行命令后,应用程序将被添加到白名单中,Gatekeeper 将不再阻止其运行。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2519,3 +2519,40 @@ worldString: world
s: Hello world
raw_s: Hello ${worldString}
```

## 59. 在 KCL 中如何推断 lambda 函数的返回值类型?

对于 Lambda 函数,KCL 可以自动推断函数体中的返回值类型,尽管我们也可以明确指定它。下面是一个 KCL 代码示例:

```python
f1 = lambda t: Type1 {
Type2 {}
} # f1 的类型是 (Type1) -> Type2
f2 = lambda t: Type1 -> Type2 {
Type2 {}
} # f2 的类型是 (Type1) -> Type2, 在这个例子中,我们显式指定了返回值类型为 Type2
```

## 60. 在 KCL 中如何将列表的列表转换为单个列表?

要将列表的列表转换为单个列表,我们可以使用 sum() 函数。例如,如果我们有多个列表,比如 `[[1,2],[3,4],[5,6]]`,我们可以使用以下 KCL 代码将这三个列表转换为单个列表:

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

上述 KCL 代码的输出如下:

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

## 61. KCL 代码片段 `version: "v1" = "v1"` 是什么意思?

这里的第一个 `"v1"` 表示变量 `version` 的类型是字符串字面类型。第二个 `"v1"` 表示变量 `version` 的默认值是 "v1"。
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ If you don't want to perform these steps every time you open an application, you
Open the terminal and run the following command:

```shell
xattr -rd com.apple.quarantine /path/to/kcl
xattr -d com.apple.quarantine /path/to/kcl
```

Where `/path/to/kcl` is the complete path of the kcl application. After running the command, the application will be added to the whitelist and Gatekeeper will no longer prevent it from running.
Expand Down
18 changes: 11 additions & 7 deletions versioned_docs/version-0.8/user_docs/support/faq-kcl.md
Original file line number Diff line number Diff line change
Expand Up @@ -2499,7 +2499,7 @@ alice: Person = config

In KCL, we can use `${..}` for string interpolation. But in some cases, we don't want to escape it. Therefore, we use create a raw string by prefixing the string literal with `'r'` or `'R'`. An example KCL code over here is:

```KCL
```python
worldString = "world"
s = "Hello ${worldString}"
raw_s = r"Hello ${worldString}"
Expand All @@ -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
```python
f1 = lambda t: Type1 {
Type2 {}
} # The type of f1 is (Type1) -> Type2
Expand All @@ -2529,20 +2529,24 @@ f2 = lambda t: 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:
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])
```python
final_list = sum([[1,2],[3,4],[5,6]], [])
```

The above KCL code gives the output:

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

## 61. What does `version: "v1" = "v1"` mean?

The first `"v1"` over here denotes that the type of the variable `version` is of string literal type. The second `"v1"` denotes that the default value of the variable `version` is `"v1"`.