Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
13
Task/Sparkline-in-unicode/Racket/sparkline-in-unicode-1.rkt
Normal file
13
Task/Sparkline-in-unicode/Racket/sparkline-in-unicode-1.rkt
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#lang racket (require syntax/parse)
|
||||
|
||||
(define bars "▁▂▃▄▅▆▇█")
|
||||
(define bar-count (string-length bars))
|
||||
|
||||
(define (sparks str)
|
||||
(define ns (map string->number (string-split str #rx"[ ,]" #:repeat? #t)))
|
||||
(define mn (apply min ns))
|
||||
(define bar-width (/ (- (apply max ns) mn) (- bar-count 1)))
|
||||
(apply string (for/list ([n ns]) (string-ref bars (exact-floor (/ (- n mn) bar-width))))))
|
||||
|
||||
(sparks "1 2 3 4 5 6 7 8 7 6 5 4 3 2 1")
|
||||
(sparks "1.5, 0.5 3.5, 2.5 5.5, 4.5 7.5, 6.5")
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
"▁▂▃▄▅▆▇█▇▆▅▄▃▂▁"
|
||||
"▂▁▄▃▆▅█▇"
|
||||
Loading…
Add table
Add a link
Reference in a new issue