Fork me on GitHub
#clojure
<
2016-07-14
>
danburton01:07:34

I sort of expected some? to be the same as identity for some reason.

Paco02:07:24

If you are using clj-yaml please make sure you also include [org.yaml/snakeyaml “1.17”] it will save you a lot of grief 😛

jh39807:07:55

I have a function (a) in a go block that uses >! and i get the assertion error error that >! is not used in a go block

jh39807:07:07

so should i start another go block in function a?

jh39807:07:20

is nested go block the right way to do this?

jh39807:07:49

but I am not sure what's the right way of getting around this problem?

Macroz07:07:41

@jh398: I don't think there is a general answer besides "simplify your code and keep it in one block"

Macroz07:07:05

perhaps what you are trying to do is overly complex already because you feel the need to put it in a separate fn

danielcompton07:07:03

@jh398 I think you can use a macro here as well?

jh39807:07:09

@macroz yes, the logic in the main go block is complex, that's why i wanted to move parts of it into a separate function

jh39807:07:22

then i run into the >! used outside go block problem

Macroz07:07:42

perhaps have more but simpler channels

Macroz07:07:52

can't offer anything smart unless you post the code

Macroz07:07:01

but most likely the only answer is to restructure

jh39807:07:06

@danielcompton: do you mean rewrite function a as a macro

Macroz07:07:04

also have a look at what macros are already available to simplify your code

jh39807:07:30

@macroz do you mean macros in core async?

Macroz07:07:38

yeah first there

jh39807:07:30

i am trying to use core async to construct a state machine for a game

jh39807:07:15

so the main go block is complex, because it need to wait on various channel at different stages of the game

jh39807:07:13

this is the main go block

jh39807:07:27

the problem is for wait-for-start function

jh39807:07:29

in the wait-for-start function i need to wait until there is at least 2 but no more than 4 players that have joined the game

jh39807:07:33

then i can start the game

Macroz07:07:54

well personally I don't see that code working for you at all

Macroz07:07:04

will you understand what happens in a few months?

jh39807:07:19

just picking up core async today

jh39807:07:31

so maybe i am too ambitious

Macroz07:07:29

I would keep the main loop trivially simple and sequential but use some kind of parallelism in individual steps e.g. AI for each unit or some other embarassingly parallel problem

Macroz07:07:24

"waiting for a game start" is definitely not a problem that needs any parallelism besides the UI being responsive while waiting is happening

Macroz07:07:55

the game loop should have nothing to do with that part also because that's before the game

Macroz07:07:23

so once you start splitting these up maybe you realize that you don't need such a complex construct anyway

jh39807:07:49

i did a version without using core async with atom and that's working well, just wanted to try out using core async to construct a state machine for the game

jh39807:07:57

i guess i am over complicating stuff

Macroz07:07:06

np, sorry I don't have a clever answer

Macroz07:07:32

but this exact problem is something I do run into several times a year

Macroz07:07:43

(not channels but game loops or abstraction)

jh39807:07:59

not at all, i am just experiementing with different parts of clojure

jh39807:07:09

really enjoying the learning process

jh39807:07:17

thanks again

Macroz07:07:27

what game are you working on?

jh39807:07:02

it's a very simple but popular chinese dice counting game, the aim is to trying to guess or bluff your opponent the values of dice on the table

jh39807:07:22

each player has 5 hidden dice that only he/she can see

Macroz07:07:28

ah you have a cup on the dice, right?

crimeminister13:07:49

@peeja: for the class of problem you're describing I have found Specter to be very useful.

crimeminister13:07:36

(sufficiently so I would nominate it for blessed status as core.navigate, say; YMMV)

bcbradley16:07:42

Under what conditions would a reducer be faster than a transducer?

bcbradley16:07:12

I know that transducer's big appeal is that it allows you to specify the nature of a computation without tying it to any particular data structure, stream, collection or whatever, so you only have to write the transducer one time and you can use it everywhere-- but as for its speed compared to the specialized parallel reducer library... I don't know which is faster

bcbradley16:07:35

does (transduce ...) become faster with more cores?

seancorfield16:07:48

@bcbradley: My understanding is "not yet" re: that last question, but I believe parallel transduction in under consideration at some point.

seancorfield16:07:44

If you have a computationally intensive transformation, parallel fold (in reducers) is probably a better bet. If you have a long pipeline of many transformations, transducers might be better.

bcbradley16:07:19

I thought CLJ-1553 was supposed to make transducers parallel but it seems unresolved

bcbradley16:07:10

as I understand it, reducers and fold require you to specify the transformation once and then you have a "machine" for doing the parallel work

bcbradley16:07:28

but you can't swap in and out aspects of that machine because the parts aren't interchangeable in a sense

seancorfield16:07:18

Right, on both counts.

meowy16:07:14

Is ptaoussanis on this Slack?

meowy16:07:28

got a question relating to a Taoensso library.

seancorfield16:07:41

@meowy: I do not believe he is. But a lot of people here use his libraries anyway so ask your question and see if someone can help you…?

meowy16:07:41

I'm wondering how to get Tufte's profiling to work when working with transducers. There's a strange little issue I'm having: If I define the transducer within the (profile) form, the profiling works correctly, but if it's defined externally using def, it won't work.

meowy16:07:45

Hmm, actually, I'm doing something not quite as I'm meant to. :P

meowy16:07:41

Nevermind, I realized what I was doing wrong. (p) form was getting evaluated outside of my (profile) block because I did a goof, wrapped the wrong forms.

meowy16:07:32

Now that I've put it where it actually belongs, profiling works. \o/

peeja17:07:33

Does &form in a macro give you any information you don't already have from the macro's arguments other than the name the macro was called with?

seancorfield17:07:18

@meowy: I like problems that solve themselves 🙂

chrisalbright18:07:35

Good day fellow clojurians!

chrisalbright18:07:42

Does anyone here know of a library or tool tool to help me visualize my closure project? I'm trying to see the namespace hierarchy and dependency graph. I've asked the venerable Google but so far have come up short. Thanks in advance 🤓

dg18:07:47

Going further, the graph of how your project depends on other projects is lein deps :tree

chrisalbright18:07:25

So cool. Thanks again!

peeja22:07:34

Is there a way to read-string some edn and then learn which at which character positions each part of it was represented in the original string?