Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Some Remarks on Data Representation

0 views
Skip to first unread message

Karl Winterling

unread,
Sep 26, 2009, 5:57:40 PM9/26/09
to
;;; I've thought about it for a while, and realized it's useful to
;;; think of writing mathematics on a computer as a form of literate
;;; programming. In some sense, proofs (of which computations are a
;;; subset) along with notation are really expressions that, when
;;; evaluated, yield something meaningful to humans. For example,
;;; consider the following function

;; (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.

0 new messages