[plt-scheme] SetW routine

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sat Jan 3 20:13:42 EST 2004

1. Look for manuals then srfi in Help Desk. SRFI-13 is your friend.

2. try something like this:

;; String Number -> String
(define (fill x width)
   (substring (string-append x (make-string (abs (- width (string-length 
x))) #\space))
              0 width))

(= (string-length (fill "hello" 80)) 80)
(= (string-length (fill (make-string 90 #\a) 80)) 80)

-- Matthias

On Saturday, January 3, 2004, at 06:21 PM, G. Saini wrote:

>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
>
> 1) Is there an equivelent function to setw (set-column-width) by some
> other name in mzscheme so I don't have to reinvent the wheel?
> 2) If there isn't is it possible to satisfy the following function
> definition?
>
> (define blank " ")
>
> (define (setw n)
>   (define (print-blanks x)
>      (if (empty? x)
>          (printf "~A" blank)
>          (print-blanks (1- x))))
>   (print-blanks (- n
>                    (f (current-output-port)))))
>
>
> Where f is some function that returns the number of columns
> printed out by a last call to printf? The number must be
> reset to zero (i think) everytime there is a newline.
>
>
> thanks!
> --Gurp



Posted on the users mailing list.