mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-29 20:34:44 +00:00
Merge branch 'main' into python-3.8
This commit is contained in:
commit
2b01ab606b
13 changed files with 49 additions and 34 deletions
|
@ -373,8 +373,8 @@ pub fn which_python() -> String {
|
|||
if res.is_empty() {
|
||||
println!("python not found");
|
||||
std::process::exit(1);
|
||||
} else if res.contains("pyenv") {
|
||||
println!("cannot use pyenv");
|
||||
} else if res.contains("pyenv") && cfg!(windows) {
|
||||
println!("cannot use pyenv-win"); // because pyenv-win does not support `-c` option
|
||||
std::process::exit(1);
|
||||
}
|
||||
res
|
||||
|
|
|
@ -19,4 +19,3 @@ The checks may fail on the first run even if there are no bugs, in which case yo
|
|||
* Editor: Visual Studio Code
|
||||
* VSCode extensions: Rust-analyzer, GitLens, Git Graph, GitHub Pull Requests and Issues, Markdown All in One, markdownlint
|
||||
* OS: Windows 10/11 | Ubuntu 20.04/22.04 | Mac OS Monterey
|
||||
* Others: mold
|
||||
|
|
|
@ -79,10 +79,10 @@ The code after `#` is ignored as a comment. Use this to explain the intent of th
|
|||
```python
|
||||
# Comment
|
||||
# `#` and after are ignored until a new line is inserted
|
||||
# [
|
||||
#[
|
||||
Multi-line comment
|
||||
Treated as a comment all the way up to the corresponding `]#`
|
||||
]#
|
||||
]#
|
||||
```
|
||||
|
||||
## Expressions, separators
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
0.00, -0.0, 0.1, 400.104, ...
|
||||
```
|
||||
|
||||
Note that the Ratio type is different from the Float type; the API is the same, but there are differences in the accuracy and efficiency of the calculation results.
|
||||
|
||||
If a `Ratio` literal has an integer or decimal part of `0`, you can omit the `0`.
|
||||
|
||||
```python
|
||||
|
@ -62,7 +64,7 @@ Each of these literals has its own documentation describing them separately, so
|
|||
### [Array Literal](./10_array.md)
|
||||
|
||||
```python
|
||||
[], [1], [1, 2, 3], ["1", "2",], [1, "1", True, [1]], ...
|
||||
[], [1], [1, 2, 3], ["1", "2",], ...
|
||||
```
|
||||
|
||||
### [Tuple Literal](./11_tuple.md)
|
||||
|
@ -86,7 +88,7 @@ Each of these literals has its own documentation describing them separately, so
|
|||
### [Set Literal](./14_set.md)
|
||||
|
||||
```python
|
||||
{}, {1}, {1, 2, 3}, {"1", "2", "1"}, {1, "1", True, [1]} ...
|
||||
{}, {1}, {1, 2, 3}, {"1", "2", "1"}, ...
|
||||
```
|
||||
|
||||
As a difference from `Array` literals, duplicate elements are removed in `Set`.
|
||||
|
@ -112,10 +114,11 @@ None
|
|||
## Range Object
|
||||
|
||||
```python
|
||||
assert 0..5 == {1, 2, 3, 4, 5}
|
||||
assert 0..10 in 5
|
||||
assert 0..<10 notin 10
|
||||
assert 0..9 == 0..<10
|
||||
assert (0..5).to_set() == {1, 2, 3, 4, 5}
|
||||
assert "a" in "a".."z"
|
||||
```
|
||||
|
||||
## Float Object
|
||||
|
@ -130,10 +133,10 @@ Float objects are constructed by multiplying a `Ratio` object by `f64`, which is
|
|||
## Complex Object
|
||||
|
||||
```python
|
||||
1+2im, 0.4-1.2im, 0im, im
|
||||
1+2Im, 0.4-1.2Im, 0Im, Im
|
||||
```
|
||||
|
||||
A `Complex` object is simply an arithmetic combination of an imaginary unit object, `im`.
|
||||
A `Complex` object is simply an arithmetic combination of an imaginary unit object, `Im`.
|
||||
|
||||
## *-less multiplication
|
||||
|
||||
|
|
|
@ -21,4 +21,3 @@ pre-commitを使ってclippyのチェックやテストを自動で行わせて
|
|||
* エディタ: Visual Studio Code
|
||||
* VSCode拡張機能: Rust-analyzer, GitLens, Git Graph, GitHub Pull Requests and Issues, Markdown All in One, markdownlint
|
||||
* OS: Windows 10/11 | Ubuntu 20.04/22.04 | MacOS Monterey
|
||||
* その他: mold
|
||||
|
|
|
@ -60,10 +60,10 @@ hello, world
|
|||
```python
|
||||
# コメント
|
||||
## `#`以降は改行されるまで無視されるため、`#`は何個でも使用できる
|
||||
# [
|
||||
#[
|
||||
複数行コメント
|
||||
対応する# `[`から`]#`のところまでがコメントとして扱われる
|
||||
]#
|
||||
対応する`#[`から`]#`のところまでがコメントとして扱われる
|
||||
]#
|
||||
```
|
||||
|
||||
## 式、セパレータ
|
||||
|
|
|
@ -9,10 +9,11 @@
|
|||
```python
|
||||
0, -0, 1, -1, 2, -2, 3, -3, ...
|
||||
```
|
||||
0未満の数値は`Int`リテラルとして型が解釈されます。
|
||||
|
||||
> __Note__: また、`Int`リテラルの部分型として`Nat`リテラルが存在します。
|
||||
> 0以上の数値は`Nat`リテラルとして型が解釈されます。
|
||||
整数(Int)リテラルはInt型のオブジェクトです。
|
||||
|
||||
> __Note__: `Int`型の部分型として`Nat`型が存在します。
|
||||
> 0以上の数値は`Nat`型とも解釈できます。
|
||||
|
||||
### 有理数リテラル(Ratio Literal)
|
||||
|
||||
|
@ -20,6 +21,7 @@
|
|||
0.00, -0.0, 0.1, 400.104, ...
|
||||
```
|
||||
|
||||
有理数を表すリテラルです。専ら小数として表現されますが、内部的には分数として扱われます。
|
||||
`Ratio`リテラルで整数部分または小数部分が`0`のときは、その`0`を省略できます。
|
||||
|
||||
```python
|
||||
|
@ -68,7 +70,7 @@ assert 1e-10 == 0.0000000001
|
|||
### [配列リテラル(Array Literal)](./10_array.md)
|
||||
|
||||
```python
|
||||
[], [1], [1, 2, 3], ["1", "2",], [1, "1", True, [1]], ...
|
||||
[], [1], [1, 2, 3], ["1", "2",], ...
|
||||
```
|
||||
|
||||
### [組リテラル(Tuple Literal)](./11_tuple.md)
|
||||
|
@ -92,7 +94,7 @@ assert 1e-10 == 0.0000000001
|
|||
### [集合リテラル(Set Literal)](./14_set.md)
|
||||
|
||||
```python
|
||||
{}, {1}, {1, 2, 3}, {"1", "2", "1"}, {1, "1", True, [1]} ...
|
||||
{}, {1}, {1, 2, 3}, {"1", "2", "1"}, ...
|
||||
```
|
||||
|
||||
`Array`リテラルとの違いとして、`Set`では重複する要素が取り除かれます。
|
||||
|
@ -109,21 +111,34 @@ assert {1, 2, 1} == {1, 2}
|
|||
True, False
|
||||
```
|
||||
|
||||
真偽値オブジェクトはBool型の単なるシングルトン(ダブルトン?)です。
|
||||
Pythonからの伝統により、`Bool`型は`Int`型ないし`Nat`型のサブタイプとなります。
|
||||
すなわち、`True`は`1`、`False`は`0`と解釈できます。
|
||||
|
||||
```python
|
||||
assert True * 2 == 1
|
||||
```
|
||||
|
||||
### Noneオブジェクト
|
||||
|
||||
```python
|
||||
None
|
||||
```
|
||||
|
||||
`NoneType`型のシングルトンです。
|
||||
|
||||
## 範囲オブジェクト(Range Object)
|
||||
|
||||
```python
|
||||
assert 0..5 == {1, 2, 3, 4, 5}
|
||||
assert 0..10 in 5
|
||||
assert 0..<10 notin 10
|
||||
assert 0..9 == 0..<10
|
||||
assert (0..5).to_set() == {1, 2, 3, 4, 5}
|
||||
assert "a" in "a".."z"
|
||||
```
|
||||
|
||||
Pythonの`range`とは異なり、IntだけでなくStrオブジェクトなども範囲として扱うことができます。
|
||||
|
||||
## 浮動小数点数オブジェクト(Float Object)
|
||||
|
||||
```python
|
||||
|
@ -132,14 +147,15 @@ assert 0.0f32 == 0.0f64
|
|||
```
|
||||
|
||||
`Ratio`オブジェクトに`Float 64`の単位オブジェクトである`f64`を乗算したものです。
|
||||
誤差が生じる可能性がありますが、`Ratio`よりも高速に計算できます。
|
||||
|
||||
## 複素数オブジェクト(Complex Object)
|
||||
|
||||
```python
|
||||
1+2im, 0.4-1.2im, 0im, im
|
||||
1+2Im, 0.4-1.2Im, 0Im, Im
|
||||
```
|
||||
|
||||
`Complex`オブジェクトは、単に虚数単位オブジェクトである`im`との演算の組み合わせで表します。
|
||||
`Complex`オブジェクトは、単に虚数単位オブジェクトである`Im`との演算の組み合わせで表します。
|
||||
|
||||
## *-less multiplication
|
||||
|
||||
|
|
|
@ -18,4 +18,3 @@
|
|||
* 编辑器: Visual Studio Code
|
||||
* VSCode 扩展: Rust-analyzer、GitLens、Git Graph、GitHub Pull Requests and Issues、Markdown All in One、markdownlint
|
||||
* 操作系统: Windows 10/11 | Ubuntu 20.04/22.04 | Mac OS Monterey
|
||||
* 其他: mold
|
||||
|
|
|
@ -42,7 +42,7 @@ Erg 代码称为脚本。脚本可以以文件格式 (.er) 保存和执行
|
|||
|
||||
## REPL/文件执行
|
||||
|
||||
要启动 REPL,只需键入:
|
||||
要启动 REPL,只需键入:
|
||||
|
||||
```sh
|
||||
> erg
|
||||
|
@ -75,10 +75,10 @@ hello, world!
|
|||
```python
|
||||
# Comment
|
||||
# `#` and after are ignored until a new line is inserted
|
||||
# [
|
||||
#[
|
||||
Multi-line comment
|
||||
Treated as a comment all the way up to the corresponding `]#`
|
||||
]#
|
||||
]#
|
||||
```
|
||||
|
||||
## 表达式,分隔符
|
||||
|
|
|
@ -132,10 +132,10 @@ assert 0.0f32 == 0.0f64
|
|||
## Complex 对象
|
||||
|
||||
```python
|
||||
1+2im, 0.4-1.2im, 0im, im
|
||||
1+2Im, 0.4-1.2Im, 0Im, Im
|
||||
```
|
||||
|
||||
一个"复杂"对象只是一个虚数单位对象`im`的算术组合
|
||||
一个"复杂"对象只是一个虚数单位对象`Im`的算术组合
|
||||
|
||||
## *-less 乘法
|
||||
|
||||
|
|
|
@ -18,4 +18,3 @@
|
|||
* 編輯器: Visual Studio Code
|
||||
* VSCode 擴展: Rust-analyzer、GitLens、Git Graph、GitHub Pull Requests and Issues、Markdown All in One、markdownlint
|
||||
* 操作系統: Windows 10/11 | Ubuntu 20.04/22.04 | Mac OS Monterey
|
||||
* 其他: mold
|
||||
|
|
|
@ -42,7 +42,7 @@ Erg 代碼稱為腳本。腳本可以以文件格式 (.er) 保存和執行
|
|||
|
||||
## REPL/文件執行
|
||||
|
||||
要啟動 REPL,只需鍵入:
|
||||
要啟動 REPL,只需鍵入:
|
||||
|
||||
```sh
|
||||
> erg
|
||||
|
@ -75,10 +75,10 @@ hello, world!
|
|||
```python
|
||||
# Comment
|
||||
# `#` and after are ignored until a new line is inserted
|
||||
# [
|
||||
#[
|
||||
Multi-line comment
|
||||
Treated as a comment all the way up to the corresponding `]#`
|
||||
]#
|
||||
]#
|
||||
```
|
||||
|
||||
## 表達式,分隔符
|
||||
|
|
|
@ -132,10 +132,10 @@ assert 0.0f32 == 0.0f64
|
|||
## Complex 對象
|
||||
|
||||
```python
|
||||
1+2im, 0.4-1.2im, 0im, im
|
||||
1+2Im, 0.4-1.2Im, 0Im, Im
|
||||
```
|
||||
|
||||
一個"復雜"對象只是一個虛數單位對象`im`的算術組合
|
||||
一個"復雜"對象只是一個虛數單位對象`Im`的算術組合
|
||||
|
||||
## *-less 乘法
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue