Fork me on GitHub

just curious: what is the rationale for this entry in the clojure style guide?:


As opposed to using an expression like (not (empty? maybe-empty-sequence)) ?


I believe because seq is the standard/idiomatic way in Clojure to determine whether a sequence is empty or not, and if not, to get back a thing that you can do first or rest on.


Also, simply for a small bit of efficiency's sake, empty? is defined as (not (seq x)), so (not (empty? x)) would be slightly less efficient than (seq x)


If you use seq for that purpose, other people familiar with Clojure will know what that means and be accustomed to it used for that purpose.


why have an empty? at all, then? is (if (empty? x) ...) preferred over (if-not (seq x) ...)?


(I'm not arguing btw, just trying to understand)


Perhaps empty? makes for a good predicate. You could then debate (filter seq coll) vs. (remove empty? coll). 🙂


Maybe the answer is simply relevant to your example. (if (empty? x) ...) is easy to grok quickly.


also worth mentioning is not-empty - nil (falsey) like seq for empty input, otherwise preserving the type of the input


Nice. I had never noticed that empty and not-empty share the “type preservation” aspect.


Hey guys, I am a CS student going through SICP. I was wondering if anyone had any advice when approaching these problems to get the most ouf ot hte book.


Like is it ok that sometimes when I design procedures, I find myself writing down on a piece of paper how certain tests will compute? Or is that defeating the purpose of thinking abstractly?


working on paper is great


it's even a helpful way to refine abstractions


thats good, sometimes i feel like to myself that i should be 'smart' enough to have it in all my head


I assume you're using the "translation" that someone did of SICP to clojure?


the typography and visuals are really great in this version


scheme is pretty cool until you need libraries for modern stuff :D


agreed. you were studying the scheme shell right?


I had some fun playing with it; haven't looked at it since I started my new job


but scsh is a pretty cool dsl for shell scripts, it can do piping etc. inside scheme code via the magic of macros


No i was doing the original SICp


Is this one for clojure as good?


I am learning clojure through 4Clojure right now


i would stay in scheme. learn to enjoy the language. and then get paid to write lisp in clojure


that's the goal 🙂


do you think it'd be bad to do both at the same time? if they're both fun lol


never a problem with learning. but i find when i do two things at once often i will neglect one and only focus on the other


guess ill give it a go! i just hope its as well written as SICP is


what are the differences between clojure.spec and prismatic schema


the biggest is that schema defaults to a closed set of keys (extra keys are an error unless you specify they are allowed) while spec defaults open


in schema the description of the data looks like the data, in spec it's a regex describing the data


Specifically I want to make sure a db entry in mongo matches a certain shape


If I'm not mistaken, I once saw somebody mention, probably here on Clojurians, a list of Rich Hickey's talks in some sort of order. Not only the fantastic list in but it had like a path to watching/reading the contents. If somebody remembers something like this, I would love a link.


Thanks! I don't think it was that particular piece, but it seems really nice, so I'll try it out.


Also realized that since the videos on Rich Hickey Fanclub are organized chronologically, and there aren't that many, I can probably set up a schedule to watch them all in reverse chronological order and see where that takes me.


sounds good!


Has anyone seen a serialization/persistence library for Clojure that takes advantage of structural sharing? What I'm looking for is a way to easily serialize [state1 state2 state3 ....], where each new state is a change from a previous one, and deserialize it back, with the following properties: 1) serialization does not store thousands of copies of similar data; 2) deserialization does not cause RAM to be filled with lots of copies; 3) it's cheaper than doing a full diff operation on serialization; 3) it's not a one-time thing: new states added to the end of the list can be also efficiently stored in a subsequent serialization.


Probably it has to be built in the language, or at least implemented in Java: basically what I'm looking for is a way to serialize underlying structure of persistent data structures to disk, and then keep a marker "this node is in durable storage at key X" on all internal nodes when they are deserialized.


But for the whole state of the program, or only an explicit given part? So you can of want to serialize everething in memory?


Otherwise you could make some macro I guess, with you use with some atom and ‘file-ref’ which when the collection is used for the first time tries to get it from a file based on the ‘file-ref’ and when the collection is updated, always overwrite the file in .edn.


Only for a specific data structure.


EDN won't cut it: I'm talking about gigabytes of data if not deduplicated properly, changing every 100ms or so.


Every change is small, but the changes are applied on a sizable data, so naively storing every snapshot in .edn is out of question.


A good mental model for a task is a rich text document with the full history: you don't want to keep every revision after every keystroke, but you also don't want to recreate historic states by reverse-applying changes.

Alex Miller (Clojure team)12:08:57

Clojure data structures support Java serialization. I can’t remember if they just use serialization defaults or something different. If default, Java serialization does what you’re asking for (persists the object graph)

Alex Miller (Clojure team)12:08:34

I guess that’s only useful to you if you were pushing them on a stream that retained the cached objects, which you’re probably not

Alex Miller (Clojure team)12:08:21

You really want the equivalent of git


A subset of git, with a single ref and immutable history, yes.


Clojure already has everything in memory. Maybe I'll try to hack something and serialize its internal structure of Persistent* types.


Then deserialization can keep a WeakMap of object -> storage key, and that can be used to persist only a diff in subsequent operations.


Maybe with redis then, it’s fast, just not sure if you serialize you can do what you want with it, and when a single collection becomes to big it’s still difficult.


transit claims to do caching of "repeated elements". I don't know if it goes all down to caching repeated structure across different elements? > Transit also supports compression via caching of repeated elements, e.g., map keys, that can significantly reduce payload size and decoding time, as well as memory in the resulting application representation.


I see, thanks!


Anyone know of any good tools for combining calls to test/check and then giving a report/summary on them?


I found a library better than clojure.spec: Just kidding, but it's a pretty useful and easy to use lib, which helpful for writing tests and validation code. Our team uses it in production for 2 years. Idea more similar to prismatic/schema than clojure.spec, but with different focus. Originally it relies on open-world assumption, but latest release also supports strict matching (to prevent exposing of sensetive information and similar cases). Will be glad to hear a feedback on the lib and documentation from you. Star the repo if you think we are moving in the right direction, it motivates to make our open source projects better.


with the tools/deps repl, how can I use an alias and ignore the main opts? clj -Amyalias --repl doesn’t seem to override my deps.edn :main-opts ['-m' 'my-namespace'] config


disregard, was thinking of it wrong. i want -R:my-alias -r to just bring in the deps of an alias, then launch a repl


I'm having a difficult time getting Lein to self-install on windows. It keeps saying 'REquest aborted, could not create secure ssl/tls channel"


This is what worked for me if anyone runs in to this issue :


Anybody got lacinia glue code for something other than pedestal? I don't have an issue with pedestal but i am stuck on windows for now


I've seen you ask this question in #graphql and I want to know, what does being on windows have to do with pedestal?


last I checked (admittedly a long time ago) pedestal was a jvm library without any kind of native code or anthing


look under supported platforms


ill feel like an idiot if it just works and i never tried it


but the documentation says that it isnt supported


isn't supported may just mean none of the developers uses windows so they don't want to be answering questions about running lein on windows