Fork me on GitHub

i want to define a function that given an argument, it returns true when as long as one of the four functions f1-f4 returns true?


how to write it in a concise way?


You might want to check every-pred for inspiration (if you're only interested in the answer, check some-fn)


yes. what’ i need is some-pref


clojure can be so easily mis-written because if you don’t know that function.


there's my personal favorite function juxt


((juxt nil? empty?) '()) => [false true]


Yup, hard to find out about what you don't know yet. This is a very useful resource (given 4 fn-like args, what could I use to get another function back?):;ret=fn%3F&amp;more=true)


it's very terse, to the point of not making sense but it takes a series of functions, and returns a function, that when applied to an argument(s) returns a vector of the results of those functions applied to the arg


@aisamu for example, i want to find all the agent related functions


how can i achieve that?


The Clojure cheatsheet does not include all Clojure functions, but definitely all of the most commonly used ones, and some of the not-so-commonly used ones. They have been separated into categories based upon their use and capabilities. If you click on the "Source repo" link near the top you can find other variants of the cheatsheet, e.g. some of them have what I consider nicer-looking tooltips when you hover the cursor over a function name, showing the doc string for the function. Also a name search box near the top.


Coming from Haskell world, I often surprised, why there are so many unnecessary functions in core - i.e. remove as duplicate of filter (not), or keep, or above example ((juxt nil? empty?) '()) as duplicate of (mapv #(% '()) [nil? empty?])


I suspect they were added for convenience of use.


Out of curiosity, have you found no unnecessary functions in Haskell, or simply fewer than in Clojure?


Looks like, but imho there should be a balance between convenience of use and hardness to remember many functions


Also, while ((juxt nil? empty?) '()) can be considered as a duplicate of (mapv #(% '()) [nil? empty?]), note that (juxt nil? empty?) is a function in its own right that can be passed to other functions, returned from a function as a value, etc., where your second expression doesn't make such a function easily separable in that way.


