Fork me on GitHub
#clojure-uk
<
2017-11-01
>
jasonbell08:11:44

(def trick-or-treat-but-basically-treat {:witches 0 :wizards 0 :just-dressed-in-black 5 :princesses 7})

otfrom08:11:49

nihilism is the scariest costume @jasonbell

jasonbell08:11:21

Well nihilism got a cup of sweets and a bag of crisps like everyone else.

thomas08:11:54

moin moin...

thomas08:11:25

we didn't get any trick-or-treaters... hasn't caught on yet in the Netherlands apparently

mccraigmccraig09:11:10

my village was crawling with trick-or-treaters. some of the costumes were quite good

otfrom09:11:27

no trick or treaters, but the 2 universities near us seemed to be having a lot of fun

maleghast09:11:54

Morning šŸ™‚

maleghast09:11:31

We went ā€œguisingā€ in Kinlochard (little village halfway between us and civilisation) with some of our kidsā€™ school chums and a lot of very jovial parents. Was AWESOMES!

maleghast09:11:43

Iā€™ve asked in #clojurescript but will ask here tooā€¦ So I want to ā€œde-renderā€ a Reagent component, so that I can render another one in the same place / section on the pageā€¦ Is there an obvious way to do that..? (This is day #2 of my cljs life, so please forgive me if Iā€™m being numb)

danielneal09:11:21

if I've understood you correct, reagent/react should take care of that for you

danielneal09:11:39

if your render function returns the new component instead of the old one

danielneal09:11:45

react will take care of removing from the dom

sundarj10:11:13

@maleghast you may find reading the React docs helpful: https://reactjs.org/docs/

maleghast10:11:01

@danieleneal - Thatā€™s an interesting idea; I will have a go at thatā€¦

maleghast10:11:17

@sundarj - I will, thanks šŸ™‚

maleghast10:11:10

@sundarj - I can see what you meanā€¦ Just a couple of pages and I am confronted with the suggestion that @danielenealā€™s comment is dead on the money. Thanks chaps.

Rachel Westmacott11:11:10

has anyone encountered an issue using namespace qualified vars in core.match?

Rachel Westmacott11:11:20

ie. (match ... some-symbol ...) is fine, but (match ... some-ns/some-symbol ...) blows up with spec errors.

Rachel Westmacott11:11:43

itā€™s easy enough to work around, but I just wonderedā€¦

Rachel Westmacott11:11:26

oh - I think I see what Iā€™m doing wrong

maleghast13:11:15

@danieleneal @sundarj - Just wanted to thank you both; your assistance has got me to where I wanted to be šŸ™‚

sundarj13:11:23

glad i could help šŸ™‚

maleghast13:11:06

New Questionā€¦ I am using Reagent, and I want to write a little bit of clojurescript to monitor the DOM for <td> elements with a specific class attached to them and based on their ā€œvalueā€ change them to an empty cell with a coloured background (I am ā€œdoingā€ traffic lights based on 1,0,-1 for green, amber, red). Am I thinking about this the wrong way around? Should I interpreting the data when I render the component and turning the number into a coloured cell at render?

maleghast13:11:18

(It feels as though I should, I am just not sure how to)

danielneal13:11:36

yes you are exactly right

danielneal13:11:49

you should interpret the data when you render and choose the class

danielneal13:11:34

[:td {:class (if (< v 3) "red" "yellow")}] kinda thing

maleghast13:11:51

@danieleneal - Excellent šŸ™‚

thomas14:11:54

@maleghast have a vector with the colours and use the number as the index? no need for an if function I think

thomas14:11:31

maybe you need to use the numbers 0, 1, 2 in that case (or inc them)

thomas14:11:50

