Fork me on GitHub
Jim Newton09:10:31

There is a note at the very bottom of the 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?

Jim Newton09:10:38

I was confused by the sentence fragment in the test.

Jim Newton09:10:03

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

✔️ 1
Jim Newton11:10:53

are any other objects which are compared for identity also capable of attaching to meta data?


can't think of any, this is kind of a special case

✔️ 1
Rafał Wyszomirski09:10:11

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.

Rafał Wyszomirski09:10:02

I'm mostly interested in status and headers.

Rafał Wyszomirski09:10:09

I'm talking specifically about [ "0.2.1"] which uses cljs-ajax under the hood


did you try response-format :raw ?

Rafał Wyszomirski11:10:37

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


perhaps you could write your own response format then


but yeah, it seems somewhat tedious

😉 1
Rafał Wyszomirski11:10:15

Anyway, thanks for help. I'm curious how others tackle this issue in re-frame/clojurescript though.


No idea; but maybe someone in #clojurescript and/or #re-frame would know something

Jim Newton11:10:17

what's the word to use to emphasize that a computation is not lazy?


eagerly ?

Jim Newton11:10:45

I want to write a version of map in my own utils library which does a non-lazy map. similar for mapcat


mapv works eager, afaik. Also, if you want map to be eager, you can wrap it in a doall


Or use into with a map transducer


Or mapcat etc

Calum Boal12:10:54

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)))

(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"]))

Calum Boal12:10:50

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)))

Calum Boal12:10:32

Ah okay cool

Calum Boal12:10:37

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"

Calum Boal12:10:31

Ahh okay, that makes sense


My pleasure :thumbsup:

Endre Bakken Stovner19:10:43

I am getting "Invalid :refer, var" does not exist in cljs. The file is there and it contains a function baz. How do I even start to debug this error?


You actually have a directory named ? I suspect that cljs, like clj, expects the namespace 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

Endre Bakken Stovner19:10:41

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


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?

Endre Bakken Stovner19:10:54

I tried running shadow-cljs compile again. I'll try to delete all js-files in target/cljsbuild too.

Endre Bakken Stovner19:10:39

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 ?

Endre Bakken Stovner19:10:42

(ns ouija.core
    [reagent.dom :as rdom]
    [reagent.core :as r]
    [re-frame.core :as rf]
    [ :as events]
    [goog.history.EventType :as HistoryEventType]
    [markdown.core :refer [md->html]]
    [ouija.ajax :as ajax]
    [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.

Endre Bakken Stovner19:10:07

It is just a toy project. I think you should just be able to git clone and compile

Endre Bakken Stovner19:10:23

lein shadow watch app

Endre Bakken Stovner19:10:26

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.*'

Endre Bakken Stovner19:10:55

Oh, wow! Nice catch

Endre Bakken Stovner19:10:57

Now it works 🙂 :thumbsup:

Endre Bakken Stovner19:10:20

Thanks to the both of you.


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.


At least that's how I see it


@UCW9TUDNK Sure, but that's not the problem here. Its the implicit function application, unless its a let.


Oh, its because let is also surrounded by ()....I think.


Very odd, thanks btw. 🙂


There is no function application though, as #() is a noop (same as (fn []).


Yes. I attribute it to lisp macro "magic" [=


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


#(...) => (fn [...] (...))


not sure how well that formatting emphasis comes through


#(let [...] ...) => (fn [...] (let [...] ...))


mechanically it is the same thing


That's probably one of the best explanations I've heard for it, to be honest!


#parenthesized-thing => (fn [...] parenthesized-thing) or #`(...)` => (fn [...] (...))


Ya, I get it. Thanks. 🙂


I'm just a little more used to Racket macros where that sort of thing is less common. 🙂


Anyway, thanks.