This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-11-04
Channels
- # announcements (5)
- # babashka (2)
- # beginners (53)
- # biff (11)
- # calva (5)
- # cider (4)
- # clojure (32)
- # clojure-austin (2)
- # clojure-dev (5)
- # clojure-europe (17)
- # clojure-norway (22)
- # clojurescript (23)
- # core-logic (1)
- # cryogen (1)
- # datomic (1)
- # dev-tooling (7)
- # emacs (6)
- # fulcro (63)
- # guix (1)
- # hyperfiddle (14)
- # integrant (2)
- # lsp (6)
- # missionary (4)
- # nbb (42)
- # overtone (9)
- # reitit (8)
- # specter (3)
- # sql (2)
- # squint (7)
- # tools-build (9)
Good Morning 🙂. When I want to use java methods as map functions, do I have to wrap that in a clojure function? E.g. I do (map #(.toUpperCase %) col)
. Is there a better way?
You can use memfn
instead if you like, but it's never really caught on. Most people would do what you've done.
There was mention of this being looked at for Clojure 1.12 but nothing has been released yet afaik. I think it's a tricky issue to solve.
Is it the issue about java functional interfaces?
Ah no that’s something else I guess
I call it obscure because I rarely see it mentioned or used. But it does the thing you want. Up to you what you prefer, but there's nothing wrong with your original suggestion, it is pretty common to write it like that.
This will be in 1.12 alphas soon
Im doing the clojure koans and I wonder if I solve this one well :
"When things cannot be equal, they must be different"
(not= :fill-in-the-blank :anything_else))
Clojure sorts vectors by length first (the length of a vector being known without looking at the vector's contents). I think this is a fine example. Two very-long vectors with the first 999999999999 items in common, can't be equal if one of them is longer than the other.
And why is this one wrong :
"You may have a multitude of possible paths"
(let [x 5]
(= :your-road (cond (= x 3) :road-not-taken
(= x 6) :another-road-not-taken
:else :your-road)))
@U024X3V2YN4 did you do the koans to learn clojure basics ?
I have tried many languages but cannot make up my mind Last 2 years I spend on learning html, css (flex and grid)_ and js well
oke, for me curiosity. I like to discover languages that does things other then many languages
DOP as defined at https://www.manning.com/books/data-oriented-programming is definitely not data-driven programming as described at https://en.wikipedia.org/wiki/Data-driven_programming
hopefully last question of the day What is here the right answer :
(def giants
(with-meta 'Giants
{:league "National League"}))
(meditations
"Some objects can be tagged using the with-meta function"
(= 'Giants' (meta giants))
read the documentation for with-meta
function
https://clojuredocs.org/clojure.core/with-meta#example-542692c8c026201cdc326a41
I have read it and I see this example
user=> (with-meta [1 2 3] {:my "meta"})
[1 2 3]
so it looks it gives the argument backHi I am trying to use the react-hook-form how can I replicate these piece of code in shadow-cljs
const {
register,
handleSubmit,
watch,
formState: { errors }
} = useForm();
I am not unable to get the errors by doing this
form (form/useForm)
register (.-register form)
handle-submit (.-handleSubmit form)
form-state (.-formState form)
_ (js/console.log (:errors form-state))
errors
will be a nested js obj so you need to continue using interop:
(.-errors form-state)
I like to wrap the return value of useForm
with cljs-bean https://github.com/mfikes/cljs-bean
(let [form-methods (cljs-bean.core/bean (form/useForm))
;; you'll need to also invoke it for formState
form-state (cljs-bean.core/bean (:formState form-methods))
errors (:errors form-state)]
(.-errors form-state)
is not working eitherSorry, without a complete code sample it is impossible to debug what is wrong. But, I would recommend getting more familiar with react-hook-form, Bill (the author of react-hook-form) has put a ton of effort into making high-quality documentation, e.g.: https://www.youtube.com/watch?v=4kzd572NbkM
Hi I am trying to integrate react-hook-form and I am doing something like this and getting the empty object in the console. is there something i am doing wrong ?
(defn signin-panel []
(let [register (.-register (useForm))
handle-submit (.-handleSubmit (useForm))
on-submit (fn [data]
(js/console.log data))]
(let [vals (register "username" {:required true})]
[:input {:props vals
:placeholder "Username"}])
))
Are you actually seeing a log message in the console at all? I can't see on-submit being used anywhere, it's just a local function. Also, style-wise you have a let in a let, should probably be just one let. I'll try to translate what you are doing to plain JS, so you can see what you've written:
function signinPanel() {
let register = useForm().register;
let handleSubmit = useForm().handleSubmit;
let onSubmit = data => console.log(data);
{
let vals = register("username", {required: true});
return ();
}
}