Fork me on GitHub
#beginners
<
2018-08-12
>
noisesmith00:08:38

make a jar, run plugins that lint or reformat code, deploy to an artifact cache or repo

noisesmith00:08:13

run nrepl without adding nrepl code to your project

athomasoriginal00:08:29

Right. However, those are, relatively speaking, painless to setup on your own (this is a subjective point) and the benefit of doing so is its very clear (if done well) how everything is working. As in, no black box. Would this be a valid statement?

noisesmith00:08:50

I don't know of a linter that works without a lein or boot project

noisesmith00:08:24

there might be a standalone program that makes a jar for a deps.edn project, but if it exists it is not widely used

noisesmith00:08:11

ditto for deployment

noisesmith00:08:45

once you make all of those things easy to do, you run into all the same design decisions that turn leiningen and boot into big slow programs, there's no simple fix for this

athomasoriginal00:08:08

Agreed. It can become large. I think that, if this is unavoidable, the benefit might be that everything becomes a library that could be run without the need for a third party tool like lein.

athomasoriginal00:08:35

kind of like what figwheel.main is doing now

lilactown00:08:20

:thinking_face: seems like eastwood would be easy to run with a deps.edn alias and maybe a few lines of code

noisesmith00:08:30

perhaps - but this work would need to be repeated for each project that uses it, or you package it as a ready to go thing and end up in the same situation you have using these things with lein or boot

stardiviner02:08:10

How to understand the Clojure function arguments destructuring. Who can explain this in more detailed?

bartuka03:08:54

there are any fork of 4clojure being maintained?

seancorfield04:08:39

@stardiviner That is some very confusing code!

seancorfield04:08:31

It says retain can take zero or more arguments. The id in the if-let shadows the id binding in the argument list (bad). args is just bound to the sequence of arguments passed in (which might be empty or...).

stardiviner05:08:03

@seancorfield This code is copied (partly) from book <programming Clojure>. So this :as args is the whole passed in arguments of function retain like (retain 1 2) which args will be ([1 2])? and function retain can be no arguments or if have, then is destructued into [url id]. Then it will be url -> 1, id -> 2 ? I make an simple demo, like this, figured it out:

clojure
(defn parse-args-test
        [& [url id :as args]]
        (println (format "args: %s, url: %s, id: %s" args url id)))

seancorfield05:08:38

args would be bound to (1 2) (not ([1 2]))

seancorfield05:08:35

(retain 1 2) => url : 1, id : 2, args : (1 2)

stardiviner07:08:47

Yeah, I also tried other arguments like (parse-args-test [1 2 3]). then args is bound to ([1 2 3]). Seems the whole argumeents is bound to args, and also arguments is destructed into url and id. I misunderstand that id :as args is kind of args is alias of id.

valerauko07:08:38

:as name binds all the stuff in it to name

stardiviner08:08:00

Is there a way to find out how it is implemented in Clojure internal?

pez09:08:48

The actual binding shouldn't be rocket science, but it would be cool to understand how the destruction is carried out!

sundarj09:08:47

destructuring is done in macros by using the destructure function, like so:

=> (destructure '[[& [url id :as args]] [1 2 3]])
[vec__2429 [1 2 3] seq__2430 (clojure.core/seq vec__2429) vec__2432 seq__2430 url (clojure.core/nth vec__2432 0 nil) id (clojure.core/nth vec__2432 1 nil) args vec__2432]

metal 2
stardiviner09:08:40

Thanks, that's great I can dig deeper to know it.

1
lepistane16:08:36

not sure if this is the right place to ask question but here it goes. Are there any libs for cljs for using google maps that are up-to-date ?or any other map that has direction for that matter, yandex is ok too i found 2 updated 2013/2015 that seems outdated

new clojure student20:08:53

Is there an answer key somewhere? I'm stuck on this problem. I can't figure out the right syntax and there aren't many clues.

jonahbenton20:08:44

Do you know java? The difference between a class and an instance?

jonahbenton20:08:48

That's tough because it's not really a clojure problem, more about interop with the host

jonahbenton20:08:26

One correct answer looks like this. Create an instance of the URL class, then slurp from its openStream method.

jonahbenton20:08:05

The syntax in the question is attempting to call a static or class method on the URL class. The distinction, if one doesn't know java or other OO languages, is definitely not obvious.

mfikes20:08:52

Hrm. That's an odd problem, given that you can just (slurp "") But, perhaps it is attempting to explore interop a bit.

mfikes20:08:52

(`slurp` is a function that takes an HTTP URL as a string and returns the content as a string)

mfikes20:08:57

Ahh, I see. The problem itself states this 🙂

jonahbenton20:08:54

Yeah, looks like it's in a section about interop. Eh, would think it would be better to demonstrate interop for cases where there isn't already an idiom.

porkostomus20:08:56

Is there an easy way to do that in cljs, where we don't have slurp?

mfikes20:08:05

The way to do it would depend on which JavaScript environment your ClojureScript is running in.

porkostomus20:08:47

I was thinking of a web app that would take a URL and parse it to only render relevant sections or something

mfikes21:08:50

With ClojureScript running in a browser that has the fetch API you could grab stuff asynchronously. With the shipping REPL (avoiding CORS), here is an example:

$ clj -m cljs.main
ClojureScript 1.10.339
cljs.user=> (-> (js/fetch "") (.then #(.text %)) (.then prn))
#object[Promise [object Promise]]
cljs.user=> "<!DOCTYPE html> (elided html) </html>"

👍 1
porkostomus21:08:32

Thanks! That was a random lurking question that I couldn't find the answer to because it was too simple.

Jp Soares22:08:06

How should I go for a map with an option key? Should it have the key with an empty value or should I create the key in the map when it's necessary?

mfikes22:08:50

@jpsoares106 I think both ways are common, but I’d say I think the approach of treating a missing entry as representing a default is more frequent (and arguably more flexible)

1
alexmiller22:08:44

absent is strongly preferable to nil

avfonarev22:08:32

Could someone clever, please, explain to me why (->> 1 #(mod % 12)) seemingly returns a function?

avfonarev22:08:28

I do understand why adding extra parens woks, but do not see why it doesn't work as I expected without them.

avfonarev22:08:48

On a more interesting note, when I switch to ->, I get an exception java.lang.Long cannot be cast to clojure.lang.ISeq.

avfonarev22:08:12

I've figured it out using macroexpand, sorry for the inconvenience (I'm not that used to macro heavy languages)

dpsutton22:08:12

(macroexpand '(-> 1 #(mod % 12))) check what this returns

dpsutton22:08:04

but the story is that -> blindly puts things into lists. it's not aware of invocation or anything semantic. All it is doing is putting things into lists

avfonarev22:08:15

@dpsutton it's a good reminder, thank you. I keep forgetting that lisps have an incredibly simple evaluation model