mes: Support equal? with arbitrary number of arguments.
* module/mes/base.mes (equal2?): Rename from equal?. (equal?): Implement.
This commit is contained in:
parent
72a4f7eba2
commit
4dfad613bf
|
@ -1,7 +1,7 @@
|
|||
;;; -*-scheme-*-
|
||||
|
||||
;;; Mes --- Maxwell Equations of Software
|
||||
;;; Copyright © 2016,2017 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;; Copyright © 2016,2017,2018 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;;
|
||||
;;; This file is part of Mes.
|
||||
;;;
|
||||
|
@ -90,17 +90,23 @@
|
|||
(define (and=> value procedure) (and value (procedure value)))
|
||||
(define eqv? eq?)
|
||||
|
||||
(define (equal? a b) ;; FIXME: only 2 arg
|
||||
(define (equal2? a b)
|
||||
(if (and (null? a) (null? b)) #t
|
||||
(if (and (pair? a) (pair? b))
|
||||
(and (equal? (car a) (car b))
|
||||
(equal? (cdr a) (cdr b)))
|
||||
(and (equal2? (car a) (car b))
|
||||
(equal2? (cdr a) (cdr b)))
|
||||
(if (and (string? a) (string? b))
|
||||
(eq? (string->symbol a) (string->symbol b))
|
||||
(if (and (vector? a) (vector? b))
|
||||
(equal? (vector->list a) (vector->list b))
|
||||
(equal2? (vector->list a) (vector->list b))
|
||||
(eq? a b))))))
|
||||
|
||||
(define (equal? . x)
|
||||
(if (or (null? x) (null? (cdr x))) #t
|
||||
(if (null? (cddr x)) (equal2? (car x) (cadr x))
|
||||
(and (equal2? (car x) (cadr x))
|
||||
(apply equal? (cdr x))))))
|
||||
|
||||
(define (list? x)
|
||||
(or (null? x)
|
||||
(and (pair? x) (list? (cdr x)))))
|
||||
|
|
Loading…
Reference in a new issue