Fork me on GitHub
#clojure-uk
<
2017-05-22
>
thomas07:05:47

wasn't Trump sniffing a lot during one of the first debates he had with HRC?

Rachel Westmacott07:05:36

yes, they commented on it all the way through the debates

agile_geek07:05:03

I'm trying to write a series of blogs on my approaches and personal experiences with software architecture over the last two decades...it's very much a work in progress and I have a long way to go to get to the detail and craft the message but I'd appreciate any retweets or comments/suggestions https://twitter.com/agile_geek/status/864055236435910657

agile_geek08:05:37

Given the delays I experience on "The Flying Scotsman - The Train" rather than "The Flying Scotsman - The Locomotive" I sometimes think Virgin Trains East Coast keep the train timetable secret! Well random anyway! http://www.bbc.co.uk/news/uk-england-gloucestershire-39991602

thomas08:05:35

@agile_geek I heard that it is used as the random number generator by GCHQ and the NSA 😝

mccraigmccraig08:05:43

train arrival time delta from timetable seems like a perfectly respectable source of entropy @thomas

thomas09:05:21

it has the most randomness

maleghast09:05:50

There is an academic paper for EVERYTHING

thomas09:05:43

weirdo Dutch people.... they must have been smoking something funny again

mccraigmccraig09:05:06

it would be awesome to see estimates of the parameters of that distribution for different countries and companies !

thomas09:05:55

the Swiss one would be interesting to be honest... all the trains run on time there.

thomas09:05:29

and I just had a quick look at the paper... they site two Phd thesis

maleghast09:05:33

@thomas Germany too, except for accidents on the network

mccraigmccraig09:05:22

in those cases it would also be interesting to include negative lateness - i.e. earliness at signal - to get an idea of how much overcapacity is being used to (almost) guarantee on-time at platform

mccraigmccraig09:05:05

then we could pit the germans against the swiss in a battle of efficiency

thomas09:05:06

There is a web site here in the NL where you can see what the cause was of the delay. last year 250 times a person was hit by a train.

thomas09:05:24

about 1 per working day.

mccraigmccraig09:05:19

i like that there are fewer delays on the weekend than in the week in NL @thomas

agile_geek09:05:28

Maybe fewer ppl get depressed at the weekend?

maleghast09:05:18

I was just going to pose that hypothesis

thomas09:05:48

not sure if that is actually the case.

thomas09:05:58

I stated that more as an average.

thomas09:05:07

but would be interesting to see.

thomas09:05:05

they have the data

agile_geek09:05:02

I've been delayed most often by signal issues, but been delayed a few times due to people hit by train (once by train I was on!) but I wonder if NL suffers from "delays caused by someone nicking 1km of copper signalling cable" which happened to me once!?

thomas10:05:54

I once was delayed earlier this year by person hit by train. not good. and it took a long time to resolve as well.

thomas10:05:10

must be really crap for train driver etc.

agile_geek10:05:11

I saw the driver of my train, he was escorted down the train to the back by two other employees (the guard and the relief driver) about an hour or so after the incident. He was white and shaking.

thomas11:05:55

😞 indeed. I have heard that if that happens the driver leaves the train regardless.

thomas11:05:44

same for the guard as they have to go out side and assess the situation.

Rachel Westmacott14:05:55

does anyone know if Clojure has any ability to tell if a form needs to be evaluated each time it is encountered or if it can be evaluated only once?

Rachel Westmacott14:05:34

my assumption is not, in which case, is there some cunning performance macro that can help?

mccraigmccraig14:05:10

are you looking for memoize @peterwestmacott ?

Rachel Westmacott14:05:49

…but at the expression level rather than the function level

Rachel Westmacott14:05:51

if I have a function that computes some stuff, and some of that stuff depends on the input, but some of it doesn’t, and all of it gets recalculated every time the function is called

Rachel Westmacott14:05:14

then I can extract the stuff that never changes to a (def ...)

bronsa14:05:18

can you give us an example

Rachel Westmacott14:05:00

contrived example:

(defn foo [a]
  (str (string/join ", " [1 2 3]) " and " a))

Rachel Westmacott14:05:11

the result of string/join will never vary

bronsa14:05:22

use a let over

Rachel Westmacott14:05:26

I could extract it to a def within the namespace

Rachel Westmacott14:05:34

will a let prevent re-evaluation on subsequent calls?

bronsa14:05:45

(let [s (s/join ..)] (defn foo [a] (str s ..)))

bronsa14:05:59

if you close over it, yes

Rachel Westmacott14:05:19

oic, put the function definition inside

Rachel Westmacott14:05:35

I heard non-top-level def/`defn` was bad

bronsa14:05:49

def-in-def is bad

bronsa14:05:00

(let [..] (def is perfectly fine

bronsa14:05:08

(that pattern is known as let over lambda)

Rachel Westmacott14:05:29

right, so why is def-in-def bad?

bronsa14:05:03

because it's a really bad pattern, and has some quirks

bronsa14:05:30

e.g.

(defn foo [a] (def x a))
x
what would you expect that to return?

Rachel Westmacott14:05:13

I would avoid expectations, and test it at the REPL?

Rachel Westmacott14:05:00

so I guess there’s no macro that says ‘compile this to a constant’

bronsa14:05:22

there isn't

reborg15:05:17

Isn't this a good case for (def ^:const s (clojure.string/join ", " [1 2 3])) ?