summaryrefslogtreecommitdiff
path: root/exercism/emacs-lisp/run-exercises.el
blob: e558d626865d8af89b63c3a083bf2056e8a5e242 (plain)
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
71
72
73
74
75
76
77
(defmacro in-test-window (&rest body)
  `(save-selected-window
     (switch-to-buffer-other-window "*kj/test*")
     ,@body))

(macroexpand '(in-test-window (insert "hello") (insert "world")))

(defun setup-test-window ()
  (in-test-window
   (erase-buffer)))

(defun kj-writeln (msg)
  (in-test-window
   (insert (concat msg "\n"))))

(setup-test-window)

(kj-writeln
 (in-test-window
  (insert (propertize "* Emacs experiments" 'face 'org-level-1))))

(defmacro kj-display (title &rest code)
  `(progn
     (kj-writeln (propertize (concat "** " ,title) 'face 'org-level-2))
     (mapc (lambda (c)
             (kj-writeln (propertize "Code:" 'face 'italic))
             (kj-writeln (format "%S" c))
             (kj-writeln (propertize "Output:" 'face 'italic))
             (kj-writeln (format "%S" (eval c))))
           ',code)))

(load-file "hello-world/hello-world.el")
(kj-display "Hello" (hello))

(load-file "two-fer/two-fer.el")
(kj-display "Two-fer" (two-fer "Annie"))

(load-file "leap/leap.el")
(kj-display "Leap years"
            (leap-year-p 1996)
            (leap-year-p 1900)
            (leap-year-p 2000))

(load-file "anagram/anagram.el")
(kj-display "Anagrams"
            (anagrams-for
             "allergy"
             '("gallery" "ballerina" "regally" "clergy" "largely" "leading")))

(load-file "roman-numerals/roman-numerals.el")
(kj-display "Roman numerals"
            (to-roman 1990))

(load-file "hamming/hamming.el")
(kj-display "Hamming distance"
            (hamming-distance "GGACGGATTCTG" "AGGACGGATTCT"))

(load-file "rna-transcription/rna-transcription.el")
(kj-display "RNA transcription"
            (to-rna "GGACGGATTCTG"))

(load-file "bob/bob.el")
(kj-display "Teenager bob"
            (response-for "What do you think?")
            (response-for "WHAT?")
            (response-for "WHAT!")
            (response-for "Okay"))

(load-file "word-count/word-count.el")
(kj-display "Word count"
            (word-count "They're a large crowd with a crowd with they."))

(load-file "acronym/acronym.el")
(kj-display "Acronyms"
            (acronym "GNU Image Manipulation program"))

(provide 'hello)