No problem, if you work only with one blab, you can remember all its personal functions. But I think more uniq things - more comlexity. And there is not a big problem to wrote (fn [x] (mapv #(% x) [nil? empty?]))


@ivana remember that clojure is not curried like haskell, so the existence of remove/juxt is also convinient for higher order use

👍 4

consider (swap! a remove pos?)


A library should do one thing well ex. routing, ui or state A framework will have a bunch of batteries, usually routing, ui and state

👍 8

other way to think about it: framework will impose certain kind of structure in your application, library will not (usually)


Hey guys, I’m trying to disable assertions checks(pre/post hooks) for production code, but could not figure out a way to do so. It seems to be a setting for the Clojure compiler, not having effect in runtime. Wondering what is the proper way to set *assert* to false before code is compiled. Tried many things and nothing seems to be working. We’ll bundle the code as an uberjar.


@joaohgomes what are you using to compile?


if it's ordinary clojure code, you can (set! *assert* false) before calling compile, if it's leiningen:

Suni Masuno15:06:33

leiningen isn't the most common way to compile?


We are packing using: clojure -A:pack mach.pack.alpha.capsule ./target/my-app-api.jar -e build-dir --application-id my-app-api --application-version "$(git describe --tags)" -m my-app.main


can't help you there, you need to run some code before pack starts compiling


perhaps ask / file an issue


(set! *assert* false) in user.clj perharps


(Possibly better behavior is clojure to initialize *assert* to the JVM assertion status)


We are not loading user.clj in prod code. We tried (set! assert false) as the first line of the main file. Apparently, the require will load and compile before *assert* could be se to true false


not in prod code, in the classpath of that clojure invocation


need assert to be off before pack runs compile


you can always turn them off at the jvm level -da


no that won't work, never mind

Drew Verlee18:06:58

Whats the current state of the art in terms of Repl driven development? For example, last i checked, it was easier to just restart your repl when you added a new dep. Is that still the case?


i see conflicting goals between "state of the art" and "easier". I always just restart my repl as I don't often add new things and its easiest for me to know i'm back in a clean state. I think deps.edn has a branch with this feature and nrepl has teased that its coming? possibly already landed. nrepl-refactor has had this for a while and I believe it is working with the current CIDER

Drew Verlee18:06:44

I suppose don't see this as conflicting with anything. I just want to add some functions to my system. Reloading everything up to that point should ideally result in the same state. I suppose it because i'm not relying on any outside state. I'll take a look at nrepl-refactor 🙂


probably hasnt landed yet but theres this

Suni Masuno19:06:54

Any guides on laying out the namespaces in a green field project?

Suni Masuno20:06:44

I more meant how to divide the logic within an application into namespaces. How are people architecting solutions?


I don't think there's really any "standard" way in the community.

Suni Masuno20:06:54

Are there positions and ideologies?


Some people like a fairly flat structure, with broad namespaces, some prefer a more deeply nested structure with more focused, shorter namespaces.


I think probably the only common thread is to separate different concerns, e.g., persistence from business logic, and to try to organize via "domain" concepts where possible.

Suni Masuno20:06:16

Having recently bounced through Redux and Elm I was wondering if there were any architectural ideologues floating around.


Clojure source 279 files 67068 total loc,
    3118 fns, 641 of which are private,
    423 vars, 29 macros, 60 atoms,
    580 specs, 21 function specs.
Clojure tests 308 files 19301 total loc,
    4 specs, 1 function specs.
So we have over 85k lines of Clojure with close to 300 source namespaces (and just over 300 test namespaces) and our source code averages about 200 lines per ns with our longest one being 2,000 lines (and only a handful are 1,000+).

👍 4

No, Clojure is not very prescriptive about architecture, beyond trying to keep side-effects at the edges.

Suni Masuno20:06:47

Those numbers are... awesome


We've been developing this since 2011 and it powers the back end of all our dating sites (about 40 or so of them), as well as a few dedicated Clojure web apps.


Our approach to namespace organization has evolved over that time too, both in naming and actual organization.


We started broad and flat and we've gradually moved into narrower, more focused namespaces as we've refactored old code and added new code.


@drewverlee FWIW, I just restart my REBL/Socket REPL combo if I change/add new dependencies. That said, I don't do that very often so my REBL instance tends to stay up and running for days, sometimes even weeks!


(last time I restarted my REBL instance was 10:18 am June 13th, when we made a pass over our dependencies to update a bunch of them -- so "only" four days so far)

Drew Verlee20:06:45

I think for most projects it tends to be the case that you dont add new deps very often. I was trying to use clojure in a more datascience type setting where i find that I want to try new libs relatively often (every 20 minutes or so). In order to find the one that fits my needs. Having to restart my repl 3 or 4 times in this setting becomes something of a creative drag.


with Cider I used to use cljr-add-project-dependency which worked great but broke at some point. I don't know if it's working in the latest version but I still miss it every now and then.


@drewverlee Agreed, and that's why I have an alias in my .clojure/deps.edn file that brings in the add-lib branch of tools.deps so I can start a REPL dedicated to exploration when I need to, and use add-lib to try out various things.

Drew Verlee20:06:23

🙂 im using that deps file right now.

Drew Verlee22:06:43

@U04V70XH6 i'm trying to use the setup you describe in the helpful youtube video you made about 2 months back. Everything is working except when i eval forms in atom via chlorine there not sent to REBL. forms evaled directly through the repl in started via the clj tool are though. Any ideas why this might be.


@drewverlee Sounds like you're using the eval block commands instead of the inspect block commands


If you look in my keymap I only bind to the inspect commands -- because I'm always running REBL (and Clojure 1.10.1).


If you want to use Chlorine without REBL or on 1.9, you have to use the eval block commands (not the inspect block commands), so it sort of depends where you are.

Drew Verlee22:06:03

your first guess was right. ty!


I used to have the inspect variants bound to ctl-, i and ctl-, I but once I got into the habit of always using REBL, it was easier to just bind ctl-, b and ctl-, B since those were easier to remember (and I'd been using them for months, before I introduced REBL).


ah yeah i can see that being a pain


Anyone know a good SFTP library?


I am currently attempting with this one:


that wrapper is very thin, a good place to start would be to attempt the auth / connection code in with-connection manually and see what might be failing


but getting connection timeout


there's an SO post for this specific error in the lib that clj-sftp uses


good example of a thin wrapper sometimes being worse than no wrapper at all


if you used the underlying lib, it would be exposed