Fork me on GitHub
#beginners
<
2020-11-28
>
Joe15:11:52

Is there a simple way to print floats with comma separation with (cl-format nil "???" 1234.56111) => "1,234.56"?

Joe15:11:03

Or another way to achieve the same thing? I can't find something in goog.string that does it either

andy.fingerhut16:11:42

I don't see a way that cl-format can do this. I don't know the Google Closure library well enough to say whether it can, but it seems pretty extensive.

Lu16:11:22

Or just use goog.i18n

Joe13:11:44

Thanks! I just used i18n directly and it worked OK

👍 3
Lu13:11:08

You’re welcome!!

noisesmith19:11:03

user=> (cl-format nil "~:d" 1234)
"1,234"
cl-format can do a lot, the trick is to google for "common lisp format"

noisesmith19:11:39

it's a full turing complete dsl actually

andy.fingerhut19:11:26

That works for integers, but I didn't see anything for floating point numbers.

andy.fingerhut19:11:57

which surprised me, given that it can encode integers as Roman numerals 🙂

andy.fingerhut19:11:16

that is, I didn't see any short built-in format specifier for putting comma-separators in the integer part of a floating point number when printed -- I didn't try to delve into the Turing-complete part of cl-format.

noisesmith19:11:27

yeah, I caught that after pasting my example, it's clearly more complicated to do the commas plus the truncation...

Emanuele16:11:49

Hi, I have a question about using Serveress function related to using a db connection. It's not strictly related to Clojure but I'm using Clojure in this case. In general, when you have a server, a key thing to configure is a connection pool so that you can reuse an existing connection instead of creating a new one every time. How should I handle this when working with a serveless function?

st3fan17:11:27

This heavily depends on the serverless platform you use

st3fan17:11:51

Some platforms keep instances 'warm' .. so if you get enough requests, a connection to the database is still alive.

st3fan17:11:20

You probably want a single connection though - not a pool. Since a serverless function is usually 'one thread'.

st3fan17:11:29

Well, depends on the platform again

Carlo19:11:43

I understand how to update nested maps using assoc-in but how do I add an element to an array in a nested structure when I don't know the length?

seancorfield19:11:14

@meditans update-in with conj is probably what you want.

st3fan23:11:20

Does anyone have experience with integrating something like Sentry in a project? Or an alternative to catch and record exceptions?

AJ Jaro00:11:51

We used to have it integrated but never used it. If you have specific questions I can look in our archives if you'd like. Just let me know