[racket] multi-line strings in ISL?

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Mon Feb 18 09:30:43 EST 2013

;; language: ISL+
;; teachpack: 
(require 2htdp/batch-io)

;; Nat -> String 
(define (create-product n)
  (local ((define (inner i)
            (cond
              [(= i 0) "(* 11\n"]
              [(< i (- n 1)) (string-append "   " (number->string (* (+ i 1) 11)) "\n")]
              [else    "   55)\n"])))
    (apply string-append (build-list n inner))))
          
(define _dummy (write-file 'standard-out (create-product 5)))


On Feb 17, 2013, at 8:14 PM, Robby Findler wrote:

> I don't know if it is appropriate in your setting, but you could use the racket/pretty library (where you can specify a column width and it will make an attempt to use that width).
> 
> Or, if these are values printing in DrRacket, then you can change the width of the window before they are returned in the REPL and that will control how wide they are printed. It may help to use the horizontal mode (the "View" menu's "Use Horizontal Layout" menu item).
> 
> Robby
> 
> 
> On Sun, Feb 17, 2013 at 4:43 PM, Mitchell Wand <wand at ccs.neu.edu> wrote:
> Is there a good way to create multi-line strings in ISL?  For example, instead of producing output in the form
> 
> (list
>  "(* 11                                                                           "
>  "   22                                                                           "
>  "   33                                                                           "
>  "   44                                                                           "
>  "   55)                                                                          ")
> 
> [where here I've padded the strings out to 80 characters to force the Racket printer to produce each string on a separate line.]
> 
> I'd like to have a program that produced the output
> 
> (* 11
>    22
>    33
>    44
>    55)
> 
> preferably without quotations.  When I put things like #\n #\newline or #\r in the middle of a string, ISL prints them out like #\n, #\newline, or #\r.
> 
> Any ideas?  What have I overlooked?
> 
> --Mitch
> 
> 
> 
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
> 
> 
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130218/68c124ea/attachment.html>

Posted on the users mailing list.