This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-11-20
Channels
- # babashka (56)
- # beginners (151)
- # calva (3)
- # cider (31)
- # clj-kondo (17)
- # cljs-dev (5)
- # clojure (26)
- # clojure-australia (21)
- # clojure-dev (7)
- # clojure-europe (23)
- # clojure-nl (5)
- # clojure-spec (54)
- # clojure-uk (11)
- # clojuredesign-podcast (8)
- # clojurescript (77)
- # community-development (10)
- # core-typed (1)
- # cursive (3)
- # datomic (7)
- # docker (67)
- # emacs (10)
- # expound (6)
- # figwheel-main (3)
- # graalvm (67)
- # helix (10)
- # java (13)
- # jobs (6)
- # kaocha (4)
- # leiningen (15)
- # malli (2)
- # meander (31)
- # off-topic (40)
- # pedestal (9)
- # rdf (7)
- # reagent (5)
- # reitit (9)
- # remote-jobs (5)
- # shadow-cljs (94)
- # sql (7)
- # testing (12)
- # tools-deps (75)
- # vim (13)
Is there a way to give an alias to an imported symbol? I know (:require [my.lib :as lib])
is possible, but is there something equivalent to (:require [my.lib :refer [myfunc :as func]])
?
clojure.core/refer
([ns-sym & filters])
refers to all public vars of ns, subject to filters.
filters can include at most one each of:
:exclude list-of-symbols
:only list-of-symbols
:rename map-of-fromsymbol-tosymbol

I'd appreciate some insight on this core.logic
expression:
(logic/run* [what]
(logic/membero (:a :b what) '((:d :e :f))))
why in the world is this returning ((:d :e :f))
?
The equivalent prolog would be:
?- member([a, b, X], [[d, e, f]]).
false.
(:a :b what)
is invoke the keyword :a
with the arguments :b
and what
and because of how keywords work as a function, returning the lvar what
user=> (logic/run* [what] (logic/membero (list :a :b what) '((:d :e :f))))
()
user=>
thanks @hiredman! I was aware of the behavior (:a {:a 3}), but didn't know that I could pass multiple arguments to a keyword used as a function. Where should I read about that behavior? Besides, what's the difference between:
(logic/run* [what]
(logic/membero (list :d :e what) '((:d :e :f))))
and
(logic/run* [what]
(logic/membero '(:d :e what) '((:d :e :f))))
the first returns a solution, the second doesn'tyou are quoting the whole list, so 'what' is jsut the symbol 'what' instead of an lvar
if you are familiar with prolog, one of the big differences with a minikanran style dsl is how names are treated
(log/run* [q] (some-goal q))
in this expression 'q' is not a name in the logic language, it is a name in the language (clojure) that the logic language is embedded in
@meditans as an expression in Clojure? :a
acts as a function looking itself up in an associative object. if it doesn't find anything, then the other argument is the default value.
yes, thank you! I knew that a keyboard could be used to search in a map, but didn't think about the need of default values
I linked the doc in thread above fyi https://clojure.org/reference/data_structures#Keywords
is there a transducer that returns each individual element of a vector?
ah that's it! thanks!