Fork me on GitHub
#clojure
<
2021-11-01
>
SK13:11:27

hi! when using cursive for debugging, how to use the parameter of an anonymous function in intelliJ's "Evalute" window? I've tried using "%" but for that it says "unable to resolve %". In the "Variables" windows this parameter is listed as "p1--52131#" however it is not working with this name in the Evaluate window. Any ideas?

FiVo14:11:57

Probably a question for #cursive.

SK14:11:11

OK, thanks 🙂

Mario Giampietri15:11:24

Hi everyone, I'd like to understand what's the reasoning behind a few choices related to a few Clojure functions. This is not to criticise the choices made or the functions themselves, is to help me having a better understanding and know the motivations or history behind them: - any? and not-any?: at a first sight I'd have expected these two function to be the complement of each other, but that's not the case. The behaviour of the 2 functions is clear, still I find it remarkable the difference between them. Is this the result of a specific choice? Or maybe the two functions are unrelated, they have an independent story, it just happens that their external appearance may suggest that they are potential complements? - some: also here the behaviour of the function is clear. What I find puzzling is its idiomatic usage with sets - which looks pretty cool and handy in practice - but in my mind this clashes with the signature what says that the function accepts a predicate as first parameter. So, are sets considered predicates (maybe in specific cases such as this one)? Thanks 😊

Alex Miller (Clojure team)15:11:02

> the two functions are unrelated, they have an independent story, it just happens that their external appearance may suggest that they are potential complements ^^

👍 2
Ed15:11:11

I think any? was created for use with spec. So if you want to spec a collection of anything you have a predicate for that, while not-any? is the opposite of some

👍 1
opqdonut15:11:31

and some doesn't have a question mark because it returns the first non-falsy value, which can be useful on its own

opqdonut15:11:44

whereas some? is just a cute name for not-nil? 🙂

dmillett20:11:11

For self clarification, I did write some functions any? all? none? prior to spec's development to help with those types of scenarios. They are compatible with spec as well. Ping me if you want them.

dpsutton15:11:14

(#{:a :b} :a) -> :a . (#{:a :b} :c) -> nil. Sets implement clojure.lang.IFn and it is a membership operation

Mario Giampietri15:11:46

all clear. Still, not necessarily a predicate - being a predicate a function that returns either true or false some is defined as (some pred coll) but it seems is often used as (some f coll) where f can also be a set

pavlosmelissinos16:11:32

False and nil are falsey values, everything else is truthy. In that sense sets are predicates

Mario Giampietri17:11:41

So I guess the key (to clarify my doubts) is the word "logical" in the function definition docs. Thanks everyone for the answers :thumbsup:

seancorfield19:11:00

@U017QU43430 The convention in Clojure is that a strictly Boolean-returning predicate function has a name ending in ? -- but any function can be used as a predicate where its result will be treated as either truthy or falsey.

seancorfield19:11:39

See https://clojure.org/guides/faq#qmark_bang for notes about ? and ! in function names.

👍 1
winsome19:11:11

Does anybody know a tool for making a visualization of your namespace graph?

winsome19:11:23

It looks like this is graphing the project's dependencies, whereas I want to graph my own namespaces, if that makes sense.

winsome19:11:00

I wonder if it can be easily tweaked, though...

indy19:11:04

Namespaces themselves are all at the same level, there is no hierarchy. Can you elaborate on what kind of graph you’ve in mind?

Alex Miller (Clojure team)19:11:21

there are a couple tools out there for this

Alex Miller (Clojure team)19:11:06

I think if you google clojure namespace graph or whatever you'll find them

Alex Miller (Clojure team)19:11:20

certainly tools.namespace can give you the graph as data

indy19:11:42

Oops, the require graph, my bad for misunderstanding the q

pithyless21:11:07

clj-kondo exposes this data; and even has a graphviz generator: https://cljdoc.org/d/clj-kondo/clj-kondo/2021.10.19/doc/analysis-data#namespace-graph

👀 4