Supernatural Symbols.

=====================

; Newlisp interpreter analyzes the expression and inserts symbols
; used in the expression into symbol-table *before* evaluation
; of the expression.
;
; Because of that, one can write the function that assigns the
; value to the symbols of the block before the symbols are
; actually defined, or even mentioned in the block.
;
; Don't look first at the function - it is technical. Take a look
; at main program block first and analyze the function only if
; that block is interesting to you.


(set 'self-conscious-symbols
  (lambda()
     (if (not symbols1)
         (set 'symbols1 (symbols)))
     (let ((symbols2
             (difference (symbols)
                 symbols1
                 '(i symbols1 symbols2 self-conscious-symbols))))
                     
       (dolist(i symbols2)
            (set i (append "I am " (string i) ". I feel "
                       (string (apply amb
                                     (difference symbols2
                                           (list i))))
                       " is close."))))))


(self-conscious-symbols)
(seed (date-value))

(begin (self-conscious-symbols)
       (println Sri-Aurobindo)
       
       '(set 'i (list Maharishi
                      Sri-Chinmoy
                      Sai-Baba
                      Dalai-Lama)))

; OUTPUT
;
; I am Sri-Aurobindo. I feel Sri-Chinmoy is close.



2 comments:

  1. Interesting, but what is the point of this:

    (let ((symbols2
    (difference (symbols)
    symbols1
    '(i symbols1 symbols2 self-conscious-symbols))))

    The code seems to run just fine if I use this:

    (let ((symbols2 (difference (symbols) symbols1)))

    ReplyDelete
  2. You are right, it is remain from the time symbols1 was defined explicitly on the beginning of the program

    (set 'symbol1 (symbols))

    Then I decided to "pull" it inside function, to increase dramatic effect and didn't simplified that expression.

    Congratulations, you understood the program better than I did.

    ReplyDelete