#!/usr/bin/guile \ -e main -s !# ; ******************************************************************* ; ; Copyright 2006 by Sean Conner. All Rights Reserved. ; ; This program is free software; you can redistribute it and/or ; modify it under the terms of the GNU General Public License ; as published by the Free Software Foundation; either version 2 ; of the License, or (at your option) any later version. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with this program; if not, write to the Free Software ; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ; ; Comments, questions and criticisms can be sent to: sean@conman.org ; ; ******************************************************************* ; ******************************************************************* ; ; Data arrays. The elements of each array are strings or a call to ; (ref), which returns a random element from the named array. ; ; ******************************************************************* (define news-flash #( "******** NEWS BULLETIN! ***********\n" "****** FLASH! FLASH! FLASH! *******\n" "******* ATTENTION EARTH! **********\n" "***** CALLING ALL EARTHLINGS! *****\n" "******** NOW HEAR THIS! ***********\n" ) ) (define hero #( "Tim Conway" "Big Bird" "The Fonz" "Wonder Woman" "Kareem Abdul Jabar" "Tom Selleck" "Lucille Ball" ) ) (define monsters #( "Transylvanian vampires" "Brazilian killer bees" "Giant green worms" "Mubbles" "bug eyed monsters" "rabid androids" "fetid zombies" ) ) (define peoria #( "Disneyland" "Cucumonga" "The United States" "Okeefenokee Swamp" "Tucumcari" "Mount St. Helens" "Timbuktu" ) ) (define hell #( "Planet X" "Persepeon" "Bundegarra" "under the bed" "the mausoleum" "downtown Burbank" "the IRS" ) ) (define attacked #( "was attacked at dawn by" "has been surrounded and infiltrated by" "appears to be under attack from" "has been whomped and stomped by" "was rudely jarred awake by" ) ) (define from #( "from the lowest levels of" "out of the vastness of" "descened from" "from the greasy pits of" "who oozed away from" ) ) (define fought #( "dropped dozens of banana peels" "tried to tie their shoelaces together" "told their mothers they were naughty" "used a huge pea shooter against them" "deployed tactical nuclear weapons" ) ) (define alas #( "No use! They kept on coming just like a lava flow" "In spite of this heroism they were not deterred" "Nothing slowed them down" "However those baddies couldn't be stopped" "\"Ha ha,\" they yelled and ran even faster" ) ) (define success #( "held up a mojo and it was GAME OVER for the baddies" "spilled toxic waste in their path, so they ran off" "hired them to make sci-fi movies" "demanded their union cards so they left the set" "help up a mirror and neutralized them" ) ) (define default-template #( #( (ref news-flash) " " (ref peoria) " " (ref attacked) " " (ref monsters) " " (ref from) " " (ref hell) ". Our hero " (ref hero) " " (ref fought) ". " (ref alas) ". " (ref hero) " " (ref success) "." ) ) ) ; ***************************************************************************** (define rndstate 0) (define refn array-ref) ;; return an element from an array (define (main args) (set! rndstate (seed->random-state (current-time))) (display (racter)) (display "\n\n") (exit 0) ) ;; return the size of an array (define (nref a) (car (array-dimensions a))) ;; return a random element from an array (define (ref a) (array-ref a (random (nref a) rndstate))) ;; sling those strings (define (racter) (eval (cons 'string-append (array->list (ref default-template))) (interaction-environment) ) )