-
Notifications
You must be signed in to change notification settings - Fork 0
/
buttons.l
48 lines (37 loc) · 1.03 KB
/
buttons.l
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
# 2019-08-08
# shoshin
(load "@lib/http.l" "@lib/xhtml.l" "@lib/form.l" "@lib/ps.l")
# Game
##----
(default *Bounds '(1 . 100))
(de small ()
(car *Bounds) )
(de big ()
(cdr *Bounds) )
(de guess-my-number ()
(if (> (small) (big))
"you cheated!"
(/ (+ (small) (big)) 2) ) )
(de smaller ()
(unless (str? (guess-my-number))
(set '*Bounds (cons (small) (dec (guess-my-number)))) )
(guess-my-number) )
(de bigger ()
(unless (str? (guess-my-number))
(set '*Bounds (cons (inc (guess-my-number)) (big))) )
(guess-my-number) )
# Gui
#-----
(de guess ()
(app)
(action
(html 0 "Guess My Number" "@sho-pico/buttons.css" NIL
(form NIL
(<div> 'container
(<div> 'main
(gui '(+Style +View +TextField) "guess" '(pack (guess-my-number)))
(<div> 'buttons
(gui '(+JS +Button) "SMALLER" '(smaller))
(gui '(+JS +Button) "BIGGER" '(bigger)) ) ) ) ) ) ) )
(de go ()
(server 8081 "!guess") )