This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-02-26
Channels
- # announcements (18)
- # aws (17)
- # babashka (19)
- # beginners (141)
- # calva (73)
- # cider (4)
- # clj-kondo (13)
- # cljs-dev (2)
- # clojure (97)
- # clojure-europe (6)
- # clojure-italy (5)
- # clojure-nl (1)
- # clojure-spec (25)
- # clojure-sweden (2)
- # clojure-uk (25)
- # clojured (3)
- # clojurescript (63)
- # core-typed (6)
- # cursive (23)
- # data-science (4)
- # datomic (74)
- # fulcro (19)
- # graalvm (18)
- # graphql (3)
- # hoplon (63)
- # jackdaw (1)
- # juxt (23)
- # london-clojurians (3)
- # meander (7)
- # off-topic (23)
- # om (1)
- # pathom (13)
- # pedestal (2)
- # perun (2)
- # re-frame (38)
- # reagent (3)
- # reitit (24)
- # shadow-cljs (91)
- # spacemacs (14)
- # sql (4)
- # tools-deps (8)
- # vim (3)
I have an esoteric question. While discussing eval-ing the current form in a repl, with a co-worker, they asked why is it called a form? This question has bothered me for a long time as well. I assumed it was either from McCarthy or Church's work. However, I have struggled to find the origin of this term in the context of lisp.
I have a copy of the Lisp 1.5 programmer's manual, 2nd ed, 15th printing., dated 1985, that uses 'special forms' as part of its terminology. Co-authored by John McCarthy
This 1960 paper by McCarthy mentions the distinction between 'function' and 'form' with a reference to an earlier paper by Church: http://www-formal.stanford.edu/jmc/recursive.pdf
Good question 🙂 I wouldn't be surprised if it came from logic https://en.wikipedia.org/wiki/Logical_form
Normal form also comes to mind and has been around for a long time too. https://en.m.wikipedia.org/wiki/Canonical_form
https://www.merriam-webster.com/dictionary/form has things like "a mathematical expression of a particular type" or "pattern, schema"
where's is the definition for random
inside rand
in clojure 1.10.1 ?https://github.com/clojure/clojure/blob/clojure-1.10.1/src/clj/clojure/core.clj#L4911-L4917
the round parenthesis are optional (I think their reason is to make the interop with arguments more readable)
lein-git-down
gives an error when trying to pull from private repo with the following config:
(defproject private.config-server "0.1.0-SNAPSHOT"
...
:dependencies [[mq-lib "02d8430963ba5bdc144089f5a62d5aaba8334e24"]]
:repositories [["private-bitbucket" {:url "" :protocol :ssh}]]
:git-down {mq-lib {:coordinates private/mq-lib}}
:plugins [[reifyhealth/lein-git-down "0.3.5"]]
:main ^:skip-aot nl.private.config-server.main
:resource-paths ["resources" "resources/private/config_server" "target/resources"]
:prep-tasks ["javac" "compile" ["run" ":duct/compiler"]]
:middleware [lein-duct.plugin/middleware
lein-git-down.plugin/inject-properties]
:profiles
{:dev [:project/dev :profiles/dev]
:repl {:prep-tasks ^:replace ["javac" "compile"]
:repl-options {:init-ns user}}
:uberjar {:aot :all
...
:resource-paths ["src"]}
:profiles/dev {}
:project/dev {:source-paths ["dev/src"]
:resource-paths ["dev/resources"]
:dependencies [[integrant/repl "0.3.1"]
[eftest "0.5.7"]
[kerodon "0.9.0"]
[hawk "0.2.11"]]}})
Error:
$ lein deps
Retrieving mq-lib/mq-lib/02d8430963ba5bdc144089f5a62d5aaba8334e24/mq-lib-02d8430963ba5bdc144089f5a62d5aaba8334e24.pom from private-bitbucket
Retrieving mq-lib/mq-lib/02d8430963ba5bdc144089f5a62d5aaba8334e24/mq-lib-02d8430963ba5bdc144089f5a62d5aaba8334e24.jar from private-bitbucket
Could not find artifact mq-lib:mq-lib:jar:02d8430963ba5bdc144089f5a62d5aaba8334e24 in central ( )
Could not find artifact mq-lib:mq-lib:jar:02d8430963ba5bdc144089f5a62d5aaba8334e24 in clojars ( )
Could not transfer artifact mq-lib:mq-lib:jar:02d8430963ba5bdc144089f5a62d5aaba8334e24 from/to private-bitbucket (): @bitbucket.org/private/mq-lib: Auth fail
Could not transfer artifact mq-lib:mq-lib:pom:02d8430963ba5bdc144089f5a62d5aaba8334e24 from/to private-bitbucket (): @bitbucket.org/private/mq-lib: Auth fail
This could be due to a typo in :dependencies, file system permissions, or network issues.
If you are behind a proxy, try setting the 'http_proxy' environment variable.
Any idea how to fix?
private ssh repos will use ssh-agent so that's what you need to debug - 1) is it running? 2) does it have your identity - ssh add -l
should list it
Thanks!
$ ssh-add -l
The agent has no identities.
One thing I would recommend is to use something like
. I've been using it for years and is super super handy for doing ssh work.
$ ssh-add ~/.ssh/id_rsa
Identity added: id_rsa (id_rsa)
Fixed it! ThanksQuestion: Is the following expected?
(clojure.string/split "/a/b/c///" #"/") => ["" "a" "b" "c"]
(clojure.string/split "/a/b/c///" #"/" 100) => ["" "a" "b" "c" "" "" ""]
yes, there are some tickets about this https://clojure.atlassian.net/browse/CLJ-1857 - some changes folded into https://clojure.atlassian.net/browse/CLJ-1360 (not yet applied)
pass -1
as the final arg to not cull the empty strings. This behavior comes from java IIRC.
The page at https://clojure.org/reference/reader#_literals says: "[Keywords] cannot contain '.' in the name part" The Rich's post at https://groups.google.com/forum/#!msg/clojure/CCuIp_bZ-ZM/9yP41gt7wuoJ (from 11/24/08) says: "As far as '.', that restriction has been relaxed"
• They cannot contain ‘.’ in the name part, or name classes. • Like symbols, they can contain a namespace, `:person/name`, which may contain ’.’s.
anyone know if there’s a common name for this function?
(defn operate [& fs]
(fn [tuple] (mapv (fn [[f x]] (f x)) (map vector fs tuple))))
=> #'example.core/operate
((operate identity inc) [1 2])
=> [1 3]
((operate identity inc dec) [1 2 0])
=> [1 3 -1]
it’s similar to juxt but for operating piecewise against a tuple
not that I'm aware of but you can simplify that impl
simpler constructions welcome!
why are you packing it into a vector, then pulling it back apart?
just to pair things up i guess
(defn operate [& fs]
(fn [tuple] (into [] (map #(%1 %2) fs tuple))))
something like that is same?
indeed
thanks
I don't know, but I'd bet that the vector part should not be there. Collections are your general unit of abstraction. Type can be preserved at an outer level if you care.
yeah. idk for some reason i always assume vector for tuples, no ?
I assumed v->v was important here for some reason
Vectoritus is dangerous. Before you know it you have clojure/corev.clj with vector versions of every function in core :)
@colinkahn what's your underlying issue?
I’m using https://github.com/weavejester/ns-tracker to watch source changes, the tracker only returns what namespaces have changed, but I need to do something with the actual files (move them somewhere etc).
looking at tools.namespace it seems I could search files for matching namespace declarations, but hoping there’s a more straightfoward way
You'll need to search the classpath and then convert the url back to a full path, or just assume src/.
honestly you could probably patch ns-tracker
to return the file path, it’s already doing the reverse: file -> namespace
https://github.com/weavejester/ns-tracker/blob/master/src/ns_tracker/core.clj#L50 I bet right here you could add the file as metadata to the symbol and not have to change much at all. just spitballing, haven’t tried it!
Thanks for the ideas @dominicm and @lilactown, I’ll see what I can come up with
if you have an already loaded var, it also contains the file path @colinkahn
user=> (get (meta #'clojure.string/includes?) :file)
"clojure/string.clj"
Why use-fixtures
have :each
ond :once
but can’t run fixture once per deftest
? I miss that option. Only once per ns or for each test, while what I always need is once
per deftest
in ns
.
:each
runs around each "test", i.e., each deftest
.
So :each
is "once per deftest
".
@kwladyka Can you explain what you're trying to do if that isn't what you need?
Sorry, I still don't understand.
You don't need to restart the REPL for that change to take effect. You may need to remove the namespace and reload just that one file tho', since you need to get rid of the old metadata on the namespace (you could just alter-meta
on it if you knew the underlying implementation used 🙂 )
Anyone know a way to generate Clojure documentation from tools.deps? I see codox and codeina but they use leiningen. I tried a naive approach in my deps.edn but was unsuccessful in generating docs. Thanks in advance!
tools.deps is for dependencies, not build concerns like generating documentation. We use https://github.com/tomfaulhaber/autodoc generate the docs for aws-api: https://cognitect-labs.github.io/aws-api/
You can see how we do it here: https://github.com/cognitect-labs/aws-api/blob/master/build/doc
Thanks @U0ENYLGTA! That is exactly the answer i need!
Glad to help.
haha... Slack: "Upgrade to a paid plan to see 1 additional message from @<some user> that matches your search." omfg. long live IRC.
http://clojurians.zulipchat.com has been logging many Clojurians Slack channels for at least a year now (maybe different start dates for different Slack channels, and some might not be at all). You can search there over that history.
most of the communication by the users of an open source language in the hands of a private company, behind a paywall. smh.
anyone familiar with https://github.com/ptaoussanis/tufte?
Im trying to do a very basic example but Im getting a exception instead of 9
.. the problem is that the code im trying to profile is written using the ->
operator
(defn add-2 [x]
(Thread/sleep 2000)
(+ 2 x))
(defn mult-by-3 [y]
(Thread/sleep 1000)
(* 3 y))
(profile
{}
(-> 1
(p :x add-2)
(p :y mult-by-3)))
@plins the examples on the page have the keyword as the first arg to p
thanks for the clarifications! but unless im missing something, p is nested below profile at the docs
(profile ; Profile any `p` forms called during body execution
{} ; Profiling options; we'll use the defaults for now
(dotimes [_ 5]
(p :get-x (get-x))
(p :get-y (get-y))))
oh I missed that, my bad
the -> ensures that the keyword is the second arg to p
you could use as->
to be more specific about the arg position, or just use let
also, the examples don't use p
inside profile
I'm looking for Lisp implementations written in Clojure. I'd like to explore different methods of converting tokens into an AST. https://github.com/kanaka/mal/blob/master/impls/clojure/src/mal/reader.cljc uses an atom to track state, but I'd like to learn about alternatives. Anyone?
An attempt at porting Norvig's Lis.py implementation (https://norvig.com/lispy.html) started me off down this rabbit hole :)
@michael.e.loughlin a normal java queue works well: https://docs.oracle.com/javase/7/docs/api/java/util/ArrayDeque.html
There are the libraries tools.reader, tools.analyzer, and tools.analyzer.jvm, implemented in Clojure, and intended to be as compatible as they can be with Clojure's built-in alternatives. Not sure if that is in the ballpark of what you are looking for. https://github.com/clojure/tools.reader. https://github.com/clojure/tools.analyzer. https://github.com/clojure/tools.analyzer.jvm
I believe they have a strong tendency to use immutable data structures whenever possible.