Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;Hersh Kumar
- ;Haiku Generator
- (defun one-of (set)
- (list (random-elt set)))
- (defun random-elt (choices)
- (elt choices (random (length choices))))
- (defparameter *nature*
- '(
- (one (is cool warm like rain some fall spring life death mouse lion duck horse))
- (two (windy snowing raining thunder zebra spider))
- (three (animals adventure favorite extinction))
- )
- )
- (defparameter *school*
- '(
- (one (tests work grades life death are is hate love when grades ))
- (two (knowledge sadness cramming homework english teacher exam whiteboard))
- (three (eraser library studying memorize principal sharpener calendar))
- )
- )
- (defparameter *halloween*
- '(
- (one (death life send down spine your is was like ghosts ghoul boo cape imp))
- (two (scary spooky shivers spiders cauldron coffin casket cackle costume darkness enchant eyeballs))
- (three (skeletons murderer enchanted fantasy frightening))
- )
- )
- (defvar *topic* *nature*)
- (setf *topic* *nature*)
- (setf *topic* *school*)
- (setf *topic* *halloween*)
- (defun genFive ()
- (let ((total 0))
- (setq words '())
- (loop while (< total 5) do
- (setq rand (random 4))
- (if (<= (+ rand total) 5)
- (cond
- ;if its a one
- ((= rand 1)
- (setq words (cons (random-elt (car (rest (assoc 'one *topic*)))) words))
- (setq total (+ total rand))
- )
- ;if its a two
- ((= rand 2)
- (setq words (cons (random-elt (car (rest (assoc 'two *topic*)))) words))
- (setq total (+ total rand))
- )
- ;if its a three
- ((= rand 3)
- (setq words (cons (random-elt (car (rest (assoc 'three *topic*)))) words))
- (setq total (+ total rand))
- )
- )
- )
- )
- words
- )
- )
- (defun genSeven ()
- (let ((total 0))
- (setq words '())
- (loop while (< total 7) do
- (setq rand (random 4))
- (if (<= (+ rand total) 7)
- (cond
- ;if its a one
- ((= rand 1)
- (setq words (cons (random-elt (car (rest (assoc 'one *topic*)))) words))
- (setq total (+ total rand))
- )
- ;if its a two
- ((= rand 2)
- (setq words (cons (random-elt (car (rest (assoc 'two *topic*)))) words))
- (setq total (+ total rand))
- )
- ;if its a three
- ((= rand 3)
- (setq words (cons (random-elt (car (rest (assoc 'three *topic*)))) words))
- (setq total (+ total rand))
- )
- )
- )
- )
- words
- )
- )
- (defun Haiku ()
- (format t "~{~a ~}~%" (genFive))
- (format t "~{~a ~}~%" (genSeven))
- (format t "~{~a ~}~%" (genFive))
- nil
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement