Merge branch 'master' of github.com:janet-lang/janet

This commit is contained in:
Calvin Rose 2023-01-07 15:05:16 -06:00
commit b73855b193
4 changed files with 15 additions and 9 deletions

View File

@ -237,7 +237,11 @@ test_files = [
'test/suite0007.janet',
'test/suite0008.janet',
'test/suite0009.janet',
'test/suite0010.janet'
'test/suite0010.janet',
'test/suite0011.janet',
'test/suite0012.janet',
'test/suite0013.janet',
'test/suite0014.janet'
]
foreach t : test_files
test(t, janet_nativeclient, args : files([t]), workdir : meson.current_source_dir())

View File

@ -839,15 +839,15 @@
a)
(defn sort
``Sort `ind` in-place, and return it. Uses quick-sort and is not a stable sort.
``Sorts `ind` in-place, and returns it. Uses quick-sort and is not a stable sort.
If a `before?` comparator function is provided, sorts elements using that,
otherwise uses `<`.``
[ind &opt before?]
(sort-help ind 0 (- (length ind) 1) (or before? <)))
(defn sort-by
``Returns `ind` sorted by calling
a function `f` on each element and comparing the result with `<`.``
``Sorts `ind` in-place by calling a function `f` on each element and
comparing the result with `<`.``
[f ind]
(sort ind (fn [x y] (< (f x) (f y)))))
@ -2065,8 +2065,9 @@
ret)
(defn all
``Returns true if all `xs` are truthy, otherwise the result of first
falsey predicate value, `(pred x)`.``
``Returns true if `(pred item)` returns a truthy value for every item in `xs`.
Otherwise, returns the first falsey `(pred item)` result encountered.
Returns true if `xs` is empty.``
[pred xs]
(var ret true)
(loop [x :in xs :while ret] (set ret (pred x)))

View File

@ -282,7 +282,7 @@ JANET_DEFINE_MATHOP(log2, log2, "Returns the log base 2 of x.")
JANET_DEFINE_MATHOP(sqrt, sqrt, "Returns the square root of x.")
JANET_DEFINE_MATHOP(cbrt, cbrt, "Returns the cube root of x.")
JANET_DEFINE_MATHOP(ceil, ceil, "Returns the smallest integer value number that is not less than x.")
JANET_DEFINE_MATHOP(fabs, fabs, "Return the absolute value of x.")
JANET_DEFINE_MATHOP(abs, fabs, "Return the absolute value of x.")
JANET_DEFINE_MATHOP(floor, floor, "Returns the largest integer value number that is not greater than x.")
JANET_DEFINE_MATHOP(trunc, trunc, "Returns the integer between x and 0 nearest to x.")
JANET_DEFINE_MATHOP(round, round, "Returns the integer nearest to x.")
@ -368,7 +368,7 @@ void janet_lib_math(JanetTable *env) {
JANET_CORE_REG("math/floor", janet_floor),
JANET_CORE_REG("math/ceil", janet_ceil),
JANET_CORE_REG("math/pow", janet_pow),
JANET_CORE_REG("math/abs", janet_fabs),
JANET_CORE_REG("math/abs", janet_abs),
JANET_CORE_REG("math/sinh", janet_sinh),
JANET_CORE_REG("math/cosh", janet_cosh),
JANET_CORE_REG("math/tanh", janet_tanh),

View File

@ -209,6 +209,8 @@ JANET_CORE_FN(os_exit,
return janet_wrap_nil();
}
#ifndef JANET_REDUCED_OS
JANET_CORE_FN(os_cpu_count,
"(os/cpu-count &opt dflt)",
"Get an approximate number of CPUs available on for this process to use. If "
@ -250,7 +252,6 @@ JANET_CORE_FN(os_cpu_count,
#endif
}
#ifndef JANET_REDUCED_OS
#ifndef JANET_NO_PROCESSES