haiku

Started by frontera, June 29, 2004, 09:42:55 AM

Previous topic - Next topic

frontera

#

(print "Content-type: text/htmlnn")



(print "<html><head><title>Random Haiku</title>")

(print "</HEAD>")

(print "<BODY>")

(print "




<table border=0 cellpadding=0 cellspacing=0 width=600><tr><td>
")



(print "<font face='verdana' size=2>n")

(print "
<p><p>RANDOM HAIKU<p></p><p></p>")



(seed (time-of-day))



(set 'adjs '( "autumn"   "hidden"  "bitter"  "misty"  "silent"

   "empty"  "dry"  "dark"  "summer"  "icy"

   "delicate"  "quiet"  "white"  "cool"  "spring"

   "winter"  "patient"  "twilight"  "dawn"  "crimson"

   "wispy"  "weathered"  "blue"  "billowing"  "broken"

   "cold"  "damp"  "falling"  "frosty"  "green"

   "long"  "late" "lingering" "bold" "little"

   "morning"  "muddy"  "old"  "red"  "rough"

   "still"  "small"  "sparkling"  "throbbing"  "shy"

   "wandering"  "withered"  "wild"   "black"  "young"

   "holy"  "solitary"  "fragrant"  "aged"  "snowy"  

   "proud"  "floral"  "restless"  "divine"  "polished"

   "ancient" "purple"  "lively"  "nameless" ))

             

(set 'nouns '( "waterfall"  "river"  "breeze"  "moon"  "rain"

   "wind"  "sea"  "morning"  "snow"  "lake"

   "sunset"  "pine"  "shadow"  "leaf"  "dawn"

   "glitter"  "forest"  "hill"  "cloud"  "meadow"

   "sun"  "glade"  "bird"  "brook"  "butterfly"

   "bush"  "dew"  "dust"  "field" "fire"

   "flower"  "firefly"  "feather"  "grass"  "haze"

   "mountain"  "night"  "pond"  "darkness"  "snowflake"

   "silence"  "sound"  "sky"  "shape"  "surf"

   "thunder"  "violet"  "water"  "wildflower"  "wave"

   "water"  "resonance"  "sun"  "wood"  "dream"

   "cherry"  "tree"  "fog"  "frost"  "voice"

   "paper"  "frog"  "smoke"  "star"))



(set 'verbs '( "shakes"  "drifts"  "has stopped"  "struggles"  "hears"

   "has passed"  "sleeps"  "creeps"  "flutters"  "fades"

   "is falling"  "trickles"  "murmurs"  "warms"  "hides"

   "jumps"  "is dreaming"  "sleeps"  "falls"  "wanders"  

   "waits"  "has risen"  "stands"  "dying"  "is drawing"  

   "singing"  "rises"  "paints"  "capturing"  "flying"

   "lies"  "picked up"  "gathers in"  "invites"  "separates"

   "eats"  "plants"  "digs into"  "has fallen"  "weeping"

   "facing"  "mourns"  "tastes"  "breaking"  "shaking"

   "walks"  "builds"  "reveals"  "piercing"  "craves"  

   "departing"  "opens"  "falling"  "confronts"  "keeps"

   "breaking"  "is floating"  "settles"  "reaches"  "illuminates"

   "closes"  "leaves"  "explodes"  "drawing"))



(set 'preps  '( "on"  "beside"  "in"  "beneath"  "of"  "above"  "under"  "by"

   "over"  "against"  "near" ))





(define (get-word word-list)

   (set 'word-list-size (length word-list))

   (set 'word-list-index (rand word-list-size))

   (set 'selected-word (nth word-list-index word-list))

   (print " " selected-word " " ))



(define (get-adjective)

   (get-word adjs))



(define (get-noun)

   (get-word nouns))



(define (get-verb)

   (get-word verbs))



(define (get-prep)

   (get-word preps))



(define (style-one)

   (get-adjective)

   (get-noun)

   (print "
n")

   (get-noun)

   (get-verb)

   (get-prep)

   (get-noun)

   (print "
n")

   (get-adjective)

   (get-adjective)

   (get-noun)

   (print "
n"))



(define (style-two)

   (get-adjective)

   (get-noun)

   (get-verb)

   (print "
n")

   (get-adjective)

   (get-adjective)

   (get-noun)

   (print "
n")

   (get-verb)

   (get-adjective)

   (get-noun)

   (print "
n"))



(define (style-three)

   (get-adjective)

   (get-adjective)

   (get-noun)

   (print "
n")

   (get-prep)

   (get-adjective)

   (get-noun)

   (print "
n")

   (get-noun)

   (get-verb)

   (print "
n"))



(define (style-four)

   (get-noun)

   (get-prep)

   (get-noun)

   (print "
n")

   (get-adjective)

   (get-noun)

   (get-prep)

   (get-noun)

   (print "
n")

   (get-adjective)

   (get-noun)

   (print "
n"))



(define (print-haiku)

   (set 'which (rand 4))

   (if (= which 0)

      (style-one))

   (if (= which 1)

      (style-two))

   (if (= which 2)

      (style-three))

   (if (= which 3)

      (style-four)))



(print-haiku)



(print "<p></p>")

(print "<font size=1>")

(print "<p>You can click <a href=haiku.lsp > HERE </a>  to see a new poem.n")

(print "<p> Haiku generated in the style of Matsuo Basho, the Japanese poet of the 17th century.


This haiku program originally written in pygmy FORTH by Kent Peterson.
Translated into lisp.")

(print "
</table> </font> </body>n</html>n")



(exit)

Lutz

#1
thanks for the Haiku demo, it is running  here: http://newlisp.org/code/haiku.cgi">http://newlisp.org/code/haiku.cgi



if it is Ok with you Frontera? I link to it from the 'Code Contributions' section here: http://www.newlisp.org/index.cgi?Code_Contributions">http://www.newlisp.org/index.cgi?Code_Contributions



Lutz

BrickCaster

#2
quite funny :)

programming is so unrewarding: it's hard to believe there are 4 styles

frontera

#3
thanks lutz for the wonderful newlisp!  please feel free to use the haiku demo as you wish.

pjot

#4
I happen to like Haiku very much. This is a cool thing! Later the Japanese tradition went on to the 5-7-5 schedule; this should also be easy to change in the algorithm...



Nice tool, thanx!