Page 1 of 1

format is broken

Posted: Wed Feb 18, 2004 2:13 pm
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

Posted: Wed Feb 18, 2004 2:49 pm
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"))

Posted: Wed Feb 18, 2004 3:23 pm
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

Posted: Wed Feb 18, 2004 3:43 pm
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

Posted: Wed Feb 18, 2004 3:58 pm
by eddier
Thanks Lutz!

Posted: Wed Feb 18, 2004 4:13 pm
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