(thinking outloud here... haven't tested it what so ever

maleghast14:11:57

@thomas - That is what I am doing, but using a map with the values as the keys. šŸ™‚

maleghast14:11:11

Now I am having a really difficult / thorny problemā€¦

thomas14:11:39

a vector is a kinda like a map with ints as keys. šŸ˜‰

maleghast14:11:44

I want my module to reference the init function in my clojurescript file, but I am hitting the document order problem.

maleghast14:11:16

@thomas - It is, yes, but I want the status values to be -1,0,1 so that they have meaning in and of themselves

maleghast14:11:23

self-documenting that wayā€¦

thomas14:11:46

no problem.

maleghast14:11:00

Right, I have to go and get my kidsā€¦ See you all in an hour or soā€¦

Rachel Westmacott15:11:53

if you want it to be really self-documenting, why not :red, :amber, :green?

maleghast15:11:50

@peterwestmacott thatā€™s a perfectly good point - it might come to that

maleghast15:11:11

So, anywayā€¦ Is there a way around the CLJS document order issue..?

maleghast15:11:41

i.e. I am near the bottom of the file, but I want to invoke a function defined at the bottom and the compiler is giving me warningsā€¦

maleghast15:11:09

Er Iā€™ll Google that, but what is that..?

Rachel Westmacott15:11:17

forward declarations

Rachel Westmacott15:11:26

you can declare a var before you define it

maleghast15:11:22

Thatā€™s awfully clever

Rachel Westmacott15:11:22

just occasionally it is not possible to order everything straightforwardly

maleghast15:11:04

Yeah, I can see that šŸ™‚

Rachel Westmacott15:11:09

higher level languages like Java (troll) handle this for you automatically

Rachel Westmacott15:11:32

(though you can hit edge cases in Java with this where it breaks)

maleghast15:11:40

So if I do a (declare ā€¦) at the top of my cljs file for all the things that I am going to need ā€œout of orderā€ then Iā€™ll have no more issues?

danm15:11:47

Shouldn't do

Rachel Westmacott15:11:54

you will still have issues, but hopefully not with that

Rachel Westmacott15:11:14

(ie. It wonā€™t cause an immediate impeachment)

danm15:11:23

Unless the reason you're declaring is because of functions which call each other, and you don't break out when you should and blow your stack šŸ˜‰

Rachel Westmacott15:11:23

if you havenā€™t blown the stack you havenā€™t lived

mccraigmccraig16:11:09

stacks are for losers, real wo|men use continuations

maleghast17:11:05

Does anyone know how to include a UTF-8 symbol in the string being passed into a Hiccup structure in Reagent? I want to use this down arrow code: &#11015;

maleghast17:11:43

Doing this:

[:td (str "&#11015; " (:percentage-shortfall chain) "% " "on expected supply")]

maleghast17:11:51

doesnā€™t work at allā€¦ šŸ˜ž

maleghast17:11:39

I want to throw a line-break in there as well, after the ā€œ%ā€ as well if at all possible - I already figured out that I canā€™t simply concatenate in ā€œ<br />ā€œā€¦ šŸ˜ž

mccraigmccraig17:11:26

@maleghast i think you can \u embed a unicode character directly in a string without using an entity

maleghast17:11:05

Thanks @mccraigmccraig - I will see if I can do that in my terminal Emacsā€¦

yogidevbear17:11:37

So out of interest sake, would anyone south of London consider going to a Clojure / FP meetup in Horsham? https://www.meetup.com/Horsham-Functional-Programming/

seancorfield18:11:46

(if it happens to be meeting next time I'm in the UK to visit family, I'd attend! šŸ™‚ )

yogidevbear18:11:24

Curious if @mccraigmccraig and his minions would venture this far north šŸ˜‰

mccraigmccraig18:11:04

maybe @yogidevbear, although i'm really bad at going to the brighton fp meetups and they are closer

mattford19:11:02

I wrote a command line tool and made a binary with lein-bin. Recently it has become necessary to stop the program with Ctrl-c - despite sending it's final output.

mattford19:11:18

It does exit eventually.

mattford19:11:32

Looking for pointers as to what to look for.

mattford19:11:46

I don't knowingly start any threads.

broquaint19:11:52

@mattford I canā€™t think of anything specific (although it does sound familiar), but you could look at the java stack between final output and exit to see whatā€™s going on though.

mattford19:11:53

@broquaint cheers I'll do that

broquaint19:11:56

Good luck šŸ™‚