gnu-emacs-sources
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tarot.el


From: Emilio Lopes
Subject: Re: tarot.el
Date: Wed, 10 Jan 2007 20:47:20 +0100
User-agent: Emacs Gnus

Joe Corneli writes:

> [...]
> (defun draw-tarot-card ()
>   (interactive)
>   (message "%s" (nth (random 78) tarot-deck)))

Better to use arrays in such cases:

(defvar tarot-deck ["Fool" "Magician" "High Priestess" "Empress"
                   "Emperor" "Hierophant" "Lovers" "Chariot" "Strength"
                   "Hermit" "Wheel of Fortune" "Justice" "Hanged Man"
                   "Death" "Temperance" "Devil" "Tower" "Star" "Moon" "Sun"
                   "Judgement" "World" "Ace of Wands" "2 of Wands" 
                   "3 of Wands" "4 of Wands" "5 of Wands" "6 of Wands" 
                   "7 of Wands" "8 of Wands" "9 of Wands" "10 of Wands" 
                   "Page of Wands" "Knight of Wands" "Queen of Wands" 
                   "King of Wands" "Ace of Cups" "2 of Cups" "3 of Cups" 
                   "4 of Cups" "5 of Cups" "6 of Cups" "7 of Cups" "8 of Cups" 
                   "9 of Cups" "10 of Cups" "Page of Cups" "Knight of Cups"
                   "Queen of Cups" "King of Cups" "Ace of Swords" 
                   "2 of Swords" "3 of Swords" "4 of Swords" "5 of Swords" 
                   "6 of Swords" "7 of Swords" "8 of Swords" "9 of Swords" 
                   "10 of Swords" "Page of Swords" "Knight of Swords" 
                   "Queen of Swords" "King of Swords" "Ace of Pentacles" 
                   "2 of Pentacles" "3 of Pentacles" "4 of Pentacles" 
                   "5 of Pentacles" "6 of Pentacles" "7 of Pentacles" 
                   "8 of Pentacles" "9 of Pentacles" "10 of Pentacles" 
                   "Page of Pentacles" "Knight of Pentacles" 
                   "Queen of Pentacles" "King of Pentacles"])

(defun random-aref (array)
  (aref array (random (length array))))

(defun draw-tarot-card ()
  (interactive)
  (message "%s" (random-aref tarot-deck)))

-- 
Emílio C. Lopes
Munich, Germany


reply via email to

[Prev in Thread] Current Thread [Next in Thread]