tests for andmap ormap running
This commit is contained in:
parent
330cc75f12
commit
bd5f0ba6f8
|
@ -1232,6 +1232,8 @@
|
|||
});
|
||||
|
||||
|
||||
|
||||
|
||||
installPrimitiveProcedure(
|
||||
'number?',
|
||||
1,
|
||||
|
@ -1259,6 +1261,23 @@
|
|||
return isRational(MACHINE.env[MACHINE.env.length - 1]);
|
||||
});
|
||||
|
||||
installPrimitiveProcedure(
|
||||
'even?',
|
||||
1,
|
||||
function(MACHINE) {
|
||||
var n = checkInteger(MACHINE, 'even?', 0);
|
||||
return baselib.numbers.equals(0, baselib.numbers.modulo(n, 2))
|
||||
});
|
||||
|
||||
installPrimitiveProcedure(
|
||||
'odd?',
|
||||
1,
|
||||
function(MACHINE) {
|
||||
var n = checkInteger(MACHINE, 'odd?', 0);
|
||||
return baselib.numbers.equals(1, baselib.numbers.modulo(n, 2))
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -302,9 +302,9 @@ integer?
|
|||
exact?
|
||||
exact-nonnegative-integer?
|
||||
;; inexact?
|
||||
;; odd?
|
||||
;; even?
|
||||
zero?
|
||||
odd?
|
||||
even?
|
||||
zero?
|
||||
;; positive?
|
||||
;; negative?
|
||||
;; box?
|
||||
|
|
|
@ -7,3 +7,15 @@ true
|
|||
hello
|
||||
()
|
||||
world
|
||||
true
|
||||
true
|
||||
false
|
||||
false
|
||||
false
|
||||
false
|
||||
true
|
||||
false
|
||||
true
|
||||
false
|
||||
false
|
||||
true
|
||||
|
|
|
@ -9,4 +9,18 @@
|
|||
(cons? '(hello))
|
||||
(first '(hello))
|
||||
(rest '(hello))
|
||||
(second '(hello world))
|
||||
(second '(hello world))
|
||||
|
||||
(andmap even? '(2 4 6 8))
|
||||
(andmap even? '())
|
||||
(andmap even? '(2 4 5 8))
|
||||
(andmap even? '(5))
|
||||
(andmap even? '(1 3 5 7))
|
||||
(andmap even? '(1 3 8 7))
|
||||
|
||||
(ormap even? '(2 4 6 8))
|
||||
(ormap even? '())
|
||||
(ormap even? '(2 4 5 8))
|
||||
(ormap even? '(5))
|
||||
(ormap even? '(1 3 5 7))
|
||||
(ormap even? '(1 3 8 7))
|
Loading…
Reference in New Issue
Block a user