File tree Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change 55 (if (negative? num)
66 (+ (expt 2 32 ) num)
77 num))
8-
9- (define BBGGRR (build-list 6 (λ (n) (modulo (quotient num (expt 16 n)) 16 ))))
10-
11- (define RRGGBB-char
12- (reverse (for/list ([n BBGGRR])
8+ (define BGR (build-list 9 (λ (n) (modulo (quotient num (expt 16 n)) 16 ))))
9+ (define RGB-char
10+ (reverse (for/list ([n BGR])
1311 (cond
1412 [(< n 10 ) (integer->char (+ n 48 ))]
1513 [else (integer->char (+ 97 (- n 10 )))]))))
16-
17- (list->string (cond
18- [(< num 256 ) (drop RRGGBB-char 4 )]
19- [(< num (* 256 256 )) (drop RRGGBB-char 2 )]
20- [else RRGGBB-char])))
14+ (define dropped (dropf RGB-char (curry char=? #\0 )))
15+ (if (zero? (length dropped))
16+ "0 "
17+ (list->string dropped)))
2118
2219(to-hex 26 )
2320(to-hex -1 )
21+ (to-hex 0 )
You can’t perform that action at this time.
0 commit comments