This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-10-23
Channels
- # announcements (1)
- # architecture (20)
- # babashka (30)
- # beginners (79)
- # calva (27)
- # cider (8)
- # clj-kondo (1)
- # clojure (125)
- # clojure-australia (1)
- # clojure-berlin (4)
- # clojure-europe (62)
- # clojure-france (1)
- # clojure-italy (6)
- # clojure-nl (4)
- # clojure-uk (12)
- # clojuredesign-podcast (5)
- # clojurescript (28)
- # core-async (31)
- # cursive (14)
- # datomic (47)
- # defnpodcast (1)
- # emacs (7)
- # figwheel-main (2)
- # fulcro (10)
- # graalvm (1)
- # graphql (11)
- # jobs-discuss (8)
- # leiningen (2)
- # off-topic (23)
- # rdf (9)
- # re-frame (3)
- # reagent (1)
- # reitit (5)
- # reveal (12)
- # shadow-cljs (12)
- # spacemacs (1)
- # tools-deps (87)
- # vim (22)
- # xtdb (21)
There is a note at the very bottom of the https://clojuredocs.org/clojure.core/with-meta. Can someone explain to me what it means. The sentence is not complete, and is confusing.
Isn't it clear? It basically says that while for other values with-meta
has no effect on equality comparison, for functions it does:
(= (with-meta [10 20] {:some :meta}) [10 20]) => true
(defn foo [] "hi")
(= foo foo) => true
(= (with-meta foo {:some-more :meta}) foo) => false
(= foo foo)
is to compare vars not functions, isn’t it?
I was confused by the sentence fragment in the test.
So a function is equal to itself, but a function with metadata attached is not equal to the original function.
Functions compare with identity and once you add metadata, they are no longer identical
are any other objects which are compared for identity also capable of attaching to meta data?
Hey hello. Sorry if this question was asked before but how can I get the whole response using cljs-ajax
? :on-success
returns response data only.
I'm mostly interested in status and headers.
I'm talking specifically about [day8.re-frame/http-fx "0.2.1"]
which uses cljs-ajax under the hood
Yeah, but I don't think it will change anything, sincie only response body is returned. So in effect, a string is returned instead of JSON
Anyway, thanks for help. I'm curious how others tackle this issue in re-frame/clojurescript though.
what's the word to use to emphasize that a computation is not lazy?
I want to write a version of map
in my own utils library which does a non-lazy map. similar for mapcat
Or use into with a map transducer
Or mapcat etc
Can anyone help me figure out wtf is going wrong here
(defn in?
"true if coll contains elm"
[coll elm]
(some #(= elm %) coll))
(defn first-unused-between [start finish col]
(if (empty? col) (first-unused-between start finish ["1"]))
(->> (range start (inc finish))
(take-while #(in? col (str %1)))
(last)
(inc)
(str)))
(first-unused-between 1 254 ["1"])
That runs fine, but doing (first-unused-between 1 254 [])
throws a null pointer exception, even though it should be recursively calling the function with col set to ["1"]
if it is passed empty@cgboal521 your if line doesn't do anything; you just if and return the threading expression. Was that your intention?
(if (empty? col) (first-unused-between start finish ["1"]))
I want to call the first-unused-between function with a default value for col if the value passed for col is empty
Did you want this, then? (haven't tested)
(defn first-unused-between [start finish col]
(if (empty? col)
(first-unused-between start finish ["1"])
(->> (range start (inc finish))
(take-while #(in? col (str %1)))
(last)
(inc)
(str))))
Ah okay cool
Yeah so it needs to be inside the if?
Yeah, otherwise you just "compute a result from the if, discard it, and do the next thing anyway"
Ahh okay, that makes sense
Thank you
I am getting "Invalid :refer, var foo.bar/baz" does not exist in cljs. The file foo.bar
is there and it contains a function baz. How do I even start to debug this error?
You actually have a directory named foo.bar
? I suspect that cljs, like clj, expects the namespace foo.bar
to be found in a directory bar
inside of a directory foo
Or rather, in a file named bar.cljs
inside of a directory named foo
No sorry. I have a directory foo
, with a file bar.cljs
. These are both in the same folder as core.cljs. This was a reply to reply 1 btw XD
Understood.
Have you attempted to delete any/all caches of compiler output from previous cljs compiler runs you have made, and then run the compiler again?
I tried running shadow-cljs compile again. I'll try to delete all js-files in target/cljsbuild
too.
Did not work 😕 I must be doing something stupid.
What does the complete ns
form look like inside of your file foo/core.cljs
?
And the function baz
isn't commented out in some way? Or perhaps it is defined after some point where there is a compiler error in the file foo/bar.cljs
, so the compiler never gets that far to see baz
?
(ns ouija.core
(:require
[day8.re-frame.http-fx]
[reagent.dom :as rdom]
[reagent.core :as r]
[re-frame.core :as rf]
[goog.events :as events]
[goog.history.EventType :as HistoryEventType]
[markdown.core :refer [md->html]]
[ouija.ajax :as ajax]
[ouija.events]
[ouija.highlight :refer [highlight] ; offending line
[reitit.core :as reitit]
[reitit.frontend.easy :as rfe]
[clojure.string :as string]
[com.rpl.specter :refer [MAP-VALS]])
(:import goog.History))
If you are willing to try an experiment where highlight
is the first function defined in ouija/highlight.cljs
, that may help determine whether there is some other error in ouija/highlight.cljs
that could be causing trouble.
It is just a toy project. I think you should just be able to git clone and compile
lein shadow watch app
I will experiment
I tried adding the line (defn highlight [])
to the top of the file. Did not change anything.
It might well be due to you having highlight.clj
and highlight.cljs
in the clj
tree as well as highlight.cljs
in the cljs
tree?
> find . -name 'highlight.*'
./src/clj/ouija/highlight.clj
./src/clj/ouija/highlight.cljs
./src/cljs/ouija/highlight.cljs
Oh, wow! Nice catch
Thanks to the both of you.
In clojurescript I want to read the string "MAP-VALS"
and interpret it as com.rpl.specter/MAP-VALS
. Is there a way to do so? I could have a hash-map that connects the two, but I was hoping to do it with read-string
.
If you have required specter, (eval (read-string "MAP-VALS"))
will give com.rpm.specter/...
But there is no eval in clojurescript...
There is resolve: https://clojuredocs.org/clojure.core/resolve huzzah!
So, probably a silly question, but if #(...)
is short for (fn [args ...] (...))
, then why is #(let [...] ...)
short for (fn [args ...] (let [...] ...)
, or am I missing something about #(...)
(or (let [...] ...)
)?
For #()
the argument bindings are implicit, so if you ignore the (fn [args ...]
it slides right in.
@UCW9TUDNK Sure, but that's not the problem here. Its the implicit function application, unless its a let
.
the expression following the # becomes the body of the fn, it is confusing because the parens in #(...)
both act as delimiters of the anonymous function, and as part of the expression (...)
which becomes the body of the anonymous function
another way to think of it is #
starts an anonymous function, where the form that follows it is the body, but that form has to be a list (is wrapped in parens)
another way to understand it would be figuring out which parenthesis correspond to each other in the #(...)
syntax and the (fn [...] (...))
syntax
That's probably one of the best explanations I've heard for it, to be honest!
#parenthesized-thing
=> (fn [...] parenthesized-thing)
or #`(...)` => (fn [...] (...)
)