From eeaffb14b8b85c2bcb0e56f4632e42ebab828b08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Lindqvist?= Date: Thu, 16 Jun 2016 23:28:02 +0200 Subject: [PATCH] 24-game: fixing game to use formatting vocab --- extra/24-game/24-game.factor | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/extra/24-game/24-game.factor b/extra/24-game/24-game.factor index f0d43bf66e..1e204630a4 100644 --- a/extra/24-game/24-game.factor +++ b/extra/24-game/24-game.factor @@ -1,8 +1,7 @@ ! Copyright © 2008 Reginald Keith Ford II ! 24, the Factor game! -USING: accessors backtrack combinators continuations io kernel -math math.parser prettyprint quotations random sequences shuffle -; +USING: accessors backtrack combinators continuations formatting io +kernel math prettyprint quotations random sequences shuffle ; IN: 24-game : nop ( -- ) ; @@ -43,9 +42,9 @@ CONSTANT: (operators) { + - * / rot swap q } [ name>> = ] with find nip ; : get-operator ( operators -- word ) - "Operators: " write dup pprint nl flush + dup "Operators: %u\n" printf flush readln over find-operator dup - [ "Command not found..." print get-operator ] unless nip ; + [ "Operator not found..." print get-operator ] unless nip ; : try-operator ( array -- array ) [ pprint nl ] @@ -53,10 +52,10 @@ CONSTANT: (operators) { + - * / rot swap q } bi ; : end-game ( array -- ) - dup { 24 } = [ + first dup 24 = [ drop "You WON!" ] [ - first number>string " is not 24... You lose." append + "%d is not 24... You lose." sprintf ] if print ; : quit-game ( array -- )