beginners

Getting started with Clojure/ClojureScript? Welcome! Also try: https://ask.clojure.org. Check out resources at https://gist.github.com/yogthos/be323be0361c589570a6da4ccc85f58f.
scythx 2020-11-28T00:12:33.496400Z

okay, thank you very much!

scythx 2020-11-28T06:28:29.497500Z

Pretty useful, thank you!

πŸ‘ 1
Joe 2020-11-28T15:10:52.000100Z

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

Joe 2020-11-29T13:26:44.020200Z

Thanks! I just used i18n directly and it worked OK

πŸ‘ 1
Lu 2020-11-29T13:52:08.020900Z

You’re welcome!!

2020-11-30T19:20:03.056700Z

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

2020-11-30T19:20:39.056900Z

it's a full turing complete dsl actually

2020-11-30T19:29:26.057100Z

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

2020-11-30T19:29:57.057300Z

which surprised me, given that it can encode integers as Roman numerals πŸ™‚

2020-11-30T19:31:16.057600Z

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.

2020-11-30T19:38:27.058200Z

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

Joe 2020-11-28T15:17:03.000200Z

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

2020-11-28T16:10:42.000400Z

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.

Lu 2020-11-28T16:17:05.000700Z

This https://github.com/thedavidmeister/cljs-i18n

Lu 2020-11-28T16:17:22.001200Z

Or just use goog.i18n

2020-11-28T16:41:49.001900Z

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?

st3fan 2020-11-28T17:06:27.002300Z

This heavily depends on the serverless platform you use

st3fan 2020-11-28T17:07:51.002500Z

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

st3fan 2020-11-28T17:08:20.002700Z

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

st3fan 2020-11-28T17:08:29.002900Z

Well, depends on the platform again

william 2020-11-28T19:34:43.011400Z

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?

seancorfield 2020-11-28T19:35:14.011800Z

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

william 2020-11-28T19:36:05.012Z

thanks @seancorfield!

st3fan 2020-11-28T23:41:20.012800Z

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