3 ;;; Mes --- Maxwell Equations of Software
4 ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
6 ;;; This file is part of Mes.
8 ;;; Mes is free software; you can redistribute it and/or modify it
9 ;;; under the terms of the GNU General Public License as published by
10 ;;; the Free Software Foundation; either version 3 of the License, or (at
11 ;;; your option) any later version.
13 ;;; Mes is distributed in the hope that it will be useful, but
14 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;;; GNU General Public License for more details.
18 ;;; You should have received a copy of the GNU General Public License
19 ;;; along with Mes. If not, see <http://www.gnu.org/licenses/>.
24 ;;; base.mes is being loaded after base-0.mes. It provides the minimal
25 ;;; set of scheme primitives to run lib/test.mes. It is safe to be
30 (define (identity x) x)
32 (define-macro (or . x)
34 (if (null? (cdr x)) (car x)
35 (list 'if (car x) (car x)
36 (cons 'or (cdr x))))))
38 (define-macro (and . x)
40 (if (null? (cdr x)) (car x)
41 (list 'if (car x) (cons 'and (cdr x))
44 (define (equal? a b) ;; FIXME: only 2 arg
45 (if (and (null? a) (null? b)) #t
46 (if (and (pair? a) (pair? b))
47 (and (equal? (car a) (car b))
48 (equal? (cdr a) (cdr b)))
49 (if (and (string? a) (string? b))
50 (eq? (string->symbol a) (string->symbol b))
51 (if (and (vector? a) (vector? b))
52 (equal? (vector->list a) (vector->list b))
57 (and (pair? x) (list? (cdr x)))))
59 (define (procedure? p)
60 (cond ((builtin? p) #t)
61 ((and (pair? p) (eq? (car p) 'lambda)))
62 ((and (pair? p) (eq? (car p) '*closure*)))