format is broken

Q&A's, tips, howto's
Locked
eddier
Posts: 289
Joined: Mon Oct 07, 2002 2:48 pm
Location: Blue Mountain College, MS US

format is broken

Post by eddier »

Code: Select all

(setq data '((1 "a001" "g") (2 "a101" "c") (3 "c220" "g")))
(map (fn (x) (format "%3.2f %5s %2s" (nth 0 x) (nth 1 x) (nth 2 x))) data)
=> ("1.00     g  g" "2.00     c  c" "3.00     g  g")

What happend to the "a001", "a101", and the "c220"?

Eddie

Sammo
Posts: 180
Joined: Sat Dec 06, 2003 6:11 pm
Location: Loveland, Colorado USA

Post by Sammo »

Same results on WIN2K, but (format "%3.2f %5s %2s" 1 "a001" "g") produces the correct result as does (map (fn (x) (list (nth 0 x) (nth 1 x) (nth 2 x))) data) ==> ((1 "a001" "g") (2 "a101" "c") (3 "c220" "g"))

eddier
Posts: 289
Joined: Mon Oct 07, 2002 2:48 pm
Location: Blue Mountain College, MS US

Post by eddier »

I found that the following works as well.

Code: Select all

(map (fn (x) (append (format "%3.2f " (nth 0 x))
                                  (format "%5s " (nth 1 x))
                                  (format "%2s" (nth 2 x))))
  data)


Eddie

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

This bug was introduced in 7.4.5 when taking out the limit of 2048 args in 'format'.

I have fixed this in 7.5.3 which goes up in a couple of minutes into the development directory, but:

CAUTION: in 7.5.3 all deprecated functions are removed as previously announced, look into the chapter 'Deprecated functions', all of these functions have work alikes with different names since many versions, i.e. sublist -> slice etc.. This prompted also changes in cgi.lsp stat.lsp and spam-filter and newlisp-blog and newlisp-wiki.

Lutz

eddier
Posts: 289
Joined: Mon Oct 07, 2002 2:48 pm
Location: Blue Mountain College, MS US

Post by eddier »

Thanks Lutz!

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

There are still code changes necessary in the newlisp-tk.tcl code, so the Windows tk version will go up later. At this moment only a Windows executable which will not work with 1.07-tk environment.

Lutz

Locked