This file is indexed.

/usr/share/zenlisp/prefix.l is in zenlisp 2013.11.22-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
; zenlisp example program
; By Nils M Holm, 1998-2007
; See the file LICENSE for conditions of use.

; Convert arithmetic expressions in infix notation
; to S-expressions:
; (infix->prefix '#12+34*56^[7+8])
; => '(+ '#12 (* '#34 (expt '#56 (+ '#7 '#8))))

; Infix expressions are represented by flat lists of
; variables (atoms) operators (atoms) and zenlisp-style
; numbers (eg #5).

; The following operators are recognized: +, - (both
; unary and binary), *, /, ^. Brackets ([, ]) are
; recoginzed as parentheses. XX is equal to X*X if
; X is a symbol.

(require '~rmath)

(define (infix->prefix x)
  (letrec
    ((symbol-p
       (lambda (x)
         (and (memq x '#abcdefghijklmnopqrstuvwxyz) :t)))
     (number
       (lambda (x r)
         (cond ((or (null x)
                    (not (digitp (car x))))
                 (list (list 'quote (reverse r)) x))
               (t (number (cdr x) (cons (car x) r))))))
     (symbol
       (lambda (x)
         (list (car x) (cdr x))))
     (expr car)
     (rest cadr)
     (car-of-rest caadr)
     (cdr-of-rest cdadr)
     ; factor := [ sum ]
     ;         | - factor
     ;         | Number
     ;         | Symbol
     (factor
       (lambda (x)
         (cond ((null x)
                 (bottom 'syntax 'error 'at: x))
               ((eq (car x) '[)
                 (let ((xsub (sum (cdr x))))
                   (cond ((null (rest xsub))
                           (bottom 'missing-right-paren))
                         ((eq (car-of-rest xsub) '])
                           (list (expr xsub) (cdr-of-rest xsub)))
                         (t (bottom 'missing-right-paren)))))
               ((eq (car x) '-)
                 (let ((fac (factor (cdr x))))
                   (list (list '- (expr fac)) (rest fac))))
               ((digitp (car x))
                 (number x ()))
               ((symbol-p (car x))
                 (symbol x))
               (t (bottom 'syntax 'error 'at: x)))))
     ; power := factor
     ;        | factor ^ power
     (power (lambda (x)
       (let ((left (factor x)))
         (cond ((null (rest left)) left)
               ((eq (car-of-rest left) '^)
                 (let ((right (power (cdr-of-rest left))))
                   (list (list 'expt (expr left) (expr right))
                         (rest right))))
               (t left)))))
     ; term := power
     ;       | power Symbol
     ;       | power * term
     ;       | power / term
     (term2
       (lambda (out in)
         (cond ((null in) (list out in))
               ((symbol-p (car in))
                 (let ((right (power in)))
                   (term2 (list '* out (expr right))
                          (rest right))))
               ((eq (car in) '*)
                 (let ((right (power (cdr in))))
                   (term2 (list '* out (expr right))
                          (rest right))))
               ((eq (car in) '/)
                 (let ((right (power (cdr in))))
                   (term2 (list '/ out (expr right))
                          (rest right))))
               (t (list out in)))))
     (term
       (lambda (x)
         (let ((left (power x)))
           (term2 (expr left) (rest left)))))
     ; sum := term
     ;      | term + sum
     ;      | term - sum
     (sum2
       (lambda (out in)
         (cond ((null in) (list out in))
               ((eq (car in) '+)
                 (let ((right (term (cdr in))))
                   (sum2 (list '+ out (expr right))
                         (rest right))))
               ((eq (car in) '-)
                 (let ((right (term (cdr in))))
                   (sum2 (list '- out (expr right))
                         (rest right))))
               (t (list out in)))))
     (sum
       (lambda (x)
         (let ((left (term x)))
           (sum2 (expr left) (rest left))))))
  (let ((px (sum x)))
    (cond ((not (null (rest px)))
            (bottom (list 'syntax 'error 'at: (cadr px))))
          (t (expr px))))))