Skip to content

Instantly share code, notes, and snippets.

@takikawa
Created November 30, 2012 03:49
Show Gist options
  • Save takikawa/4173670 to your computer and use it in GitHub Desktop.
Save takikawa/4173670 to your computer and use it in GitHub Desktop.
#lang racket
(require rackunit)
;; int -> string
(define (line n)
(list->string (build-list n (λ (x) #\*))))
(check-equal? (line 3) "***")
(check-equal? (line 1) "*")
;; listof<int> -> string
(define (histogram lst)
(apply string-append
(for/list ([i lst])
(string-append (line i) "\n"))))
(check-equal? (histogram '(1 2)) "*\n**\n")
(display (histogram '(1 2 3)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment