use quasiquote syntax to make things better

This commit is contained in:
Nico 2022-04-06 14:05:21 +01:00
parent d9d7a6ab49
commit df2699c009
1 changed files with 7 additions and 12 deletions

View File

@ -243,16 +243,11 @@
(let ([g (GameState-grid s)]
[f (open-output-file filename)])
(pretty-write
(quasiquote
((player0
(unquote (player-name (first (GameState-players s)))))
(player1
(unquote (player-name (second (GameState-players s)))))
(grid
(unquote (grid-width g)) (unquote (grid-height g)))
(score
(unquote (first (GameState-scores s))) (unquote (second (GameState-scores s))))
`((player0 ,(player-name (first (GameState-players s))))
(player1 ,(player-name (second (GameState-players s))))
(grid ,(grid-width g) ,(grid-height g))
(score ,(first (GameState-scores s)) ,(second (GameState-scores s)))
(lines
(unquote (for/list ([l (grid-lines g)])
(list (point-x (line-from l)) (point-y (line-from l)) (point-x (line-to l)) (point-y (line-to l)) (line-player l))))))) f)
,(for/list ([l (grid-lines g)])
(list (point-x (line-from l)) (point-y (line-from l)) (point-x (line-to l)) (point-y (line-to l)) (line-player l))))) f)
(close-output-port f)))