1
0
mirror of https://github.com/janet-lang/janet synced 2024-10-18 08:00:40 +00:00

Fix formatting.

This commit is contained in:
Calvin Rose 2024-07-12 15:22:46 -05:00
parent 368b891499
commit 342a29c7be
3 changed files with 17 additions and 5 deletions

View File

@ -211,13 +211,13 @@ int sixints_fn_3(SixInts s, int x) {
EXPORTER EXPORTER
intint stack_spill_fn(uint8_t a, uint8_t b, uint8_t c, uint8_t d, intint stack_spill_fn(uint8_t a, uint8_t b, uint8_t c, uint8_t d,
uint8_t e, uint8_t f, uint8_t g, uint8_t h, uint8_t e, uint8_t f, uint8_t g, uint8_t h,
float i, float j, float k, float l, float i, float j, float k, float l,
float m, float n, float o, float p, float m, float n, float o, float p,
float s1, int8_t s2, uint8_t s3, double s4, uint8_t s5, intint s6) { float s1, int8_t s2, uint8_t s3, double s4, uint8_t s5, intint s6) {
return (intint) { return (intint) {
(a | b | c | d | e | f | g | h) + (i + j + k + l + m + n + o + p), (a | b | c | d | e | f | g | h) + (i + j + k + l + m + n + o + p),
s1 * s6.a + s2 * s6.b + s3 * s4 * s5 s1 *s6.a + s2 *s6.b + s3 *s4 *s5
}; };
} }

View File

@ -449,6 +449,11 @@ JANET_CORE_FN(janet_core_range,
} }
count = (count > 0) ? count : 0; count = (count > 0) ? count : 0;
int32_t int_count = ceil(count); int32_t int_count = ceil(count);
if (step > 0.0) {
janet_assert(start + int_count * step >= stop, "bad range code");
} else {
janet_assert(start + int_count * step <= stop, "bad range code");
}
JanetArray *array = janet_array(int_count); JanetArray *array = janet_array(int_count);
for (int32_t i = 0; i < int_count; i++) { for (int32_t i = 0; i < int_count; i++) {
array->data[i] = janet_wrap_number(start + i * step); array->data[i] = janet_wrap_number(start + i * step);

View File

@ -69,6 +69,13 @@
(seq [n :range [0 10]] (% n 5 3)) (seq [n :range [0 10]] (% n 5 3))
[0 1 2 0 1 0 1 2 0 1]) "variadic mod") [0 1 2 0 1 0 1 2 0 1]) "variadic mod")
# linspace range
(assert (deep= @[0 1 2 3] (range 4)) "range 1")
(assert (deep= @[0 1 2 3] (range 3.01)) "range 2")
(assert (deep= @[0 1 2 3] (range 3.999)) "range 3")
(assert (deep= @[0.8 1.8 2.8 3.8] (range 0.8 3.999)) "range 4")
(assert (deep= @[0.8 1.8 2.8 3.8] (range 0.8 3.999)) "range 5")
(assert (< 1.0 nil false true (assert (< 1.0 nil false true
(fiber/new (fn [] 1)) (fiber/new (fn [] 1))
"hi" "hi"