-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzolu.el
70 lines (59 loc) · 2.24 KB
/
zolu.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
;;; zolu.el ---
;; Copyright (C) 2011 Free Software Foundation, Inc.
;;
;; Author: dove <dove@dove-ThinkPad-T400>
;; Maintainer: dove <dove@dove-ThinkPad-T400>
;; Created: 31 May 2011
;; Version: 0.01
;; Keywords:
;; ====================================================================
;; ==================== 99 bottle of beers ============================
;; ====================================================================
; The following code is copied from http://99-bottles-of-beer.net/
; I just love it.
(defun beer-text (num &optional capitalise)
"Returns a phrase for the given number of bottles of beer.
The phrase is colour-coded red if there are no bottles left or
blue otherwise. If the optional argument CAPITALISE is non-nil,
the first letter of the phrase is capitalised."
(propertize (cond ((= num 0) (concat (if capitalise "N" "n")
"o more bottles of beer"))
((= num 1) "1 bottle of beer")
(t (format "%i bottles of beer" num)))
'face (list :foreground (if (equal num 0) "red" "blue"))))
(defun beer-verse (num)
"Returns a complete verse for the given number of bottles."
(concat (beer-text num t) " on the wall, "
(beer-text num) ".\n"
(if (equal num 0)
(concat "Go to the store and buy some more, "
(beer-text 99) " on the wall.\n")
(concat "Take one down and pass it around, "
(beer-text (1- num)) " on the wall.\n"))))
(defun beer-song-insert (start)
"Inserts the complete 99 bottles of beer song into the buffer."
(let ((n start))
(while (>= n 0)
(insert (beer-verse n))
(when (>= (setq n (1- n)) 0)
(insert "\n")))))
(defun beer-song (start)
"Show the 99 bottles of beer song.
The song is created in a buffer called *Beer song* and the buffer
is displayed. If a prefix is given, the song is started from that
number of bottles, otherwise it starts from 99."
(interactive "P")
(let ((buf (get-buffer-create "*Beer song*")))
(with-current-buffer buf
(kill-all-local-variables)
(erase-buffer)
(beer-song-insert (if start (prefix-numeric-value start) 99))
(goto-char (point-min)))
(view-buffer buf)))
;(defun factorial(n)
; (if (= n 1)
; 1
; (* n (factorial (- n 1)))
; )
;)
;(message "%d" (factorial 6))