Fork me on GitHub
#clojure
<
2015-11-27
>
danielcompton02:11:30

@bensu :min-lein-version is optional only

danielcompton02:11:40

although Heroku uses it to pick a Lein2

danielcompton02:11:20

I think you would need to upgrade it yourself if you wanted a specific version

eraserhd03:11:35

Somehow, lein repl stopped working. It now gets “REPL server launch timed out”. Is this something someone’s seen?

eraserhd04:11:07

Resolved. Top-level synthesizing bad keywords. Still not sure why it timed out, though.

roelof06:11:46

What did go wrong here : https://www.refheap.com/112122 when I send (@account) to the repl in Cursive I see this error message : (@account) CompilerException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn

not-much-io06:11:59

You are calling account as if it was a function. Wrapped in parens (@variable) @variable is treated as a function, in first place onside the parens.

roelof06:11:57

Thanks, I never knew you could send things to the repl without ( )

roelof06:11:22

and I see there is another error somewhere account is still zero 😞

borkdude06:11:01

@alexmiller: I saw this page linked from a blog post: http://dev.clojure.org/display/doc/IDEs+and+Editors and I noticed didn’t contain Cursive.

not-much-io06:11:30

@roelof Your anonymous function: (fn [x] (+ x)) probably should add something :) (+ x) not sure what it does, not at a repl (+ x 1) adds one

roelof06:11:09

What I want to achieve is that the amount is added up with the agent account

borkdude06:11:02

