summaryrefslogtreecommitdiff
path: root/examples/abacus/writing.lali
blob: 2ba300bc957091f496b0c93eb066e8c19c3cf9cb (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
;; variables
(set 'max-columns +3)

;; functions
(defun random-number (cases)
  (fill
   ((dif cases +0) (cons (random +9) ()))
   (f (cons (random +9) (random-number (- cases +1))))))

(defun number-to-symbol (num)
  (fill
   ((dif +0 num) '0)
   ((dif +1 num) '1)
   ((dif +2 num) '2)
   ((dif +3 num) '3)
   ((dif +4 num) '4)
   ((dif +5 num) '5)
   ((dif +6 num) '6)
   ((dif +7 num) '7)
   ((dif +8 num) '8)
   ((dif +9 num) '9)))

(defun number-to-earth-rod (num)
  (fill
   ((dif +0 num) "[@-@][@@@@-@]")
   ((dif +1 num) "[@-@][@@@-@@]")
   ((dif +2 num) "[@-@][@@-@@@]")
   ((dif +3 num) "[@-@][@-@@@@]")
   ((dif +4 num) "[@-@][-@@@@@]")
   ((dif +5 num) "[-@@][@@@@-@]")
   ((dif +6 num) "[-@@][@@@-@@]")
   ((dif +7 num) "[-@@][@@-@@@]")
   ((dif +8 num) "[-@@][@-@@@@]")
   ((dif +9 num) "[-@@][-@@@@@]")))

(defun number-to-air-rod (num)
  (fill
   ((dif +0 num) "[@-@@@@][@-@]")
   ((dif +1 num) "[@@-@@@][@-@]")
   ((dif +2 num) "[@@@-@@][@-@]")
   ((dif +3 num) "[@@@@-@][@-@]")
   ((dif +4 num) "[@@@@@-][@-@]")
   ((dif +5 num) "[@-@@@@][@@-]")
   ((dif +6 num) "[@@-@@@][@@-]")
   ((dif +7 num) "[@@@-@@][@@-]")
   ((dif +8 num) "[@@@@-@][@@-]")
   ((dif +9 num) "[@@@@@-][@@-]")))

;; main
(defun main ()
  (progs
   f
   (set 'n-rand (random-number (random max-columns)))
   (print (map number-to-symbol n-rand))
   ;; (print n-rand)
   (newline)
   (read)
   (map (lambda (num) (princ (number-to-earth-rod num)) (newline)) n-rand)
   (read)
   (newline)
   (read)))

;; loop
(defun loop ()
 (fill
  ((main) ())
  (f (loop))))

(loop)