Fork me on GitHub

bind is in some Clojure library somewhere? I don't know what the #{a} m part is supposed to do, but it doesn't quite look like legal Clojure destructuring syntax.

👍 3

i just made that as a macro specifically so that would work as destructuring syntax


it just expands to {:keys [a]}


Hi all, I work at a rather large company that has very restrictive rules about open source which unfortunately makes it impossible for me (and my colleagues) to use Clojure in production. For some reason the legal departement has decided that it is not ok to distribute software to customers that contain components licensed under EPL 1.0. I am not smart and/or interested enough to understand the implications of the license but I trust Rich more than I trust the knowledge of software in our legal department so I am not arguing any change in license for Clojure. What I am wondering is if there is anyone that has been in a situation like mine and if so what I can do about it, are there any arguments that I can bring to the legals or is there some other way to tackle this? I have reached the point at which I really don’t want to continue programming using (in my view) inferior tools and if I cannot start using Clojure I might have to look around for another job. @alexmiller does Cognitect have any strategy to help or give guidance in cases like these?


The EPL was chosen due to it being enterprise friendly! Seems like a mistake has been made.


Yes, that’s exactly the point, however I think that for me trying to argue with legal is a dead end, so I am looking for advice

Alex Miller (Clojure team)12:09:48

I don’t think either I or Cognitect is in a position to give legal guidance. What are their objections?


I don’t know, in this big company the distance between different parts of the company is very large and the desicions regarding OSS has been defined globally but I will try to get some more detailed information


If I had to guess the policy was set based on the assumption that programmers are not experts enough to evaluate the licenses that code is released under and maybe legal aren't "experts enough to make sure that the code is all under the right license"


So if you want to make some headway, my best guess is that you should talk to legal and help them work out an approval process that works on a case by case basis.


Plus, you definitely use open source software already to some degree if you use any programming language


so they had to have done their legal due diligence at least once


Yes we sure do use open software, however so far nothing licensed under EPL 1.0 so the issue as I see it is that our lawyers have a different understanding of that particular license than the rest of the world


@U39EC6Z7Y Do you have to ship the Clojure library along with your product? Can the product simply download the clojure library as part of the install on the clients site? Then you can use what ever license you like for your own product (which I assume you do anyway). If you are not distributing Clojure then its license is not an issue. Licensing is another reason to build services rather than installed products.


@U05254DQM Thanks for your response! However, I am not in the position of deciding how our products are delivered so unfortunately downloading the Clojure library is not an option since we are delivering docker containers running in a very restricted environment (i.e. not internet connection). I realize that distributing the library makes the license an issue (apparently), however, legal seems to think that EDL (Eclipse Distribution License) is ok and I would really like to understand the difference here. Unfortunately I have not yet received any feedback from legal about their reasoning regarding EPL.


Is it intended that s/keys always checks all keys, even when they are not explicitly mentioned in :req or :opt? Example: (s/def some-spec (s/keys :req [:foo/bar :bar/baz])) Now somewhere else a spec for :example/key is defined. Then if :example/key is present in a map that is checked against some-spec it is checked as well.


The docstring is quite explicit about that


Thank you, I found must have overlooked that explicit part.


Hi guys, to preface this, the qn i'm asking is a coding task I need to complete to register to an event. I think I could have worked it out with Python but they listed Clojure as one of the languages so I wanted to give it a shot ... Given an array of integers, return the smallest set of indices of numbers such that they add up to a target number. You may not use the same element twice.            Examples:            [1,2,6,3,17,82,23,234] -&gt; 26            Solution [3,6]              [1,2,6,3,17,82,23,234] -&gt; 40            Solution [4,6]              [1,2,6,3,17,82,23,234] -&gt; 23            Solution [6] So thus far only have the backbone of what I would want to do. So far have done sorting and filtering out the numbers that would be too high

(defn foo
  ([ls target] (let [new-ls (filter #(> target %)
                                    (sort ls))]
                 (foo (butlast new-ls) target (last new-ls))))
  ([ls target sum] 
    (list ls target sum)))
