This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-02-28
Channels
- # aleph (50)
- # announcements (3)
- # aws (35)
- # beginners (74)
- # boot (25)
- # calva (39)
- # cider (18)
- # clara (2)
- # cljdoc (18)
- # cljs-dev (24)
- # cljsrn (11)
- # clojure (166)
- # clojure-europe (13)
- # clojure-italy (5)
- # clojure-nl (6)
- # clojure-spec (35)
- # clojure-uk (263)
- # clojurescript (22)
- # clojutre (1)
- # code-reviews (34)
- # cursive (58)
- # data-science (2)
- # datascript (4)
- # datomic (4)
- # duct (6)
- # emacs (7)
- # figwheel-main (9)
- # fulcro (2)
- # graphql (3)
- # hoplon (22)
- # hyperfiddle (2)
- # juxt (5)
- # kaocha (6)
- # leiningen (33)
- # luminus (15)
- # off-topic (1)
- # pedestal (5)
- # reagent (18)
- # reitit (12)
- # shadow-cljs (171)
- # vim (5)
Hey guys, I just made this thing https://github.com/fp-alice/cljmcs Aside from not having any tests, am I doing anything wrong?
this could be expressed as (set/rename-keys x {:download :file :href :location})
https://github.com/fp-alice/cljmcs/blob/master/src/cljmcs/http/scraper.clj#L11
subjectively, sometimes (first (filter f coll))
is better than constructing a predicate that returns its input so you can use some
https://github.com/fp-alice/cljmcs/blob/master/src/cljmcs/minecraft/servers.clj#L16
the predicate there could be (comp #{minecraft-version} :version)
- returns truthy if the value under the key matches any value in the set
(that's also subjective)
a keys is a function from a map to the value under the key
a set is a function from a potential member to itself only if contained in the set
(#{foo} foo)
-> foo
Oh so it's like getting the version and then checking if it's equal to the given one with the set
(#{foo baz} bar)
-> nil
right
Whenever I look at (comp f g h)
, I tend to see #(f (g (h ...)))
.
Of course if you transform it to #(-> ... f g h)
it will seem backwards.
I had this same problem. But apparently every functional language that has compose does it from right to left.
yeah, if the devs in your team (you) don't find that straightforward, it's probably a bad style choice
but it's an idiom I personally like
you use http://clojure.java.io here already, so you could use io/file
, but you could also import java.io.File
so that you can just use File
https://github.com/fp-alice/cljmcs/blob/master/src/cljmcs/os/files.clj#L15
this could be clojure.string/join https://github.com/fp-alice/cljmcs/blob/master/src/cljmcs/os/files.clj#L8
the portable version of this is (System/getProperty "user.dir")
https://github.com/fp-alice/cljmcs/blob/master/src/cljmcs/os/shell.clj#L8
an extra "print-generic-help" type thing as the odd numbered element at the end of the case will make more sense to the user than the runtime error clojure gives if no case is matched https://github.com/fp-alice/cljmcs/blob/master/src/cljmcs/core.clj#L14
well, the getProperty is also a single method call, instead of a chain of functions as well
it's all my opinions so far, no bugs
in fact this
(if action
(case action
"download" (download-command/download! arguments)
"list" (list-command/list! (first arguments))
"help" (help-command/help!))
(help-command/help!))))
could be (case action "download" (download-command/download! ...) "list" (list-command/list! ...) "help" (help-command/help!) (help-command/help!))
- both the lack of an action and an unrecognized action often map to the same help output in shell utilsor for style you could differentiate the help output from unmatched by adding a prefixing "no matching command"