This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-11-28
Channels
- # adventofcode (4)
- # announcements (1)
- # babashka (4)
- # beginners (23)
- # calva (15)
- # cider (8)
- # clj-kondo (30)
- # cljsrn (1)
- # clojure (29)
- # clojure-europe (15)
- # clojure-uk (2)
- # clojurescript (10)
- # community-development (4)
- # cryogen (3)
- # cursive (4)
- # emacs (3)
- # figwheel-main (2)
- # fulcro (13)
- # jobs-discuss (1)
- # kaocha (1)
- # luminus (1)
- # meander (2)
- # off-topic (78)
- # pathom (2)
- # reagent (13)
- # rewrite-clj (56)
- # ring-swagger (2)
- # tools-deps (15)
- # vim (3)
Is there a simple way to print floats with comma separation with (cl-format nil "???" 1234.56111) => "1,234.56"
?
Or another way to achieve the same thing? I can't find something in goog.string that does it either
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.
user=> (cl-format nil "~:d" 1234)
"1,234"
cl-format can do a lot, the trick is to google for "common lisp format"it's a full turing complete dsl actually
That works for integers, but I didn't see anything for floating point numbers.
which surprised me, given that it can encode integers as Roman numerals 🙂
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.
yeah, I caught that after pasting my example, it's clearly more complicated to do the commas plus the truncation...
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?
Some platforms keep instances 'warm' .. so if you get enough requests, a connection to the database is still alive.
You probably want a single connection though - not a pool. Since a serverless function is usually 'one thread'.
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?
@meditans update-in
with conj
is probably what you want.
thanks @seancorfield!