mirror of
https://github.com/erg-lang/erg.git
synced 2025-08-04 18:58:30 +00:00
Update builtins.d.er
This commit is contained in:
parent
64d53a39ce
commit
8b5d289ad3
4 changed files with 75 additions and 7 deletions
|
@ -217,10 +217,10 @@ impl Context {
|
|||
poly(ZIP, vec![ty_tp(T.clone()), ty_tp(U.clone())]),
|
||||
)
|
||||
.quantify();
|
||||
self.register_builtin_py_impl(FUNC_ABS, t_abs, Immutable, vis, Some(FUNC_ABS));
|
||||
self.register_builtin_py_impl(FUNC_ALL, t_all, Immutable, vis, Some(FUNC_ALL));
|
||||
self.register_builtin_py_impl(FUNC_ANY, t_any, Immutable, vis, Some(FUNC_ANY));
|
||||
self.register_builtin_py_impl(FUNC_ASCII, t_ascii, Immutable, vis, Some(FUNC_ASCII));
|
||||
self.register_py_builtin(FUNC_ABS, t_abs, Some(FUNC_ABS), 17);
|
||||
self.register_py_builtin(FUNC_ALL, t_all, Some(FUNC_ALL), 29);
|
||||
self.register_py_builtin(FUNC_ANY, t_any, Some(FUNC_ANY), 41);
|
||||
self.register_py_builtin(FUNC_ASCII, t_ascii, Some(FUNC_ASCII), 67);
|
||||
// Leave as `Const`, as it may negatively affect assert casting.
|
||||
self.register_builtin_erg_impl(FUNC_ASSERT, t_assert, Const, vis);
|
||||
self.register_builtin_py_impl(FUNC_BIN, t_bin, Immutable, vis, Some(FUNC_BIN));
|
||||
|
|
|
@ -523,7 +523,7 @@ impl Context {
|
|||
self.register_builtin_impl(name, t, muty, vis, None, AbsLocation::unknown());
|
||||
}
|
||||
|
||||
// TODO: replace with `register_builtins`
|
||||
// TODO: replace with `register_py_builtin`
|
||||
fn register_builtin_py_impl(
|
||||
&mut self,
|
||||
name: &'static str,
|
||||
|
|
|
@ -116,13 +116,13 @@ impl Context {
|
|||
)
|
||||
.quantify();
|
||||
self.register_builtin_py_impl("dir!", t_dir, Immutable, vis, Some("dir"));
|
||||
self.register_py_builtin("print!", t_print, Some("print"), 27);
|
||||
self.register_py_builtin("print!", t_print, Some("print"), 95);
|
||||
self.register_builtin_py_impl("id!", t_id, Immutable, vis, Some("id"));
|
||||
self.register_builtin_py_impl("input!", t_input, Immutable, vis, Some("input"));
|
||||
self.register_builtin_py_impl("globals!", t_globals, Immutable, vis, Some("globals"));
|
||||
self.register_builtin_py_impl("locals!", t_locals, Immutable, vis, Some("locals"));
|
||||
self.register_builtin_py_impl("next!", t_next, Immutable, vis, Some("next"));
|
||||
self.register_py_builtin("open!", t_open, Some("open"), 144);
|
||||
self.register_py_builtin("open!", t_open, Some("open"), 212);
|
||||
let name = if cfg!(feature = "py_compatible") {
|
||||
"if"
|
||||
} else {
|
||||
|
|
|
@ -1,3 +1,71 @@
|
|||
'''
|
||||
Return the absolute value of the argument.
|
||||
|
||||
```erg
|
||||
assert abs(-1) == 1
|
||||
assert abs(3+4Im) == 5
|
||||
```
|
||||
'''
|
||||
'''japanese
|
||||
引数の絶対値を返す。
|
||||
|
||||
```erg
|
||||
assert abs(-1) == 1
|
||||
assert abs(3+4Im) == 5
|
||||
```
|
||||
'''
|
||||
.abs: (x: Num) -> Nat
|
||||
|
||||
'''
|
||||
Return `True` if `x == True` for all values `x` in the `iterable`.
|
||||
|
||||
If the `iterable` is empty, return `True`.
|
||||
|
||||
```erg
|
||||
assert all [1, 2].map(x -> x > 0)
|
||||
assert all []
|
||||
```
|
||||
'''
|
||||
.all: (iterable: Iterable Bool) -> Bool
|
||||
|
||||
'''
|
||||
Return `True` if `x == True` for any value `x` in the `iterable`.
|
||||
|
||||
If the `iterable` is empty, return `False`.
|
||||
|
||||
```erg
|
||||
assert any [-1, 1, 2].map(x -> x < 0)
|
||||
assert not any []
|
||||
```
|
||||
'''
|
||||
.any: (iterable: Iterable Bool) -> Bool
|
||||
|
||||
'''
|
||||
Return an ASCII-only representation of an object.
|
||||
|
||||
As repr(), return a string containing a printable representation of an
|
||||
object, but escape the non-ASCII characters in the string returned by
|
||||
repr() using \\x, \\u or \\U escapes. This generates a string similar
|
||||
to that returned by repr() in Python 2.
|
||||
|
||||
```erg
|
||||
assert ascii("a") == "'a'"
|
||||
assert ascii("あ") == "'\\u3042'"
|
||||
```
|
||||
'''
|
||||
'''japanese
|
||||
オブジェクトのASCII表現を返す。
|
||||
|
||||
repr()と同じように、オブジェクトの表現を文字列で返すが、repr()で返される文字列の非ASCII文字は\\x、\\u、\\Uエスケープでエスケープされる。
|
||||
これはPython 2でのrepr()と似た文字列を生成する。
|
||||
|
||||
```erg
|
||||
assert ascii("a") == "'a'"
|
||||
assert ascii("あ") == "'\\u3042'"
|
||||
```
|
||||
'''
|
||||
.ascii: (obj: Obj) -> Str
|
||||
|
||||
'''
|
||||
Prints the values to a stream, or to `sys.stdout` by default.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue