How to resolve the algorithm Stem-and-leaf plot step by step in the Racket programming language
How to resolve the algorithm Stem-and-leaf plot step by step in the Racket programming language
Table of Contents
Problem Statement
Create a well-formatted stem-and-leaf plot from the following data set, where the leaves are the last digits: The primary intent of this task is the presentation of information. It is acceptable to hardcode the data set or characteristics of it (such as what the stems are) in the example, insofar as it is impractical to make the example generic to any data set. For example, in a computation-less language like HTML the data set may be entirely prearranged within the example; the interesting characteristics are how the proper visual formatting is arranged. If possible, the output should not be a bitmap image. Monospaced plain text is acceptable, but do better if you can. It may be a window, i.e. not a file.
Note: If you wish to try multiple data sets, you might try this generator.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Stem-and-leaf plot step by step in the Racket programming language
Source code in the racket programming language
#lang racket
(define (show-stem+leaf data)
(define xs (sort data <))
(for ([stem (add1 (floor (/ (last xs) 10)))])
(printf "~a|" (~a #:width 2 #:align 'right stem))
(for ([i xs])
(define-values [q r] (quotient/remainder i 10))
(when (= q stem) (printf " ~a" r)))
(newline)))
(show-stem+leaf (sequence->list (in-producer read eof)))
You may also check:How to resolve the algorithm Colour bars/Display step by step in the Mathematica / Wolfram Language programming language
You may also check:How to resolve the algorithm Terminal control/Ringing the terminal bell step by step in the Phix programming language
You may also check:How to resolve the algorithm Find the intersection of two lines step by step in the Go programming language
You may also check:How to resolve the algorithm Detect division by zero step by step in the M4 programming language
You may also check:How to resolve the algorithm Zebra puzzle step by step in the Standard ML programming language