Skip to content

Commit f312f84

Browse files
committed
chore: format arkscript code
1 parent 0fbf2c6 commit f312f84

File tree

4 files changed

+21
-25
lines changed

4 files changed

+21
-25
lines changed

examples/closures.ark

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@
99
# the return value, our closure
1010
# the &name notation is used in the argument list to explicitly capture
1111
# a variable (using deep copy)
12-
(fun (&set-age
13-
&name
14-
&age
15-
&weight) ()) }))
12+
(fun (&set-age &name &age &weight) ()) }))
1613

1714
# we create 2 humans using such construction, just a nice function call
1815
(let bob (create-human "Bob" 0 144))

examples/games/game_of_life.ark

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@
1717
(let neigh (fun (board_ index) {
1818
(let x (math:floor (mod index width)))
1919
(let y (math:floor (/ index width)))
20-
(+ (get board_ (- x 1) y) (get board_ (+ x 1) y) (get board_ x (- y 1)) (get board_ x (+ y 1)) (get board_ (- x 1) (- y 1)) (get board_ (+ x 1) (- y 1)) (get board_ (- x 1) (+ y 1)) (get board_ (+ x 1) (+ y 1))) }))
20+
(+
21+
(get board_ (- x 1) y)
22+
(get board_ (+ x 1) y)
23+
(get board_ x (- y 1))
24+
(get board_ x (+ y 1))
25+
(get board_ (- x 1) (- y 1))
26+
(get board_ (+ x 1) (- y 1))
27+
(get board_ (- x 1) (+ y 1))
28+
(get board_ (+ x 1) (+ y 1))) }))
2129

2230
(let indices (list:iota 0 (* height width)))
2331
(let update (fun (board) {

examples/games/snake/snake.ark

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@
4747
(while (!= x 20) {
4848
(mut case (@ (@ data y) x))
4949

50-
(if (= case 1) {
51-
(sf:set:pos apple_sprite (* 20 x) (* 20 y))
52-
(sf:draw apple_sprite) })
50+
(if (= case 1)
51+
{
52+
(sf:set:pos apple_sprite (* 20 x) (* 20 y))
53+
(sf:draw apple_sprite) })
5354
(set x (+ x 1)) })
5455
(set y (+ 1 y)) })
5556

@@ -108,11 +109,7 @@
108109

109110
(return test) }
110111
(throw "Out of bounds"))))
111-
(fun (&data
112-
&apple_sprite
113-
&draw_board
114-
&has_apple_left?
115-
&eat_apple_at) ()) }))
112+
(fun (&data &apple_sprite &draw_board &has_apple_left? &eat_apple_at) ()) }))
116113

117114
# instanciating
118115
(let board (create-board-object))
@@ -159,14 +156,7 @@
159156
(sf:set:pos snake_sprite (* 20 (@ current 0)) (* 20 (@ current 1)))
160157
(sf:draw snake_sprite)
161158
(set acc (+ 1 acc)) }) }))
162-
(fun (&move
163-
&reset_auto_move
164-
&auto_move
165-
&draw
166-
&pos
167-
&should_move
168-
&last_direction
169-
&snake_sprite) ()) }))
159+
(fun (&move &reset_auto_move &auto_move &draw &pos &should_move &last_direction &snake_sprite) ()) }))
170160

171161
# instanciating
172162
(let snake (create-snake-object))
@@ -201,9 +191,10 @@
201191
(snake.move -1 0 board))]])
202192

203193
# update
204-
(if (= 0 (board.has_apple_left?)) {
205-
(print "you win!")
206-
(sf:window:close) })
194+
(if (= 0 (board.has_apple_left?))
195+
{
196+
(print "you win!")
197+
(sf:window:close) })
207198

208199
(if (= 0 (mod frame 20))
209200
(snake.auto_move board))

lib/std

0 commit comments

Comments
 (0)