From 755c44ea1d4b21a6fcbaaf990cf6e5a97a99d3b3 Mon Sep 17 00:00:00 2001 From: MsK` Date: Thu, 9 Dec 2021 12:58:16 +0100 Subject: [PATCH] moved char->number to common.scm --- 04-giant-squid/code.scm | 4 ---- common.scm | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/04-giant-squid/code.scm b/04-giant-squid/code.scm index 9216af8..d8e58dd 100644 --- a/04-giant-squid/code.scm +++ b/04-giant-squid/code.scm @@ -2,10 +2,6 @@ (load "../common.scm") -; returns numbers 0 to 9 from ascii character -(define (char->number c) - (- (char->integer c) 48)) ; 48 is ASCII's number zero - ; returns a number from two characters ; ex: '0' and '9' => 9 ; ' ' and '6' => 6 diff --git a/common.scm b/common.scm index e839719..e21f5c2 100644 --- a/common.scm +++ b/common.scm @@ -7,3 +7,8 @@ [(char=? c #\,) (loop (cons n draws) 0)] [(char-whitespace? c) (reverse (cons n draws))] [else (loop draws (+ (* n 10) (string->number (string c))))])))) + +; returns numbers 0 to 9 from ascii character +(define (char->number c) + (- (char->integer c) 48)) ; 48 is ASCII's number zero +