I was thinking a naive way to solve this would be to iterate through the remaining elements from the back. In the case of 1 2 3 4 5, would 5. So there's a path where you try 4+5, 3+5, 2+5, 1+5. And if it exceeds the target you ignore it. if it is lower, and there are still elements before that you iterate through those. I'm not really sure how I can express this with maps and perhaps making use of multi arity functions for recursion I just realised that I still need to make sure the solution is the smallest set possible .... Anyone has any thoughts or is Clojure not too great for such tasks?


It sounds like a combinatorics problem to me, at least for a brute force approach, so I'd reach for clojure.math.combinatorics and do something like this:

> clj -Sdeps '{:deps {org.clojure/math.combinatorics {:mvn/version "RELEASE"}}}'
user=> (require '[clojure.math.combinatorics :as c])
user=> (defn small-pair [coll n]
         (->> (mapcat #(c/combinations coll (inc %)) (range (count coll)))
              (filter #(= n (reduce + %)))
              (sort-by count)
              (map #(get (zipmap coll (range)) %))))
user=> (small-pair [1,2,6,3,17,82,23,234] 26)
(3 6)
user=> (small-pair [1,2,6,3,17,82,23,234] 40)
(4 6)
user=> (small-pair [1,2,6,3,17,82,23,234] 23)
(it would be more efficient to calculate the zipmap just once in a let at the top, but I was just playing in a REPL to get to this point).


Oh wow :o @U04V70XH6 yeah I was thinking I needed to implement something like this but in clojure


Was gonna attempt to foolhardily reference the python code and make a conversion (if i had time)


The combinatorics library is great for stuff like this. Took me a few minutes to get that exact code above, but it really was just a dozen lines in the REPL looking at the shape of things as I worked from that top line down.


There's actually a function in there called subset that already does the mapcat.


I see I see. Thanks for your help!! :)


But in my opinion, for a programming challenge like that, using the combinatronics lib seems like cheating 😛, the hard part is figuring out how to generate the possible combinations. I don't know the rules of your event, so maybe want to check that


But in idiomatic Clojure you'd just that library yes


Yeah i was thinking about that too :P but technically is part of Clojure similar to math in python hmmm.


I see I see!


It's not though, you need to add an extra dependency on it. So similarly, it won't work if they have some automated runner or something like that


@U0K064KQV Oh, cool, I hadn't read far enough through the docs. I thought there should be an easier way!


(and it's subsets)

✔️ 6

Seems weird that in order to register for an event, you're supposed to solve a programming puzzle... I wonder how they "validate" responses?


I unfortunately don't have a lot of time or energy to work on it. So ill probably just go with combinatorics. It isn't a test runner but we need to explain the solution for this one in a txt doc 😅


Oh is like a algo competition I guess. I was curious because I wouldn't ordinarily think they allow clojure submissions


I consider all the Contrib libraries "fair game" as a sort of "standard library" for Clojure but not everyone shares that view.


(but then I maintain four of them and have helped with several others so I might be a bit biased 🙂 )


Ya that's neat they allow Clojure


I suppose it doesn't matter too much to me if I they don't accept it as a submission - I wanted to use it to motivate me to learn abit more Clojure as I try to tackle problems


Well, I think Rich Hickey does not consider them "core" 😛 Not sure, but the impression I get is such. I personally don't care if its "official" or not as long as it works and does what I need. My perspective is just that I need to add an extra dependency, and that's always an "extra step", so I feel they are not "standard" because of that


It's been decades since I've had to write stuff like combinations from scratch. It's like the tired old stuff with search algorithms in interviews. No one outside the FAANG companies implement this stuff themselves any more.


Good luck with the application @UUSQHP535 and, as you say, it's a good motivation to learn more about Clojure even if you don't get accepted.


Ya, generating combinations is not an easy algo even. I'd consider this a hard question


Mmmmm, unfortunately @U04V70XH6 I think I still need to mindlessly drill such problems depending on what companies I apply for ><

💯 3

But anyhow, thanks guys 😄


Sounds like you got to work out an algorithm for it first. Nothing Clojure can do before that 😝


Right I thought that naive way was kinda an algorithm but I think you got me to find something. Shall try working with that first! :)