This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-11-14
Channels
- # announcements (8)
- # babashka (37)
- # beginners (4)
- # biff (19)
- # cider (18)
- # clj-kondo (52)
- # clojure (26)
- # clojure-brasil (5)
- # clojure-dev (12)
- # clojure-europe (34)
- # clojure-nl (1)
- # clojure-norway (32)
- # clojure-uk (7)
- # core-logic (1)
- # data-science (5)
- # emacs (14)
- # honeysql (11)
- # hyperfiddle (37)
- # jobs (1)
- # malli (4)
- # off-topic (38)
- # pedestal (7)
- # portal (30)
- # releases (1)
- # remote-jobs (1)
- # tools-build (8)
- # vim (12)
Hey community , Anyone familiar on how to do multi insert using HugSQL with an array of maps? From the documentation couldn’t find if there is a way to do the insertion with control over which value goes where Thank you 🙏
Hi, you can have a look here : https://www.hugsql.org/hugsql-in-detail/parameter-types/sql-tuple-list-parameters You have to deal with tuples, but it s easy to convert a map into it.
Thx, the problem with tuples is making sure all the values are in the same order
if you have an array of map you can do something like (map (juxt :id1 :id2) [{:id1 1 :id2 2} {:id1 3 :id2 4}])
Didn’t know about this, thx!
What is the correct predicate to know if x
supports with-meta
?
coll?
seems to work, but not sure about edge cases
I think I would probably try
(instance? clojure.lang.IMeta [])
(instance? clojure.lang.IMeta "")
https://github.com/clojure/clojure/blob/clojure-1.11.1/src/clj/clojure/core.clj#L219C37-L219C54 (instance? clojure.lang.IObj x)
no, there's not
and IObj is what you want (IMeta is for metadata read, IObj is for metadata update)
the main ones are really colls and symbols though
It seems that ChatGPT and I have similar fantasies
(from ChatGPT):
In Clojure, you can determine the arity of a function (i.e., the number of arguments it takes) by using the arity
function from the clojure.reflect
namespace. This function allows you to reflect on the function and get information about its arities.
Here’s a basic example of how you can use it:
1. First, you need to require the clojure.reflect
namespace:
clojure
(require '[clojure.reflect :as reflect])
2. Then, you can use the reflect/arity
function on any function to get its arity. For instance:
clojure
(reflect/arity +) ; For the built-in `+` function
This will return a set of integers, each representing the arity of one of the function’s overloads.
Remember that Clojure functions can have multiple arities (i.e., different versions of the function with different numbers of parameters), so the arity
function returns a set of all possible arities.
If you’re working with a custom function, you can do the same:
clojure
(defn my-func
([a] a)
([a b] (+ a b)))
(reflect/arity my-func)
This should return #{1 2}
, indicating that my-func
has two arities: one that takes 1 argument and another that takes 2 arguments.I also had ChatGPT hallucinate a clojure.lang.Utils/footprint
function for determining the estimated size a data-structure would take up in memory yesterday :^), less than reliable~
I did admire how confident it was, though!
would be a nice world : D, I was mildly confused when evaling that fn was met only with DNE errors, and then I realized I'd been had
I started feeding Clojure documentation to a custom GPT using the new Assistants feature from OpenAI, I wonder at what point it will stop hallucinating (so far it hasn’t but I started with the API docs, not guides from http://Clojure.org ) - I’ll try it out later today :thinking_face:
More deets here https://clojurians.slack.com/archives/C054XC5JVDZ/p1699633801699019
When I use expression in macro (meta &form)
I get something like {:line 9, :column 5}
sometimes, but other times I get nil (especially when macro uses another macro). Why is that?
List literals get position metadata, other forms do not