mirror of
https://github.com/janet-lang/janet
synced 2025-03-26 01:56:55 +00:00
Fix not= and odd?
This commit is contained in:
parent
f63d08efbd
commit
08f6c642d0
@ -50,7 +50,7 @@
|
||||
|
||||
# Basic predicates
|
||||
(defn even? [x] (== 0 (% x 2)))
|
||||
(defn odd? [x] (== 1 (% x 2)))
|
||||
(defn odd? [x] (not= 0 (% x 2)))
|
||||
(defn zero? [x] (== x 0))
|
||||
(defn pos? [x] (> x 0))
|
||||
(defn neg? [x] (< x 0))
|
||||
|
@ -159,20 +159,20 @@ static int dst_strict_equal(DstArgs args) {
|
||||
int32_t i;
|
||||
for (i = 0; i < args.n - 1; i++) {
|
||||
if (!dst_equals(args.v[i], args.v[i+1])) {
|
||||
DST_RETURN(args, dst_wrap_false());
|
||||
DST_RETURN_FALSE(args);
|
||||
}
|
||||
}
|
||||
DST_RETURN(args, dst_wrap_true());
|
||||
DST_RETURN_TRUE(args);
|
||||
}
|
||||
|
||||
static int dst_strict_notequal(DstArgs args) {
|
||||
int32_t i;
|
||||
for (i = 0; i < args.n - 1; i++) {
|
||||
if (dst_equals(args.v[i], args.v[i+1])) {
|
||||
DST_RETURN(args, dst_wrap_false());
|
||||
if (!dst_equals(args.v[i], args.v[i+1])) {
|
||||
DST_RETURN_TRUE(args);
|
||||
}
|
||||
}
|
||||
DST_RETURN(args, dst_wrap_true());
|
||||
DST_RETURN_FALSE(args);
|
||||
}
|
||||
|
||||
static int dst_not(DstArgs args) {
|
||||
|
@ -198,4 +198,8 @@
|
||||
(def xs (apply1 tuple (for [x :range [0 10] :when (even? x)] (tuple (/ x 2) x))))
|
||||
(assert (= xs '((0 0) (1 2) (2 4) (3 6) (4 8))) "for macro 1")
|
||||
|
||||
# Some testing for not=
|
||||
(assert (not= 1 1 0) "not= 1")
|
||||
(assert (not= 0 1 1) "not= 2")
|
||||
|
||||
(end-suite)
|
||||
|
Loading…
x
Reference in New Issue
Block a user