;;; -*-scheme-*- ;;; Mes --- Maxwell Equations of Software ;;; Copyright © 2016 Jan Nieuwenhuizen ;;; ;;; base.mes: This file is part of Mes. ;;; ;;; Mes is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; Mes is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with Mes. If not, see . (define (cons* x . rest) (define (loop rest) (if (null? (cdr rest)) (car rest) ;; IF (cons (car rest) (loop (cdr rest))))) (loop (cons x rest))) (define-macro cond (lambda clauses (if (null? clauses) *unspecified* ;; IF (if (null? (cdr clauses)) ;; IF (list 'if (car (car clauses)) ;; IF (cons* 'begin (car (car clauses)) (cdr (car clauses))) *unspecified*) (if (eq? (car (cadr clauses)) 'else) ;; IF (list 'if (car (car clauses)) ;; IF (cons* 'begin (car (car clauses)) (cdr (car clauses))) (cons* 'begin *unspecified* (cdr (cadr clauses)))) (list 'if (car (car clauses)) ;; IF (cons* 'begin (car (car clauses)) (cdr (car clauses))) (cons* 'cond (cdr clauses)))))))) ;; IF