;;;; -*- Mode: LISP; Syntax: Common-Lisp; Base: 10 -*- ;;;; --------------------------------------------------------------------------- ;;;; File name: general-utilities.lsp ;;;; System: ;;;; Author: Shawn Nicholson ;;;; Created: July 15, 2002 16:38:35 ;;;; Purpose: ;;;; --------------------------------------------------------------------------- ;;;; Modified: Monday, November 10, 2003 at 14:52:04 by usher ;;;; --------------------------------------------------------------------------- (in-package :fire-case-viewer) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Strings (defun pretty-print-to-string (form &optional (width 40)) "Pretty-prints a LISP expression to a string. The output is constrained to a width that is the number of characters specified by width." (let ((*print-right-margin* width) (*package* (find-package :data))) (remove-leading-newline (with-output-to-string (s) (pprint form s))))) (defun remove-leading-newline (string) (if (eq (elt string 0) #\newline) (subseq string 1) string)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Expressions (defun symbol< (sym1 sym2) (string-lessp (symbol-name sym1) (symbol-name sym2))) (defun exp< (exp1 exp2) ;; This is not very efficient, but it is satisfactory for many uses. (let ((*package* (find-package :data))) (string-lessp (remove #\newline (write-to-string exp1)) (remove #\newline (write-to-string exp2))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; End of Code