Hi John,
Yes, but LISP can set up any non-cyclic nested data structures of any dimension - perfect for CAD systems and Graph. Editors like GIMP , it can start mutate itself because it makes no difference between data and code :
from NewLisp :
(println my-program-as-a-string) ;; prints your code
(eval-string my-program-as-a-string) ;; runs the code
you can write programs mutating themselves , save the mutant and run the mutant -- in the mean time, we can smoke the cigarette and drink the whiskey ...
If you need some teasers for TS -- quickly written : the reward of the King (story goes when the King asked the inventor of the game of chess about his price ,he answered to start with one grain and double it every next field (rice / corn .. etc ). The King answered, is that all ?! -- however some calculations learn the amount is immense .....
2 things in the code :
the named let -- how to do "pseudo" iterations (the use name "loop" is just another name -- run , do-it etc.. also will do)
how to mark the number is inexact : use 1.0 i.o. 1 (otherwise it will run out of capable numbers)
(define (grains x)
(let loop ((i 1) (j 1.0))
(display " field ") (display i)
(display " number of grains ")(display j) (newline)
(when (< i x) (loop (+ i 1) (* 2 j) ))))
(define (main)
(display "The reward of the King") (newline)
(display "----------------------") (newline)
(newline)
(grains 64))
------------------------------------------------------------------------------------output
The reward of the King
----------------------
field 1 number of grains 1
field 2 number of grains 2
field 3 number of grains 4
field 4 number of grains 8
field 5 number of grains 16
field 6 number of grains 32
field 7 number of grains 64
field 8 number of grains 128
field 9 number of grains 256
field 10 number of grains 512
field 11 number of grains 1024
field 12 number of grains 2048
field 13 number of grains 4096
field 14 number of grains 8192
field 15 number of grains 16384
field 16 number of grains 32768
field 17 number of grains 65536
field 18 number of grains 131072
field 19 number of grains 262144
field 20 number of grains 524288
field 21 number of grains 1048576
field 22 number of grains 2097152
field 23 number of grains 4194304
field 24 number of grains 8388608
field 25 number of grains 16777216
field 26 number of grains 33554432
field 27 number of grains 67108864
field 28 number of grains 134217728
field 29 number of grains 268435456
field 30 number of grains 536870912
field 31 number of grains 1073741824
field 32 number of grains 2147483648
field 33 number of grains 4294967296
field 34 number of grains 8589934592
field 35 number of grains 1.717986918e+010
field 36 number of grains 3.435973837e+010
field 37 number of grains 6.871947674e+010
field 38 number of grains 1.374389535e+011
field 39 number of grains 2.748779069e+011
field 40 number of grains 5.497558139e+011
field 41 number of grains 1.099511628e+012
field 42 number of grains 2.199023256e+012
field 43 number of grains 4.398046511e+012
field 44 number of grains 8.796093022e+012
field 45 number of grains 1.759218604e+013
field 46 number of grains 3.518437209e+013
field 47 number of grains 7.036874418e+013
field 48 number of grains 1.407374884e+014
field 49 number of grains 2.814749767e+014
field 50 number of grains 5.629499534e+014
field 51 number of grains 1.125899907e+015
field 52 number of grains 2.251799814e+015
field 53 number of grains 4.503599627e+015
field 54 number of grains 9.007199255e+015
field 55 number of grains 1.801439851e+016
field 56 number of grains 3.602879702e+016
field 57 number of grains 7.205759404e+016
field 58 number of grains 1.441151881e+017
field 59 number of grains 2.882303762e+017
field 60 number of grains 5.764607523e+017
field 61 number of grains 1.152921505e+018
field 62 number of grains 2.305843009e+018
field 63 number of grains 4.611686018e+018
field 64 number of grains 9.223372037e+018
best Rob