Fork me on GitHub
#beginners
<
2019-07-09
>
csd00:07:44

What's the point of partition-all ? partition was introduced in 1.0; partition-all in 1.2. It's a subset of the functionality of partition, with the exception that it can create transducers. But transducers weren't introduced until 1.7(?). So why does it exist?

hiredman00:07:20

partition will drop the last x items if the number of items is fewer then the partition size

hiredman00:07:43

I pretty much never use partition for that reason

csd01:07:39

oh weird. imo that's not really clear in the docstring

andy.fingerhut03:07:19

Hopefully it is clearer on http://ClojureDocs.org examples

anantpaatra05:07:45

I would like to make an appeal to seasoned Clojurists: please help with the Clojure Track on Exercism. It lacks exercises and mentors. Currently it takes from weeks to months to get your code reviewed. It's a great tool with a gentle pace, easy installation instructions and a nice interface, but it can only go so far. https://exercism.io

stefan.van.den.oord08:07:15

Is there a convention/guideline on function parameter order? Say I have a function that takes some state and some other arguments, and returns an updated version of that state (based on the values of the arguments). Should I put the state first or last? I know that for threading it doesn’t matter (since we have both -> and ->>). I’m wondering what the consequences are in terms of using that function for “higher order” purposes, recursion, reducing, etc etc.

pradyumna08:07:35

@stefan.van.den.oord common state update like functions (assoc, dissoc etc) have state as first arguments. whereas collection related functions (map, reduce, etc) have the collection as the last arguments. there is no big issue whether you choose last or first. however, the convenience comes into picture when you chain it with other such functions.

jaihindhreddy08:07:37

yup. All the sequence operations take the seq as the last arg, whereas the others take it as the first.

stefan.van.den.oord08:07:44

Exactly, so for my example I can expect more convenience putting it first then, I guess?

jaihindhreddy08:07:48

If you're treating your state as a sequence in that operation, then I suggest the last arg, else the first.

stefan.van.den.oord08:07:18

Clear, thanks a lot!

donaldball13:07:14

My rule of thumb is to generally order my fn args from least likely to change to most likely to change

dhruv113:07:00

is this expected: (map #(%1 %2) '(first second) '((1) (2 3))) returns: (nil nil) Expectation: (1 2)

bronsa13:07:36

you're applying the symbol first, not the function

bronsa13:07:20

('first _) == (get _ 'first)

bronsa13:07:35

i.e.

user=> ('foo {'foo 1})
1

bronsa13:07:57

what you want there is (list first second)

dhruv113:07:12

ah. thanks!

bronsa13:07:18

user=> (map #(%1 %2) (list first second) '((1) (2 3)))
(1 3)

dhruv113:07:56

perfect! thank you.

uwo15:07:00

NOob question here: I run LittleSnitch and was just notified that the code signature for java.clojure.main had been modified (I was notified when it attempted to connect to our nexus installation to pull dependencies via lein) Is it expected that that code signature would change? If not is there something I can do to remedy the situation?

andy.fingerhut15:07:41

I don't know what LittleSnitch is doing there, and a quick scan of its docs (I didn't read thoroughly) showed a mention that the dynamic code signature of a running process changes when/if it loads a dynamic library. There may be other reasons that can happen, too: https://help.obdev.at/littlesnitch/adv-code-signature

uwo16:07:36

ahh, makes sense. Thanks for looking into it for me!

uwo19:07:20

I just un- and re-installed java -- same version newer patch (1.8.0_211), and now my i've had to increase the timeout much more so that lein repl will start. It's definitely the project because removing the user.clj makes it start swiftly (in particular not loading figwheel-sidecar.repl-api in user.clj makes it go faster). However before reinstalling java it was much faster. Any advice on how to debug?

ghadi19:07:44

1.10.1 has a fix for the user.clj stuff

uwo19:07:13

version 1.10.1 of java, then?

uwo19:07:59

doh. 'course. thanks!

ghadi19:07:44

in general I'd move stuff away from user.clj to more purpose built namespaces

uwo19:07:07

Thank you. I'll try to move my team in that direction!

dpsutton19:07:14

interesting. thanks @ghadi

miguelb20:07:09

hi everyone, I have a very noob question but, I’ve been on this for a couple of hours and still stuck. I’m using docker to deploy an app with an deps.edn/uberjar but everytime I run the java command I get Error: Could not find or load main class clojure.main

darioszr21:07:14

do you have in project.clj (assuming you use lein) somethink like this? :main my-namaespece-foobar.core

darioszr21:07:43

looks like you missed that

miguelb20:07:29

works fine if I create the jar locally

noisesmith20:07:45

@miguelb doesn't that USER invocation in Dockerfile change your working directory? Maybe try explicitly putting your generated jar in a system-wide place (eg. /usr/lib/...) and running it from there?

noisesmith20:07:22

I guess if it didn't find the jar at all that would be a different error message though

miguelb20:07:18

@noisesmith I removed the USER line, it worked!

miguelb20:07:26

that was it

miguelb20:07:45

I’ve rewritten this dockerfile so many times and always kept that in

miguelb20:07:48

thanks again

noisesmith20:07:52

I think explicitly putting things to be run or used at runtime into global locations is a good practice anyway (or if you intend for everything to run from a local dir, ensuring you execute everything from that same dir)

noisesmith20:07:21

even just changing user before making the uberjar would sort it

ghadi20:07:36

really shouldn't use mvn/version "RELEASE"

ghadi20:07:43

works, but unsupported

ghadi20:07:26

tools.deps is all about using dependencies as values, and RELEASE is a mutable reference

miguelb20:07:27

@ghadi, noted, thanks