I couldn’t help myself. So here is 90% of what John proposed in HtDP’s ISL+
language. Exercise for the reader: fix the failing tests.
#lang htdp/isl+
;; long division
;; Trace = [cons N [cons N [Listof [List N N]]]
;; N N -> Trace
;; compute the trace for the division of x and y
;; examp
Let me support John’s email with a hint:
#lang htdp/isl+
;; long division
;; Number Number -> (cons Number (cons Number [Listof Number]))
;; compute the list of steps needed to divide x by y
;; work thru an example
;; given 5432, 12
;; wanted [list 452 8) ... optional: (list 54 48) (list 63
> On Sep 7, 2017, at 9:28 AM, jaroslaw.mo...@gmail.com wrote:
>
>
> Dear Racketeers!
>
> I would like to write the function divide in racket, for performing the long
> division, which would print the whole computational process, as the
> elementary school pupils do. For example, the call (div
Dear Racketeers!
I would like to write the function divide in racket, for performing the long
division, which would print the whole computational process, as the elementary
school pupils do. For example, the call (divide 5432, 12) should print this:
5432 : 12 = 452
-48
--
63
-60
--
3
4 matches
Mail list logo