beginners

Getting started with Clojure/ClojureScript? Welcome! Also try: https://ask.clojure.org. Check out resources at https://gist.github.com/yogthos/be323be0361c589570a6da4ccc85f58f.
2021-01-28T00:04:32.023800Z

@noisesmith Reminds me of something I read once about Richard Feynman -- he reinvented / rediscovered parts of trigonometry on his own, and had a period of adjustment when he found out what notation others used for it in math classes.

2021-01-28T00:05:18.024Z

haha, right - as programmers we do a lot of off-roading but sometimes its useful to be able to adopt the official traffic rules and get on the freeway

2021-01-28T00:06:32.024200Z

and the more math I learn (mostly set theory, linear algebra, group theory, category theory so far), the more I see things I used informally / in a very basic way, reformatted to be simpler and more reusable

2021-01-28T00:07:20.024400Z

not claiming to be anything like a Feynman, I'm just fiddling with some numbers

2021-01-28T00:08:47.024600Z

I was impressed that he rediscovered parts of trigonometry on his own before learning it from others. Pretty cool.

2021-01-28T00:12:53.024800Z

he would have been a polymath if he was born two centuries sooner, he was just that kind of thinker

2021-01-28T07:20:17.026800Z

Given this Data structure How could I append to allbooks? (def data-base {:nameHere {:allBooks ["harry potter" "twilight" "hunger games" "hunger games 2" "hunger games 3"]} :horror ["hunger games" "hunger games 2" "hunger games 3"] :love ["twilight"] :count 3}) this works (vector (get-in data-base [:nameHere :allBooks]) "yeash") but not this (update-in data-base [:nameHere :allBooks] (vector (get-in data-base [:nameHere :allBooks]) "worked"))

2021-01-28T07:27:42.026900Z

update-in takes a function which will be given the current value

2021-01-28T07:31:05.027100Z

(update-in
 data-base
 [:nameHere :allBooks]
 conj
 "worked")

2021-01-28T07:33:25.027300Z

Thank you so much, it was driving me kinda nuts. I tried something similar, but conj was in parenthesis.

2021-01-28T07:34:23.027500Z

Ya, when something takes a function as argument, you need to pass it without parenthesis

2021-01-28T07:35:18.027700Z

Or you need to pass in a Lambda, so sometimes you'll see:

(update-in
  data-base
  [:nameHere :allBooks]
  #(conj % "worked"))

2021-01-28T07:40:36.027900Z

Yeah, that looks a lot clearer.

Faris 2021-01-28T08:28:41.031300Z

Hi everyone, in Programming Clojure in the Snake game part there is this section

" 	(​defn​ head-overlaps-body? [{[head & body] :body}]
 	  (contains? (set body) head))
 	
 	(​def​ lose? head-overlaps-body?)

Test lose? against overlapping and nonoverlapping snake bodies:

 	(lose? {:body [[1 1] [1 2] [1 3]]})
 	-> false
 	
 	(lose? {:body [[1 1] [1 2] [1 1]]})
 	-> true"