@roelof (def a (agent 0)), (send a #(+ % 2))

roelof06:11:04

@borkdude: I have made the agent earlier with (def account (agent 0 :validation number?))

borkdude06:11:43

@roelof: well, then replace a with account 😉

roelof06:11:25

I thought so

borkdude06:11:51

@roelof: the agent receives a function of the old value to a new value

borkdude06:11:26

so (fn [old] (+ old 2)) works

borkdude06:11:39

#(+ % 2) is the same function

roelof07:11:04

when I do this : (send-off account (send account #(+ account amount)) ) I see this error : CompilerException java.lang.RuntimeException: Agent is failed,

borkdude07:11:25

@roelof: why are you using send-off and send?

roelof07:11:00

According to the programming clojure book send-off is sending the message 1 times where send sends it several times

roelof07:11:07

one time is enough

borkdude07:11:49

I don't think that's correct. Use either send or send-off but not both

borkdude07:11:58

send-off is for potentially blocking operations

borkdude07:11:20

also (send ...) is not a function. send-off expects a function as the second argument

roelof07:11:54

oke, I will change my code

borkdude07:11:11

I must go. good luck

roelof07:11:15

Thanks for the help

roelof07:11:11

Still errors . Anyone else who can help me with this code : https://www.refheap.com/112123

nha09:11:48

@roelof: do you mean :validator ?

roelof09:11:55

nha : you are right. I checked it with the "programming clojure" book

nha09:11:44

@roelof: never used agents, but the doc is there : https://clojuredocs.org/clojure.core/agent

nha09:11:12

(quite sure you know this, but just in case simple_smile )

roelof09:11:00

I know, I change it but still the same error : CompilerException java.lang.RuntimeException: Agent is failed,

roelof09:11:29

found it, I had to change my function to (send account #(+ % amount)))

tomayerst12:11:28

Is this paper about more efficient collections exciting or old news: http://blog.acolyer.org/2015/11/27/hamt ?

moxaj12:11:34

@tomayerst I think it's actually being looked at according to @alexmiller, if I remember correctly

borkdude14:11:57

is there some handy tool to log the arguments of a function call + the names of the arguments

borkdude14:11:02

instead of manual println it

borkdude14:11:31

@martinklepsch: JVM wanted, but I'll take a look anyway simple_smile

borkdude14:11:15

I could provide it in my dev-dependencies

borkdude14:11:42

(and don't forget to remove the traces when deploying)

borkdude15:11:14

is it possible to "find all references" of a function? in emacs/cider?

agile_geek15:11:20

@borkdude: have you got clj-refactor installed?

agile_geek15:11:15

if you have it’s ‘cljr-find-usages'

agile_geek15:11:16

I have clj-refactor prefix bound to C-c <RETURN> then ‘f u’ for find usages.

agile_geek15:11:00

If you just want to go to the defn or def of a var you can use CIDER by placing cursor on symbol and using C-c M-.

agile_geek15:11:15

You use C-c M-, to return to where you were

agile_geek15:11:42

As you’re coming to ClojureX why not talk to @benedek about clj-refactor. He’s one of the authors. Also @bozhidar (CIDER author) will be there too.

benedek15:11:52

haha thx @agile_geek for the promotion 😉

borkdude15:11:00

@agile_geek: apparently not, I'll try it now.

borkdude15:11:18

And sure 😄

agile_geek15:11:40

@benedek: my pleasure. 😉

chris15:11:55

clj-refactor is full of so many goodies that are hard to find.

agile_geek15:11:07

@borkdude: it’s a missing piece of the emacs/clojure/cider puzzle!

benedek15:11:14

@chris we recently added hydras (as in https://github.com/abo-abo/hydra) for easier discoverability, see screen cast here: https://github.com/clojure-emacs/clj-refactor.el/wiki/Hydra

borkdude15:11:18

yeah, I had it installed before, but then it got lost during an upgrade simple_smile

borkdude15:11:21

ah, refactor-nrepl middleware...

agile_geek15:11:26

@benedek: cool. I think I’m a couple of versions behind!

chris15:11:31

simple_smile thanks. I watched @magnars parens-of-the-dead and I was amazed by all the things that clj-refactor could do that I had never even seen, and I’m sure there’s a bunch more in there I haven’t even discovered yet

benedek15:11:32

it also has the added benefit of (1) staying open for a refactoring ‘session’ and (2) ‘teaching’ you the same keycombo-s you can use with your predefined prefix

benedek15:11:44

i think this is in the 2.0-SNAPSHOT

borkdude15:11:26

I hope it's compatible with cider-nrepl 10.0

benedek15:11:28

our wiki is quite complete as well with screencasts etc although naturally it refers to the latest snapshot

benedek15:11:47

@borkdude: the latest snapshot is

benedek15:11:09

in fact i think you need to have cider 0.10-SNAPSHOT

borkdude15:11:45

I have cider snapshot

borkdude15:11:49

so I'll use 2.0.0-SNAPSHOT then

benedek15:11:03

yup that should be a good combination 😉

benedek15:11:20

it also depends on clojure 1.7

borkdude15:11:33

I'm using that

benedek15:11:40

coolio then

benedek15:11:07

has some cljs support too. for example clean-ns works for cljs nses

borkdude15:11:02

cool, now I have this exception in my emacs nrepl-messages simple_smile

borkdude15:11:22

this is after I tried cljr-find-usages

borkdude15:11:56

NP: I'll switch over to Cursive for a minute

roelof15:11:34

A beginners question : How can I start a loop with a start and end and a empty map ?

borkdude15:11:02

(loop [i 0 m {}] (if (= i 10) m (recur (inc i) (update m :foo inc)))))

borkdude15:11:42

but I hardly ever use loop

roelof15:11:44

aha, now I see where I made my mistake

roelof15:11:12

oke, for a exercise I need to re-implement range

roelof15:11:28

and I thought loop could do that job

borkdude15:11:22

you could use it, it's always good to exercise

roelof15:11:24

yep, the only way to get more and more familair with clojure

roelof15:11:35

only reading about it do not work simple_smile

borkdude15:11:57

@roelof: there is also a beginners channel btw, if that's helpful to you

borkdude15:11:24

@roelof: nm, I see you there now

roelof15:11:14

I have been there almost the whole day the last 2 days no much help there

benedek15:11:22

most likely you have two nses with the same name (on of them clj other one cljs) which tools.namespace can’t handle right now

benedek15:11:05

in ur code or in one your dependencies i mean

roelof15:11:13

borkdude : thanks, this did the job https://www.refheap.com/112143

benedek15:11:33

as magnars reported it with quiescent

roelof15:11:48

@borkdude: many thanks from a cold Netherlands

borkdude15:11:45

@roelof: I'm in the same country 😉

roelof15:11:43

oke, did not know that

borkdude15:11:57

can emacs highlight unused symbols for me like this? http://twitter.com/borkdude/status/670267589264695296

roelof15:11:02

from which part are you, Im from Twente

borkdude15:11:42

@roelof: let's chat in private

benedek16:11:01

@borkdude: I don’t think it can at the moment but sounds like a low hanging fruit actually. most likely can be done in clj-refactor as refactor-nrepl has find-used-locals

agile_geek16:11:46

@roelof: loop in Clojure is not an imperative loop. It’s the point at which recur will ‘jump’ to in a recursive call. It also binds the initial values used in the ‘loop’. Think of it like a ‘let’ that you loop back to on a recur call. I hope that makes sense?

roelof16:11:30

yes, I had the way things work wrong into my head

roelof16:11:00

I think I have seen to many different things when I was doing the clojure koans

agile_geek17:11:23

You may need to look at 'for' which is a list comprehension. That's a fancy name for something that iteratively consumes a sequence assigning each element to a var. However, when I'm recursing over a sequence I usually use map if I'm just transforming each element in the sequence or reduce if I'm doing something that I need to maintain some state for during the recursion e.g. building a total.

roelof17:11:35

@agile_geek: thanks. the challenge of 4 clojure which I tried to solve was re-implement range

roelof17:11:59

and I thought recursion was a good candidate for a solution

agile_geek17:11:05

Yep. Although there other ways as with all things!

roelof17:11:32

there Always are different ways to solve this

roelof17:11:09

@agile_geek: can you show me a other way

agile_geek17:11:07

@roelof I'm just going out but I'll reply directly to you over the weekend

roelof17:11:01

I can work on the other challenges of 4clojure or play with my toy project

mccraigmccraig17:11:47

@roelof: here's another way - (defn range' [start end step] (take-while #(< % end) (iterate #(+ % step) start)))

borkdude18:11:58

what's the best way to pull in a dependency that is only used in a test, that I also want to run from my 'lein repl' development

borkdude18:11:04

:scope test?

roelof18:11:54

@mccraigmccraig: oke, I think I understand how it works, The only thing I need to check is iterate

mccraigmccraig18:11:32

@roelof: (iterate f x) returns an infinite lazy sequence with (x (f x) (f (f x)) ...) i.e. to get the next value in the sequence it applies f to the previous value

roelof18:11:35

mccraigmccraig: thanks, I have found the same explanation in the clojure cheat-sheet

roelof18:11:23

anyone here who has succeed in running datomic on clojure. Im following the getting started and ran into issues right away

majenful19:11:41

Can someone leads me to documentation of ^{…}, I can’t figure it out what it is (I saw it in for)

majenful19:11:44

awww you right !

majenful19:11:50

didn’t think about cheatsheet, thanks

marvotron19:11:00

i just digging through this stuff myself simple_smile

marvotron19:11:09

and searching google for ^{ is useless

majenful19:11:22

I know, I tried 😄

marvotron19:11:31

so i ctrl+f the cheatsheet when im getting stuck

moxaj21:11:55

question: when unquote-splicing seqs, I don't need to worry about lazyness right?

moxaj21:11:53

on second thoughts, this seems like a stupid question, but I'd like to make sure simple_smile