Removed wrong not in zerop built-in.
[bpt/guile.git] / module / language / elisp / runtime / function-slot.scm
1 ;;; Guile Emac Lisp
2
3 ;; Copyright (C) 2001 Free Software Foundation, Inc.
4
5 ;; This program is free software; you can redistribute it and/or modify
6 ;; it under the terms of the GNU General Public License as published by
7 ;; the Free Software Foundation; either version 2, or (at your option)
8 ;; any later version.
9 ;;
10 ;; This program is distributed in the hope that it will be useful,
11 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ;; GNU General Public License for more details.
14 ;;
15 ;; You should have received a copy of the GNU General Public License
16 ;; along with this program; see the file COPYING. If not, write to
17 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 ;; Boston, MA 02111-1307, USA.
19
20 ;;; Code:
21
22 (define-module (language elisp runtime function-slot)
23 #:use-module (language elisp runtime))
24
25 ; This module contains the function-slots of elisp symbols. Elisp built-in
26 ; functions are implemented as predefined function bindings here.
27
28
29 ; Number predicates.
30
31 (built-in-func floatp (lambda (num)
32 (elisp-bool (and (real? num)
33 (not (integer? num))))))
34
35 (built-in-func integerp (lambda (num)
36 (elisp-bool (integer? num))))
37
38 (built-in-func numberp (lambda (num)
39 (elisp-bool (real? num))))
40
41 (built-in-func wholenump (lambda (num)
42 (elisp-bool (and (integer? num)
43 ((@ (guile) >=) num 0)))))
44
45 (built-in-func zerop (lambda (num)
46 (elisp-bool ((@ (guile) =) num 0))))
47
48
49 ; Number comparisons.
50
51 (built-in-func = (lambda (num1 num2)
52 (elisp-bool ((@ (guile) =) num1 num2))))
53 (built-in-func /= (lambda (num1 num2)
54 (elisp-bool ((@ (guile) not) ((@ (guile) =) num1 num2)))))
55
56 (built-in-func < (lambda (num1 num2)
57 (elisp-bool ((@ (guile) <) num1 num2))))
58 (built-in-func <= (lambda (num1 num2)
59 (elisp-bool ((@ (guile) <=) num1 num2))))
60 (built-in-func > (lambda (num1 num2)
61 (elisp-bool ((@ (guile) >) num1 num2))))
62 (built-in-func >= (lambda (num1 num2)
63 (elisp-bool ((@ (guile) >=) num1 num2))))
64
65 (built-in-func max (lambda (. nums)
66 ((@ (guile) apply) (@ (guile) max) nums)))
67 (built-in-func min (lambda (. nums)
68 ((@ (guile) apply) (@ (guile) min) nums)))
69
70 (built-in-func abs (lambda (num)
71 ((@ (guile) abs) num)))
72
73
74 ; Number conversion.
75
76 (built-in-func float (lambda (num)
77 (if (exact? num)
78 (exact->inexact num)
79 num)))
80
81 ; TODO: truncate, floor, ceiling, round.
82
83
84 ; Arithmetic functions.
85
86 (built-in-func 1+ (@ (guile) 1+))
87 (built-in-func 1- (@ (guile) 1-))
88 (built-in-func + (@ (guile) +))
89 (built-in-func - (@ (guile) -))
90 (built-in-func * (@ (guile) *))
91 (built-in-func % (@ (guile) modulo))
92
93 ; TODO: / with correct integer/real behaviour, mod (for floating-piont values).
94
95
96 ; Floating-point rounding operations.
97
98 (built-in-func ffloor (@ (guile) floor))
99 (built-in-func fceiling (@ (guile) ceiling))
100 (built-in-func ftruncate (@ (guile) truncate))
101 (built-in-func fround (@ (guile) round))