This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-08-17
Channels
- # beginners (70)
- # boot (4)
- # cider (16)
- # clara (6)
- # cljdoc (21)
- # cljs-dev (2)
- # cljsrn (1)
- # clojure (73)
- # clojure-finland (2)
- # clojure-nl (6)
- # clojure-russia (35)
- # clojure-sg (1)
- # clojure-spec (14)
- # clojure-uk (146)
- # clojurebridge (2)
- # clojurescript (128)
- # cryogen (2)
- # cursive (20)
- # datomic (27)
- # emacs (6)
- # events (8)
- # figwheel-main (57)
- # fulcro (46)
- # hoplon (3)
- # hyperfiddle (2)
- # immutant (3)
- # jobs (6)
- # jobs-discuss (15)
- # juxt (2)
- # off-topic (33)
- # parinfer (2)
- # portkey (4)
- # protorepl (1)
- # re-frame (4)
- # reagent (78)
- # ring-swagger (45)
- # schema (6)
- # shadow-cljs (167)
- # spacemacs (2)
- # specter (13)
- # tools-deps (6)
just curious: what is the rationale for this entry in the clojure style guide?: https://github.com/bbatsov/clojure-style-guide#nil-punning
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) ...)
?
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
thank you
I assume you're using the "translation" that someone did of SICP to clojure? http://www.sicpdistilled.com/
i'd recommend scheme and https://sicpebook.wordpress.com/ebook/
scheme is pretty cool until you need libraries for modern stuff :D
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
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
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 https://github.com/tallesl/Rich-Hickey-fanclub but it had like a path to watching/reading the contents. If somebody remembers something like this, I would love a link.
perhaps you're remembering https://changelog.com/posts/rich-hickeys-greatest-hits ?
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.
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.
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.
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)
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
You really want the equivalent of git
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. https://github.com/cognitect/transit-format#rationale
It doesn’t
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
:
https://github.com/HealthSamurai/matcho
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 : https://github.com/technomancy/leiningen/pull/2405
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?