I have a few questions 1. Why is lose? a def but it is called like a function? 2. Coming from a Ruby background, it seems like lose? is a function calling another function but its definition doesn’t seem to accept any arguments, how does it know it can accept arguments and also pass it to heads-overlaps-body? (which also doesn’t seem to be accepting any arguments in lose?

solf 2021-01-28T08:37:54.031400Z

lose? is not a function calling another function, it's just a variable that points to head-overlaps-body? (defn foo [] 42) is roughly syntag sugar over (def foo (fn [] 42)), maybe that helps you understand the second line in your example

solf 2021-01-28T08:38:47.031700Z

clojure.core/defn
 [name doc-string? attr-map? [params*] prepost-map? body]
 [name doc-string? attr-map? ([params*] prepost-map? body) + attr-map?]
Macro
Added in 1.0
  Same as (def name (fn [params* ] exprs*)) or (def
    name (fn ([params* ] exprs*)+)) with any doc-string or attrs added
    to the var metadata. prepost-map defines a map with optional keys
    :pre and :post that contain collections of pre or post conditions.

Faris 2021-01-28T08:44:46.031900Z

Thanks for your answer, I understand the answer to the first question. But for the second question, I’m still not sure how it works. How does the arguments I passed to lose? get passed to head-overlaps-body?

tvirolai 2021-01-28T08:58:31.032100Z

As @dromar56 pointed out, lose? is a var, essentially an alias for head-overlaps-body?. Calling lose? with arguments is functionally equivalent of calling head-overlaps-body? with them, but the name makes the idea more explicit here.

Faris 2021-01-28T09:08:08.032400Z

I see! Okay thats interesting. Thanks @tvirolai and @dromar56!

raspasov 2021-01-28T09:23:34.032600Z

As everybody pointed out, it is just an alias for the same exact function (effectively giving one function two names which can be used to invoke/call the function). In 7 years of doing Clojure I have never really done such a thing, so it is quite unusual style IMO.

Faris 2021-01-28T09:27:50.032800Z

I’m not sure I have enough experience to comment about the style, I found it in the Programming Clojure book.

raspasov 2021-01-28T09:28:27.033Z

Technically, you can give the function any number of “aliases” like: (def my-name-1 head-overlaps-body?) (def my-name-2 head-overlaps-body?)

raspasov 2021-01-28T09:31:28.033200Z

Programming Clojure is a good book, perhaps for this small-scale example it’s OK. In a real project perhaps I would consider just naming the function lose? and putting a comment like:

(defn lose?
  "We lose the game when the head overlaps the body."
  [{[head & body] :body}]
  (contains? (set body) head))

Faris 2021-01-28T09:32:10.033600Z

Yeah that makes sense, thanks for the tip! :thumbsup:

raspasov 2021-01-28T09:36:37.033800Z

You’re welcome 🙂

evocatus 2021-01-28T11:04:41.037900Z

could you recommend a simple online REPL? Preferably one which allows to edit and run multiline scripts

evocatus 2021-01-28T11:05:03.038200Z

clj/cljs - doesn't matter

2021-01-28T11:06:19.038500Z

https://www.maria.cloud/ like this?

👍 2
evocatus 2021-01-28T11:08:36.038700Z

probably, but I still don't understand how to run a script there, only found the shape drawing tutorial

evocatus 2021-01-28T11:09:51.038900Z

oh, it's like Jupyter notebook and I need to press Enter to create an actual code block

dharrigan 2021-01-28T11:09:59.039100Z

Here's a new one that popped up recently

dharrigan 2021-01-28T11:10:00.039300Z

https://nextjournal.github.io/clojure-mode/

👍 2
💯 1
dharrigan 2021-01-28T11:10:06.039500Z

It'll allow you to type in scripts and execute.

2021-01-28T11:10:06.039700Z

there is another one, but it is not “online” you have to manage it itself - http://gorilla-repl.org/start.html

👍 1
dharrigan 2021-01-28T11:12:15.039900Z

And of course, there is <https://repl.it/languages/clojure>, although you'll need to sign up.

2021-01-28T11:58:53.040600Z

I recently found this new one: https://paiza.io/projects/9-Daq1Zrz1s-al0nqE0YUA?language=clojure

👍 1
agata_anastazja (she/her) 2021-01-28T13:42:46.042400Z

Hello, I am trying to test that if there is an invalid input there will be an ExceptionInfo using thrown-with-msg?``

agata_anastazja (she/her) 2021-01-28T13:44:02.042600Z

let’s say

(defn validate-input [input]
   (if true
     (throw (ex-info "invalid input" {:input input}))
     nil))

agata_anastazja (she/her) 2021-01-28T13:44:47.043300Z

(deftest input-validation
  (testing "when validating"
    (is (thrown-with-msg? ExceptionInfo #"invalid input"
                          (validate-input "input"))))

evocatus 2021-01-28T13:45:23.043600Z

tried to run gorilla-repl and it doesn't work

agata_anastazja (she/her) 2021-01-28T13:45:50.044Z

but it’s failing

agata_anastazja (she/her) 2021-01-28T13:47:15.044800Z

it’s saying that ex-info returns an error dictionary instead of actual error

agata_anastazja (she/her) 2021-01-28T13:47:48.045200Z

so what would be a better test for this scenario?

alexmiller 2021-01-28T13:50:55.045700Z

that code looks right to me (except input-validation is missing an end paren)

👍 1
🎉 1
alexmiller 2021-01-28T13:51:25.046100Z

are you sure your repl state matches your code?

agata_anastazja (she/her) 2021-01-28T13:53:56.047500Z

ok more context

expected: (thrown-with-msg? ExceptionInfo #"invalid input" (convert "dsfds"))
  actual: #error {
 :cause "It is possible to parse only numbers from 0 to 1000"
 :data {:input "dsfds"}
 :via
 [{:type clojure.lang.ExceptionInfo 
   :message "invalid input"
   :data {:input "dsfds"}
   :at [numerals_kata.core$validate_input invokeStatic "core.clj" 13]}]
 :trace [[ .... ]]}

agata_anastazja (she/her) 2021-01-28T13:54:09.047800Z

this is what the test returns 🙂

agata_anastazja (she/her) 2021-01-28T13:55:56.048600Z

yes, the bracket is there in the original file. I just took one test out of deftest, that’s why it was missing here.

Thor 2021-01-28T13:56:00.048900Z

for what it's worth, your first code sample runs fine for me, and passes (after adding a closing paren, that is).

👍 1
🦜 1
clyfe 2021-01-28T13:57:18.049500Z

issue is: #"invalid input" does not match "It is possible to parse only numbers from 0 to 1000"

👍 1
🎉 1
clyfe 2021-01-28T13:57:38.049700Z

Looking at that error there.

agata_anastazja (she/her) 2021-01-28T13:57:45.050100Z

ha! it does work!!!!

agata_anastazja (she/her) 2021-01-28T13:58:08.050700Z

yes, I was checking for different strings!

agata_anastazja (she/her) 2021-01-28T13:58:13.050900Z

thank you all!

agata_anastazja (she/her) 2021-01-28T13:59:07.051600Z

I just spent 20 minutes looking at a string that was almost right….

2
2021-01-28T14:01:12.052700Z

A lot of programming experience is these kinds of 20-minute episodes, that in future lead you to ask different questions and check different things when things are going wrong, and the next time it will probably be less than 20 minutes 🙂

🎯 5
➕ 2
agata_anastazja (she/her) 2021-01-28T14:39:38.054400Z

@jaihindhreddy by the way, hello to this amazing mentor from exercism!

👋 1
2021-01-28T16:07:13.055900Z

👋

👋 1
2021-01-28T16:07:37.056500Z

Is there a function similar to transduce or reduce that calls the completing 1-arity of a reducing step function?

2021-01-28T16:08:00.057Z

Something like (rf (reduce rf source-seq))

2021-01-28T16:08:29.057600Z

I've been solving by doing this but it feels wrong: (transduce (map identity) rf source-seq)

❔ 1
2021-01-28T16:09:12.057700Z

from here: https://guide.clojure.style/#body-indentation why is this good?

(when something
  (something-else))
while this is bad?
(filter even?
  (range 1 10))
is it simply because the (something-else) part is the body arg of the when macro?

dpsutton 2021-01-28T16:10:37.058800Z

that guide is entirely subjective and just some people's opinions. I happen to agree with this one though. the when establishes a kind of context that (something-else) is executed in. for filter the args are of equal importance so I like them to be aligned.

clyfe 2021-01-28T16:11:33.059400Z

when is macro, filter is function

2021-01-28T16:11:59.060100Z

right, but even this style guide uses this language: “Vertically align function (macro) arguments spanning multiple lines.”

2021-01-28T16:12:15.060500Z

it seems to elide them, at least in my reading

dpsutton 2021-01-28T16:12:41.061100Z

some people do like that style of arguments staying to the left as far as possible as it can prevent lines from getting too long. I much prefer the alignment as it makes visually scanning the forms easier but sometimes it does get tedious in line length

clyfe 2021-01-28T16:12:52.061400Z

vertically align both, but macros get 2 spaces

dpsutton 2021-01-28T16:13:39.061900Z

(when true
  (foo)
  (bar))

;; horrendous
(when true
      (foo)
      (bar))

dgb23 2021-01-28T16:14:03.062400Z

with if ?

dgb23 2021-01-28T16:16:06.063800Z

also what do people think of aligning associative forms (maps)? I almost never see it. When looking at the fulcro tutorials I saw Tony Kay doing it and I immediately copied it.

dpsutton 2021-01-28T16:17:20.064900Z

love to read it hate to see a diff where a single line changes the entire map. same with binding forms in let. those are the major arguments on each side. where you land on that seesaw is pretty personal and not standardized from what i can tell

👍 1
2021-01-28T16:17:59.065Z

The identity transducer is just identity, you don't need to map it

👍 1
clyfe 2021-01-28T16:20:14.066600Z

@jeffrey.wayne.evans so the answer is "the 2nd is bad because looking at it does not convey it's a fn call (as opposed to a macro, which it isn't)"

2021-01-28T16:21:02.066700Z

thanks. I imagine this becomes automatic over time, but I also presume some editors are aware of this magic and can actually follow it

2021-01-28T16:21:27.066900Z

I mean, source and doc are always at the ready

clyfe 2021-01-28T16:22:39.067600Z

Don't align. Better git history, and more compact code (at the expense of visual rhythm). Same for let bindings.

dpsutton 2021-01-28T16:22:52.068Z

in cursive control-q or f1 are amazing. a nice little popup of the source along with clojure-doc examples

1
2021-01-28T16:24:00.069500Z

wait, you use Cursive too? 😆

dgb23 2021-01-28T16:24:19.070100Z

I think Go did it right. They only have 1 way to format things, no configuration. The only sensible alternative is to individually format during development, while the checked in code is formatted by the “one true way” (or not at all). I don’t see the cost-benefit there though.

2021-01-28T16:24:46.070300Z

hell, even mouseover seems to get you that

dgb23 2021-01-28T16:26:13.070500Z

Ou right! I get it, you get formatting commits this way obviously

dgb23 2021-01-28T16:26:20.070700Z

I dislike those too

dpsutton 2021-01-28T16:26:51.071Z

i do every now and then. i have a paid license because its really great software. If i did more interop i might look at switching or having it more at hand. its interop story is top notch

dpsutton 2021-01-28T16:27:05.071200Z

emacs can't compete with cursive's and intellij's java knowledge

clyfe 2021-01-28T16:27:23.071400Z

"with clojure-doc examples" you say?

dpsutton 2021-01-28T16:27:24.071600Z

> hell, even mouseover seems to get you that what's a mouse?

😀 1
dpsutton 2021-01-28T16:27:43.071900Z

yup. really slick. CIDER implemented it after colin did i believe because its so handy

2021-01-28T16:28:37.072100Z

example:

dpsutton 2021-01-28T16:29:38.072500Z

there's also a quick peek for source which is super super nice but i forgot the key binding at the moment

alexmiller 2021-01-28T16:33:18.073300Z

I formatting lisps is inherently harder because the syntax is more uniform but the semantics vary more

➕ 1
alexmiller 2021-01-28T16:33:30.073500Z

that's counter-intuitive

dgb23 2021-01-28T16:35:43.074900Z

That makes sense. The syntax doesn’t express as much. It’s essentially an AST.

alexmiller 2021-01-28T16:35:56.075200Z

invocation itself is an abstraction and thus inside calls lurk lazy/eager eval (function/macro), unstated structure (literal maps), flow control, etc

2021-01-28T16:41:38.076100Z

https://tonsky.me/blog/clojurefmt/ there is an alternative opinion on the formatting rules

2021-01-28T16:42:30.076800Z

in nutshell — there are just two rules: • Multi-line lists that start with a symbol are always indented with two spaces, • Other multi-line lists, vectors, maps and sets are aligned with the first element

pavlosmelissinos 2021-01-28T16:54:09.076900Z

git diff has the -b flag though, so diffs can look essentially the same, whether you align maps or not. https://git-scm.com/docs/git-diff#Documentation/git-diff.txt--b

👍 1
danieroux 2021-01-28T17:01:18.077200Z

I use these. They stay out of my way. That makes me happy.

dgb23 2021-01-28T17:58:55.084Z

Recently there was a question of suitability of Clojure for certain types of computation. One of the downsides that was mentioned was higher memory pressure. But two performance upsides of FP are easier parallelisation and caching/memoization, since we’re dealing with (pure) functions in much larger quantities. How naive is it to think that it could be beneficial to skew to scaling vertically rather than horizontally given these tradeoffs? AKA requesting/using more cores and more memory, while optimising code to be concurrent, with heavy use of memoization (at the right places) instead of building smaller pieces that are scaled more horizontally with more machines (and more IO)?

dgb23 2021-01-28T18:00:03.084600Z

Also if anyone has recommended reading about this issue I would be stoked!

phronmophobic 2021-01-28T18:05:40.087Z

martin thompson has talked a lot about vertical vs horizontal. specifically, the limitations imposed by amdahl's law and little's law. He's done a bunch of interesting writing and given presentations on the subject. here's two to get started: • https://www.infoq.com/presentations/mechanical-sympathy/https://www.infoq.com/presentations/LMAX/

phronmophobic 2021-01-28T18:08:16.087800Z

another notable proponent of vertical scaling is the stack overflow team: http://highscalability.com/stack-overflow-architecture

dgb23 2021-01-28T18:11:37.088300Z

thank you @smith.adriane!

2021-01-28T18:32:47.090900Z

saying clojure has "higher memory pressure" is tricky, because it is open ended, higher than what? a better way to put might be "clojure leans hard on the garbage collector"

✔️ 1
2021-01-28T18:38:28.093900Z

although even that is problematic, because some things like everything being references and strings taking a lot of memory, are not features of clojure but of the jvm (and subject to change as the jvm changes, the string thing has gotten debatable better)

2021-01-28T18:39:58.094900Z

thx!

2021-01-28T18:40:08.095100Z

and the oracle and openjdk jvms ship with multiple different possible gcs, along with alternative jvms like zing shipping with their own high performance gc

2021-01-28T18:44:15.097600Z

so sort of maybe you can say something like "for a given task, among some set of programming languages, with naive task implementations, assuming the jvm languages would tend towards using more memory then others, and assuming clojure would tend to use more memory than java, would not be terrible starting assumption"

💯 1
2021-01-28T18:54:33.097700Z

that's the long term dream of much fp lang development (it's what haskell banks on especially), it's still a strategy and still has trade offs though

2021-01-28T18:55:41.097900Z

(to be clear I wasn't saying "don't use clojure because it uses too much RAM", but when prompted for use cases where you wouldn't use clojure I listed some criteria, and if you meet multiple criteria clojure might be an unpragmatic choice)

2021-01-28T18:57:50.098100Z

in real world cases these trade offs increase complexity of code for high performance in a specific use case the drawback here (generally) is that your code is harder to write and read, and outside the specific target case it is worse than the naiive approach

Lyderic Dutillieux 2021-01-28T19:30:42.101500Z

Hey ! I'm working on a fullstack Clojure(Script) project. The backend is a pedestal API, and the frontend is a Reagent app that calls this API. I'm wondering if an "instrospection" tool exists to introspect the backend API and generate frontend services that I could just call with apropriate params. Ever heard of something like this before ?

Marco Pas 2021-01-28T19:37:52.105600Z

If i have a list of hashmaps how can i get a new list with hashmap only with the specific keys included?

(def data [{:user "foo"
            :name "foo-name"
            :age 20}
           {:user "bar"
            :name "bar-name"
            :age 24}])

[{:user foo, :name foo-name, :age 20} {:user bar, :name bar-name, :age 24}]
I want to only get the keys and values from a subset like :user and :name
[{:user foo, :name foo-name} {:user bar, :name bar-name}]

2021-01-28T19:38:50.106100Z

@marco.pasopas (select-keys m [:user :name])

Lyderic Dutillieux 2021-01-28T19:39:01.106200Z

You should have a look at select-keys https://clojuredocs.org/clojure.core/select-keys

Marco Pas 2021-01-28T19:42:35.106500Z

Need to refrase my question 🙂 I want to get the keys / values from the list of hashmaps

Marco Pas 2021-01-28T19:43:49.107200Z

@noisesmith Need to refrase my question 🙂 I want to get the keys / values from the list of hashmaps..

[{:user foo, :name foo-name, :age 20} {:user bar, :name bar-name, :age 24}]
to
[{:user foo, :name foo-name} {:user bar, :name bar-name}]

dpsutton 2021-01-28T19:44:51.108100Z

(map (fn [m] (select-keys m [:user :name])) data) If you can do it once you can do it many times with map

Lyderic Dutillieux 2021-01-28T19:45:22.108200Z

Yes, then you can map through the list with (mapv #(select-keys % [:user :name]) data)

Marco Pas 2021-01-28T19:46:59.109100Z

@dpsutton Thanks!! Going to digest how this works 🙂

2021-01-28T19:47:05.109300Z

yeah, I'd avoided the specific solution (because you might already be iterating the collection somewhere), but map is what usually get used

👍 1
Marco Pas 2021-01-28T19:47:35.109900Z

Thanks all for answering a real newbie question 🙂

dpsutton 2021-01-28T19:48:44.110500Z

for sure. check out (doc map) (or use your editor specific commands to see documentation) for an explanation of how map works

dgb23 2021-01-28T20:21:12.110800Z

Thank you for those pointers!

Daniel Stephens 2021-01-28T20:33:49.111200Z

Maybe something like swagger is what you are after. Looks like there is support for ring - https://github.com/metosin/ring-swagger https://github.com/metosin/ring-swagger-ui I have only used it with Java personally, so I can't vouch for those libraries!

Lyderic Dutillieux 2021-01-28T20:56:26.111600Z

Thanks, I'll have a look rn 😉

Daniel Stephens 2021-01-28T20:57:00.111800Z

Turns out it's super easy to get the example going, not sure on how easy it would be to add in later:

lein new compojure-api dice-api \
&amp;&amp; cd dice-api/ \
&amp;&amp; lein ring server 

🤘 1
Lyderic Dutillieux 2021-01-28T21:04:07.112100Z

I've already used swagger on non-clojure projects. The lib route-swagger seems to support pedestal APIs' route definitions like here : https://github.com/frankiesardo/route-swagger/blob/8ebab45d03cb43fdec323b955f5ae4c152814d39/example/src/sample/service.clj#L279 Great. Thanks for the hint

👍 1
MatthewLisp 2021-01-28T21:33:31.114300Z

Clojurists, i believe you'll know how to do this easily, and i'm having trouble it's a simple transformation: [:a 1 :b 2 :c 3] -> {:a 1 :b 2 :c 3}

MatthewLisp 2021-01-28T21:38:23.114600Z

just realized i can use partition to do this 😄

2021-01-28T21:40:05.114900Z

@matthewlisp hash-map

1
tws 2021-01-28T21:40:57.115400Z

(apply hash-map [:a 1 :b 2]); =&gt; {:b 2, :a 1}

2021-01-28T21:41:00.115600Z

apply assoc would also work if hash-map didn't exist

Mark McQuillen 2021-01-28T21:49:36.116600Z

Does anyone know how to deploy the static files created with Clojurescript to Heroku? I'm getting an error when I try to deploy the whole repo.

2021-01-28T21:58:54.117600Z

Does anyone know if their is a library that recreates this, or is similer. Its a checkbox but in the command prompt. This is an example when creating a new gatsby project. You hit enter and it puts a start by that line. I tried pretty.cli, but its really buggy for my computer.

2021-01-28T22:06:17.118200Z

I don't think lanterna has that built in, but it has the pieces you could use to do that https://github.com/mabe02/lanterna

phronmophobic 2021-01-28T22:09:54.118800Z

currently, only support for fullscreen (via lanterna), https://github.com/phronmophobic/terminal-todo-mvc

2021-01-28T22:10:36.119500Z

Ill give it a shot. I have been wanting to learn how to use java from clojure anyways. 2 birds 1 stone right.

phronmophobic 2021-01-28T22:10:52.119700Z

@santosx99xx, it's also graalvm compatible

2021-01-28T22:12:27.119800Z

Ill check this out too.

2021-01-28T22:12:35.120Z

Thank you.

phronmophobic 2021-01-28T22:13:52.120200Z

if you have any questions or run into any issues, feel free to ping me or file an issue

👍 1
2021-01-28T22:14:48.120400Z

there are many options in the jvm itself to do that as well (and for the most part the only hard things about interop are that java apis tend to be worse than clojure ones and inheritance sucks)

👍 1
sova-soars-the-sora 2021-01-28T22:40:22.121100Z

Using google translate sometimes i get a result back such as "It&#39;s time"

sova-soars-the-sora 2021-01-28T22:40:32.121400Z

Is there a way to turn that back into a normal apostrophe / etc?

sova-soars-the-sora 2021-01-28T23:01:07.121800Z

url decode?

2021-01-28T23:06:03.122600Z

it's not a URL though, you need an HTML unescape, which seems not to be present in the vm

2021-01-28T23:06:11.122900Z

(which I found surprising)

sova-soars-the-sora 2021-01-28T23:06:24.123200Z

gasp

2021-01-28T23:06:50.123800Z

the googles say use some random apache lib, but I can't tell you if that's even worth it

sova-soars-the-sora 2021-01-28T23:07:00.124100Z

maybe it's enough to do a regex for apostrophes and that jazz

2021-01-28T23:07:33.124800Z

a regex that matches character escapes then uses the Char constructor shouldn't be hard

sova-soars-the-sora 2021-01-28T23:08:57.125600Z

a spec catalogue for christmas... how did you know??

sova-soars-the-sora 2021-01-28T23:09:00.125800Z

xD

sova-soars-the-sora 2021-01-28T23:09:38.126100Z

mm the results i'm getting are the #&38; variety

sova-soars-the-sora 2021-01-28T23:10:14.126400Z

i can't be the first human on the internet with this problem

2021-01-28T23:10:24.126900Z

)user=&gt; (Character/toString 38)
"&amp;"

✅ 1
2021-01-28T23:10:30.127100Z

that plus a regex

2021-01-28T23:10:30.127200Z

yes, people use the apache library

2021-01-28T23:12:15.128200Z

the jvm undoubtedly has infrastructure for dealing with this in its xml processing stuff, but who wants to deal with that

sova-soars-the-sora 2021-02-03T04:56:56.416900Z

Pretty much the only one that arose was the apostrophe so... 1 regex later it's resolved XD

dgb23 2021-01-28T23:48:32.131500Z

something that is incredibly frustrating about languages like JS is keeping track of all the things in your head that you need to change or not change at specific points in time, because equality checks for references and not for values and some libraries force you to think about these things. The more I write in Clojure, the more I realise how mentally taxing this is! That said, when dealing with such APIs with Clojure/Script: are there pragmatic techniques/pointers to contain this issue?