Fork me on GitHub
#clojure
<
2019-08-31
>
craftybones06:08:38

What am I missing?

user=> (defn same-suit?
  #_=>   [c1 c2]
  #_=>   (= (:suit c1) (:suit :c2)))
#'user/same-suit?
user=> (same-suit? a b)
false
user=> a
{:suit :diamond, :rank 2}
user=> b
{:suit :diamond, :rank 3}
user=> (= (:suit a) (:suit b))
true

scknkkrer06:08:30

What did you expect @srijayanth ?

craftybones06:08:07

the typo 😄

craftybones06:08:38

Nevermind. Missing semi-colons are one thing, but superfluous colons…

craftybones06:08:55

My code had colon cancer. It has been removed.

😂 4
seancorfield06:08:42

LOL I just typed that all into the REPL and repro'd and I'm looking at it going "What the..." and then I noticed the : 🙂

scknkkrer06:08:14

Clojure is a concentrated language. I suggest you that at these times, step-back, take a deep breath and look again. @srijayanth. Do not forget breaks and long breaks while you work.

scknkkrer06:08:10

No problem, good luck!

cjohansen06:08:40

How do I get access to the Clojure Jira to report a bug? I used to have an account, but I'm no longer able to access it after the migration to http://id.atlassian.com

andy.fingerhut06:08:12

The current recommendation is to create an item at http://ask.clojure.org, and Clojure devs will create a JIRA issue if they believe it is a good idea.

cjohansen07:08:45

I was unable to format a block of code with that - am I holding it wrong?

andy.fingerhut07:08:01

Did you try the "code sample" button above the text box where you enter your question, that looks like double quotes?

andy.fingerhut07:08:19

Sorry, it looks like curly braces

cjohansen08:08:05

Yeah, seems to only work with one liners, and didn't support a backtick in the sample

pbaille11:08:42

Hello, i’ve got a naming challenge for you 🙂

(fn [func]
  (fn [& args]
    (fn [this] (apply func this args))))

Leon12:08:41

i guess we'd need more context for why u need this

Leon12:08:50

i guess It'd be a "funfunfunction" if you get the reference

pbaille12:08:32

‘func’ can be viewed as a method implementation of ‘this’, ‘args’ are arguments to this method.

Leon12:08:18

doesn't this first fn return the other fn, which returns the third one?

alfredx12:08:37

a few candidates: guess, confuse, nested-fn, monad…

😄 4
craftybones13:08:29

funky-curry ?

craftybones13:08:04

Actually flippin-funky-curry

pbaille11:08:23

What would be a good name for this function?

sogaiu12:08:12

fun fun fun?

😄 4
borkdude14:08:44

I notice that clojure.server is designed to contain multiple socket repl servers. Is the typical use case to have one or multiple?

borkdude14:08:59

REPLs like planck or lumo only spawn one at a time if I'm not mistaking?

mfikes14:08:08

Correct, they both only optionally listen on at most one port.

mfikes14:08:03

I hadn't noticed that the Clojure version it supports multiple ports, so just didn't implement it.

borkdude14:08:36

Makes sense to only have one I think

borkdude14:08:58

You can connect to the same one multiple times with different clients

borkdude14:08:35

@U04VDQDDY Did you implement any special keywords to exit the REPL or just Ctrl-c?

mfikes14:08:22

:cljs/quit for normal REPL, and additionally :repl/quit if via Socket REPL

borkdude14:08:27

Oh :cljs/quit I guess

borkdude14:08:35

why is the servers var used together with alter-var-root instead of just using an atom to administer them?

Alex Miller (Clojure team)15:08:30

because you need locking to handle the thread control in tandem with the state updates

borkdude15:08:35

Not sure if I understand it correctly. If you would use an atom, what could go wrong? E.g.:

(swap! servers assoc name {:name name, :socket socket, :sessions {}})
instead of (locking lock (alter-var-root! #'servers ...))?

Alex Miller (Clojure team)16:08:00

there's at least one spot where we are coordinating both shutdown and servers state update and we'd like that combo to be combined. and if doing it at one spot, you need to do it at all.

borkdude17:08:57

I guess also one issue is when stopping a server, you don't want to have the side effect of closing a socket happen multiple times (which can happen when using swap!)

Mark Addleman15:08:54

Is there a recursive descent reduce function available in spec? I'm writing a query DSL in using spec and my interpreter needs to pick various bits out of the parse tree. I wrote a recur-reduce fn that is specific to my DSL but it seems to me that spec has all the info it needs to generate one

Alex Miller (Clojure team)15:08:32

a few different options - tree-seq + filter, clojure.walk/prewalk, clojure.zip traversal with next/end?

Mark Addleman15:08:13

Maybe those would work but that's not how I was thinking of the problem. The public "execute" fn of my DSL first conforms the input DSL, the rest of the code operates on the result of the conform operation so i'm working with a nicely regular parse tree. Generic functions like tree-seq, prewalk, etc operate at the data structure level where I want something that operates at the syntax node level.

Karol Wójcik17:08:32

What is the best way to convert namespaced map to a map which is not namespaced?

emccue18:08:25

@karol.wojcik traverse the map and replace all namespaced keys with non namespaced versions

emccue18:08:50

Up to you how/if you want to handle duplicates

Jakub Holý (HolyJak)20:08:11

Hello, when using defrecord to implement a Java interface that has an overloaded method (with 1 and 2 arguments), how to do that? As if it was Clojure fn with multiple arities or as 2 separate functions??? Thank you!

skuttleman20:08:53

Something like:

(defrecord MyRecord []
  JavaInterface
  (method [this arg] ...)
  (method [this arg1 arg2] ...))

👍 4
Alex Miller (Clojure team)20:08:51

I always have to look this up but I think it’s separate

❤️ 4
Alex Miller (Clojure team)20:08:04

B/c they are separate in Java

David Rojas Camaggi22:08:14

Hello, how should I require this library https://github.com/worldturner/medeia-validator ? I added it to deps.edn and it gets installed but don't know how to require it yet

seancorfield23:08:45

@drojascamaggi It's not Clojure so you don't require it. You can import classes from it tho'.