Y
Hacker News
new
|
ask
|
show
|
jobs
by
z_open
328 days ago
printf("x = %6d\ny = %.8E\n", x, y) ;
What's the equivalent lisp?
4 comments
mrcode007
328 days ago
(format t "x = ~6d~%y = ~.8E~%" x y)
link
taeric
328 days ago
The "format string" capabilities of common lisp are quite advanced.
https://gigamonkeys.com/book/a-few-format-recipes
is a fun overview.
link
ramenbytes
328 days ago
An inelegant weapon, for a less civilized age. And yet, it works.
link
rscho
328 days ago
You seriously thought that lisps had no printf equivalent ?!
link
Jtsummers
328 days ago
People still think that Lisps only offer lists for data structures, which hasn't been true since at least 1960.
link
zck
328 days ago
Someone else has given you the Common Lisp version. Here's one for Clojure:
(printf "x = %6d\ny = %.8E\n" x y)
If I've understood everything right, and your example is in C, the format string in Clojure is identical to the one in your comment.
link