Fork me on GitHub
#clojure-uk
<
2018-08-07
>
dominicm07:08:37

morning ๐Ÿ˜ฎ

danielneal07:08:49

halloo there

agile_geek08:08:11

Bore da pawb welsh_flag

rhinocratic08:08:56

Everyone? I think - could well be wrong!

agile_geek09:08:04

Yep! Good morning everyone

yogidevbear09:08:54

\o (greet "everyone")

alexlynham09:08:23

(map #(str "Ahoy hoy " %) clojure-uk-pals) o/

๐Ÿ™‚ 4
guy09:08:38

Morning folks!

guy09:08:42

Noob question

guy09:08:03

(fn [& args] โ€ฆ ) can you do the args bit with #( )

3Jane09:08:04

turns out yes ๐Ÿ˜„

3Jane09:08:08

> %& for the rest of the arguments after the highest individually referenced argument

guy09:08:35

yeah! just saw it thanks @lady3janepl

3Jane09:08:13

(TIL for me, thanks for bringing it up!)

guy09:08:30

no worries me too

guy09:08:38

i was just doing some code golf

guy09:08:47

trying to reduce this horror

guy09:08:49

(fn[& x](fn[& a](map #(apply %1 a)x)))

guy09:08:07

but 4clojure doesnt allowed nested anon (or maybe its clojure dnno)

dominicm09:08:23

clojure doesn't allow nested anon

dominicm09:08:49

I would consider that a horror in and of itself. The call signature you're in seems whacky though.

dominicm09:08:58

4clj makes this worse due to how the tests work really.

guy09:08:06

just doing that one

guy09:08:29

i got to 33 for code golf, gimmie a shout if u give it ago ๐Ÿ˜‚

dominicm09:08:32

Makes perfect sense then ๐Ÿ™‚

3Jane09:08:56

I donโ€™t think anything allows nested anon

๐Ÿ‘ 8
alexlynham11:08:08

eyyyyyyy @conor.p.farrell welcome dude!

alexlynham11:08:34

finally more manchester clojure representation

dominicm11:08:43

imagine being in a programming community where you didn't know everyone by their first name? ๐Ÿ˜ฎ

๐Ÿ˜‚ 4
alexlynham11:08:11

makes me think we should have more cryptic user names more than anything else ๐Ÿ˜‰

dominicm11:08:22

I really just mean that it's not all bad that we're such a small group.

dominicm11:08:31

Socially it's pretty great.

guy11:08:13

๐Ÿ˜„

alexlynham12:08:41

this is a really friendly and helpful little corner of the internet imo

dominicm12:08:02

I agree ๐Ÿ™‚

jasonbell12:08:35

@dominicm Imagine a programming community that NEVER calls me by my first name ๐Ÿ™‚

agile_geek12:08:32

Canโ€™t imagine Jadeโ€ฆwhat would that feel like?

danielneal12:08:16

careful don't say his name 3 times or the spell will be broken

alexlynham12:08:12

welcome to the party

danielneal12:08:49

if someone offers you illegal parentheses please don't take them and report them to the correct authorities

alexlynham12:08:18

(conj clojure-uk-pals "Conor")

๐Ÿ‘€ 4
guy12:08:27

Clojure noob question 2.).

(defn reductions
  "Returns a lazy seq of the intermediate values of the reduction (as
  per reduce) of coll by f, starting with init."
  {:added "1.2"}
  ([f coll]
   (lazy-seq
    (if-let [s (seq coll)]
      (reductions f (first s) (rest s))
      (list (f)))))
  ([f init coll]
   (if (reduced? init)
     (list @init)
     (cons init
           (lazy-seq
            (when-let [s (seq coll)]
              (reductions f (f init (first s)) (rest s))))))))

What does (list @init) mean?

guy12:08:45

To me it looks like they are deref-ing init

bronsa12:08:15

that is indeed what's happening

bronsa12:08:22

init is a reduced

bronsa12:08:31

to get a value out of a reduced you deref it

bronsa12:08:43

user=> @(reduced 1)
1

danielneal12:08:46

a bit like an orange

danielneal12:08:31

no thats all

bronsa12:08:38

no you have to follow through now

bronsa12:08:51

you've committed

danielneal12:08:51

to get value out of an orange you deref it

guy12:08:52

How do you know its reduced sorry

bronsa13:08:05

you have to write a blog post about how reduceds are like oranges

bronsa13:08:17

@guy (if (reduced? init) :)

guy13:08:35

Sorry how does it become reduced might be a better way of phrasing

guy13:08:49

i think im not grokking how it works

bronsa13:08:53

f might return a reduced

danielneal13:08:18

reduced is a way of returning early with a value

bronsa13:08:22

(reductions (fn [acc el] (if (> el acc) (reduced acc) (+ el acc))) colls)

bronsa13:08:28

imagine this

bronsa13:08:45

that guard in reductions is testing against (f acc el) returning a reduced

bronsa13:08:34

if it does, it stops the reduction

guy13:08:56

:thinking_face:

bronsa13:08:11

by returning just (cons @init nil) instead of (cons init (rest of reductions))

guy13:08:27

(if (reduced? init) So this is more to do with the function passed into reductions rather then the function itself?

bronsa13:08:42

there's two parts to this

danielneal13:08:50

*like an orange

๐Ÿ™ˆ 4
๐Ÿงก 4
bronsa13:08:29

1- reductions needs to support early termination of f, by testing for reduced? on the accumulator 2- f can tell reductions to terminate the reduction early by returning a reduced value

bronsa13:08:43

so the bit in reductions is the "consumer" bit, the bit in f is the "producer"

bronsa13:08:09

it's a bit easier to understand this in terms of reduce than reductions

bronsa13:08:13

user=> (reduce (fn [acc el] (println el) (if (> el 3) (reduced acc) (+ acc el))) (range 10))
1 2 3 4
6

bronsa13:08:20

do you understand what reduced does in this example?

bronsa13:08:40

it tells reduce "ok, stop consuming the collection and performing the reduce operation, just return acc

guy13:08:00

when el is > than 3

bronsa13:08:18

for (el : coll) { 
   if el > 3 then
      break;
   else
     acc += el
}

bronsa13:08:23

in java it would be like this

danielneal13:08:55

it's a useful concept with transducers too - this blog post has some more about it https://dev.to/greencoder/build-your-own-transducer-and-impress-your-cat---part-4-2bp8

guy13:08:11

start at part 1?

guy13:08:13

or read that one

bronsa13:08:25

transducers compose backwards, start from the end :P

๐Ÿ˜‚ 8
parrot 4
๐Ÿ‘๏ธ 4
confusedparrot 4
danielneal13:08:25

well that one is relevant in terms of what reduced is

danielneal13:08:44

just as an aside

bronsa13:08:33

@guy that implementation of reductions is quite easy and compact, focus on the [f init coll] arity, drop the lazy-seq, play around with returning a reduced from f and then remove that reduced? check and see how it behaves

bronsa13:08:46

you'll get it in no time

guy13:08:54

oki doki ill give it ago! thanks

danielneal13:08:10

๐ŸŠ

๐Ÿ˜ฑ 4
3Jane14:08:21

All this talk of oranges and no one mentioned chocolate ๐Ÿ˜ž

alexlynham14:08:02

well we've not seen the blog post yet ๐Ÿ™‚

alexlynham14:08:19

or the whimsical talk at the conj

bronsa14:08:44

i'm sure @danieleneal was talking about this

dominicm14:08:28

now I'm hungry

dominicm14:08:34

chocolate orange is my favourite

3Jane14:08:49

Well we always knew that that healthy != tasty, and chocolate == tasty. Once we discovered that fruit == healthy, it was only a matter of time since someone invented a substitute.

guy14:08:52

I used to like chocolate oranges

guy14:08:01

Nowadays i dnno, iโ€™ve become a bit of a chocolate purist

danm14:08:11

I don't actually like chocolate

danm14:08:22

I just use it as a cream/sugar delivery mechanism

danm14:08:32

So by that reckoning, Dairy Milk is the best thing ever

dominicm14:08:08

@carr0t is there nothing else which satisfies that?

3Jane14:08:19

strawberries

dominicm14:08:57

@lady3janepl strawberries dipped in cream maybe, but I guess that's a difficult to carry pair?

3Jane14:08:10

@guy green & black?

guy14:08:56

nah 70% dark chocolate lindt :man-shrugging:

3Jane14:08:13

+ chilli and Iโ€™m sold

guy14:08:23

looool i just like plain haha

guy14:08:36

My all time fav is i think, paul a young?

guy14:08:38

let me google

guy14:08:05

http://www.paulayoung.co.uk/ That one, then they do this salted caramel chocolates

๐Ÿ˜‹ 4
dominicm15:08:08

are you going to get me into some niche expensive chocolate brand?

dominicm15:08:30

phew, they don't have a delivery tab, and I'm not in London ๐Ÿ˜‰

danielneal15:08:21

these are the bomb

dominicm15:08:25

> 10% OFF FIRST ORDER Well!

dominicm15:08:28

if that's the case!

minimal16:08:39

Pumpstreet Bakery chocolate is nice if you wanโ€™t to level up from Green and black

danm14:08:54

@dominicm Oh yeah, tons of stuff. Choc Orange, Toblerone, Dairy Milk. My point was more that actually nice chocolate often doesn't (because it's dark, or whatever)

danm14:08:55

My wife gets a monthly Hotel Chocolat box (delivered to my work these days, since the dog ate one that came to the house). I get most of the fruity/white/fondant ones, she gets all the darks/nutty ones

guy14:08:17

that seems like a good deal :thumbsup:

danm14:08:56

I especially get all the ones involving orange, as she's allergic

๐ŸŠ 8
๐Ÿงก 8
dominicm14:08:31

@carr0t Oh, I meant cream/sugar delivery, as opposed to chocolate ๐Ÿ˜„

danm14:08:44

Oh right ๐Ÿ˜† Well, yes, but they can be more work. And I like creamy, sugary milk chocolate

danm14:08:37

But I do sometimes just mix up icing sugar and melted butter and a little bit of peppermint essence in a mug, and eat it with a spoon. Basically peppermint cream mix

Conor15:08:29

You're some sort of mutant, Dan

danm15:08:36

And when I was in college I worked weekends in a bakery and used to have a pasty and a 1kg block of Regalice ready-to-roll icing for lunch. Somehow I am neither diabetic nor the size of a house, but that's more luck than judgement

danm15:08:00

And I tried it again back when I was about 22/23 and got a massive sugar crash headache. Not done it since

danielneal15:08:07

a 1kg block of icing

dominicm15:08:08

@carr0t I imagine raw cookie mix would suit your tastes, but drop the egg

danielneal15:08:34

and the jelly cubes before they are made into jelly

alexlynham15:08:37

1kg????!!!??

alexlynham15:08:45

damn danm

๐Ÿ˜‚ 8
danm15:08:04

Oh yeah. First dessert I learned to make was syrup sponge in the microwave. I used to make a double batch, eat half raw, cook the rest. That was when I was about 8

danm15:08:31

Also yes, jelly cubes are amazing. Though we don't normally have them in the house these days as we rarely eat jelly

danm15:08:04

@dominicm If it's anything like the chunks in Ben & Jerry's Cookie Dough Ice Cream, then yes. Best flavour

danm15:08:20

Also it being the UK, I would imagine we don't even have to drop the egg. Raw egg is fine over here. Not so much in the US. Don't know about the rest of the EU

dominicm15:08:42

@carr0t I always eat it, but I wasn't sure about the rules. Interesting that it's a US problem.

dominicm15:08:35

@carr0t seriously, 1g brown sugar, 2g soft butter and 3g flour (you can probably drop/reduce this, you're not making cookies). Mix in a bowl and scale this to your hearts desire and enjoy.

โค๏ธ 4
danm15:08:11

All eggs sold in the UK have to come from vaccinated chickens, cannot be washed (which to a certain extent requires the farmers to keep them in cleaner conditions, as noone want an egg covered in crap), and we keep them (in the supermarket) outside the fridge.

danm15:08:08

The US washes their eggs (which means they can be kept in dirtier conditions without people 'knowing', and also washes off the protective coating [egg bloom] and leaves them porous, which means they absorb contaminants more easily). They also don't mandate vaccination of their chickens. Those two combined means they have to keep their eggs in the fridge, even in the supermarket

minimal15:08:10

think just eggs with the lion mark come from vaccinated chickens

danm15:08:27

And their eggs are generally said to be unsafe to eat raw, whereas ours are OK

danm15:08:33

@minimal You could be right

danm15:08:47

> The Food Standards Agency says "Lion Mark" eggs, which include almost all of the eggs produced in the UK, are virtually free of salmonella. From https://www.bbc.co.uk/news/health-41568998

minimal15:08:58

but your point still stands in general

dominicm15:08:21

general impression seems to be that eggs prefer constant temperature. So shelf in supermarket, fridge (not in door) at home.

alexlynham16:08:14

we have eggs in a bowl in the shade

alexlynham16:08:17

never had a problem

alexlynham17:08:30

does anybody else think that:

alexlynham17:08:33

๐Ÿ’ช:face_with_raised_eyebrow:๐ŸŽ‰

alexlynham17:08:48

looks like the canonical emoji for serious party

sundarj18:08:57

:man_in_business_suit_levitating::skin-tone-3:๐Ÿ˜ฎ๐ŸŽ‰

sundarj18:08:02

i raise you that

mccraigmccraig18:08:24

@carr0t 1kg sugar = 4kcal... ~2 days of calories for lunch! how did you avoid becoming a diabetic house?

danm18:08:48

@mccraigmccraig I honestly donโ€™t know. Iโ€™m 6โ€™2โ€ (about 188cm), have been since I was 15/16. Until I was 18 I ate whatever I wanted and stayed about 10.5 stone (66-67kg). I was unhealthily thin. At Uni that went up a bit, but only to a more healthy weight. Then I got to 28 and suddenly it all appeared and I had to start watching what I eat (though the cycling helps)