;; (use srfi-1)
;; (require srfi/1)
;; ...
(define (make-binop op)
(define (convert expression)
(cond ((number? expression) (number->string expression))
((symbol? expression) (symbol->string expression))
((string? expression) expression)
(else (error "Unknown expression type: " expression))))
(lambda args
(fold-right (lambda (x xs)
(if (equal? xs "")
(string-append x xs)
(string-append x op xs)))
""
(map convert args))))
(define add (make-binop "+"))
(define multiply (make-binop "*"))
;;; This seems rather boring since we actually want to lead
;;; unsuspecting victims to believe that we are doing something
;;; useful. Therefore, consider
(define (make-command op)
(string-append "\\" op))
(define (make-sum-like op)
(lambda (from to body)
(string-append (make-command op)
"_{"
from
"}"
"^{"
to
"}"
body)))
(define sum (make-sum-like "sum"))
(define product (make-sum-like "prod"))
;;; The reader can probably think of further ``tweaks'' to this
;;; approach. Like, say, a new versions of `read' and `eval', or
;;; modifications to this file allowing it to convert itself to a
;;; `nice' format.