moved char->number to common.scm

This commit is contained in:
2021-12-09 12:58:16 +01:00
parent 663a7fe65b
commit 755c44ea1d
2 changed files with 5 additions and 4 deletions

View File

@@ -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

View File

@@ -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