Remix.run Logo
dimitar a day ago

Can you give an example? I can't speak for all possible lisps but Common Lisp and clojure have great string built-ins:

https://lispcookbook.github.io/cl-cookbook/strings.html

https://clojuredocs.org/clojure.string

z_open a day ago | parent [-]

printf("x = %6d\ny = %.8E\n", x, y) ;

What's the equivalent lisp?

mrcode007 a day ago | parent | next [-]

(format t "x = ~6d~%y = ~.8E~%" x y)

taeric a day ago | parent | prev | next [-]

The "format string" capabilities of common lisp are quite advanced. https://gigamonkeys.com/book/a-few-format-recipes is a fun overview.

ramenbytes a day ago | parent [-]

An inelegant weapon, for a less civilized age. And yet, it works.

rscho a day ago | parent | prev | next [-]

You seriously thought that lisps had no printf equivalent ?!

Jtsummers a day ago | parent [-]

People still think that Lisps only offer lists for data structures, which hasn't been true since at least 1960.

zck a day ago | parent | prev [-]

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.