Fork me on GitHub
#clojure-uk
<
2019-04-09
>
guy09:04:18

morning!

Ben Hammond09:04:02

n00b question; I was hoping that

(let [{:keys [channel throttle_value comms_count]
       :or {throttle_value 0 comms_count 0}
       :as row}
      {:id nil, :channel nil, :throttle_value nil, :comms_count nil}]
  [throttle_value comms_count])
would return [0 0] but it doesn't, it returns [nil nil]

Ben Hammond09:04:33

`(let [{:keys [channel throttle_value comms_count]
       :or {throttle_value 0 comms_count 0}
       :as row}
      nil]
  [throttle_value comms_count])
works as expected

Ben Hammond09:04:25

is there a way to get :or to substitute a default value for an existing but nil key

Ben Hammond09:04:48

(let [{:keys [channel throttle_value comms_count]
       :or {throttle_value 0 comms_count 0}
       :as row}
      {:this :that}]
  [throttle_value comms_count])

Ben Hammond09:04:13

works as expected; its specifically when you have a MapEntry that has a value off nil

Ben Hammond09:04:23

that there's a gotcha

guy09:04:10

I thought :or only works when the key doesn’t exist?

guy09:04:35

let me check the docs

Ben Hammond09:04:37

yeah, perhaps I'm just outside the pale

bronsa09:04:43

:or works with contains?

bronsa09:04:57

it's not for replacing nil values

bronsa09:04:03

use or manually for that :)

guy09:04:04

Associative destructuring, however, also allows you to supply a default value if the key is not present in the associative value with the :or key.

guy09:04:29

(def string-keys {"first-name" "Joe" "last-name" "Smith"})

(let [{:strs [first-name last-name]} string-keys]
  (println first-name last-name))
;= Joe Smith

guy09:04:37

Turns out reading the docs helps you learn new stuff

guy09:04:43

i never knew about :strs

Ben Hammond09:04:49

works with sym also

Ben Hammond09:04:21

there's a ton of stuff you are only gonna find out if you read the code

guy09:04:27

true true

Ben Hammond09:04:45

so I write something like

((fn [row]
   (let [throttle_value (or (:throttle_value row) 0)
         comms_count (or (:comms_count row) 0)]
     [throttle_value comms_count]))
 {:id nil, :channel nil, :throttle_value nil, :comms_count nil})
and get on with the rest of my life

guy09:04:50

the real question is why are you using snake case when kebab case is superior 👀

Ben Hammond11:04:41

oh its because this data map originates in Postgres

Ben Hammond11:04:55

which has some funny ideas about the minus-sign

Ben Hammond11:04:08

and I have another gripe about underscore-vs-minus-vs-:camelcase

Ben Hammond11:04:45

and libraries that 'helpfully' convert them

Ben Hammond11:04:50

when you least expect it

😅 4
Ben Hammond09:04:54

To Be Honest, the introduction of lower-case in the mid-80s was an enormous backward step IMHO

Ben Hammond09:04:13

CAPS IS JUST EASIER TO READ

😂 12
guy09:04:32

I AGREE THIS IS MUCH BETTER

Ben Hammond09:04:57

AND I NEVER, EVER WANT myvar, MyVar, MYVAR TO BE DIFFERENT THINGS

😂 12
parrot 8
jasonbell10:04:37

Well that escalated quickly.

agile_geek10:04:40

NO IT DIDN'T JADE!!!!!

jasonbell10:04:45

Wow, just wow 🙂

danielneal10:04:36

HELLO EVERYONE

guy10:04:14

👋 HELLO

3Jane11:04:16

welcome to #fortran-uk

3Jane11:04:35

wait, no, that doesn’t require ucase, does it?

agile_geek11:04:52

Ah ... Fortran wistful memories

agile_geek11:04:19

some later PC based variants didn't

agile_geek11:04:45

Anyway, the question would be Fortran IV or 77?

agile_geek11:04:11

Early BASIC implementations were in uppercase because, as Ben pointed out, that's all most machines had.

agile_geek11:04:18

I still haven't got over COBOL making the . optional in some later variants! Madness, chaos and anarchy!

otfrom12:04:11

we're hiring a data scientist but still getting the JD right. Any thoughts on the following?

guy12:04:30

I would say it reads really well, but you focus a lot on client communication but only mention it once in the who you are section. So at a glance my interpretation is the responsibilities are heavily client and communication focused, but then the requirements are strong data science skills with a little communication on the side. But tbh i think its a great JD. Mine was just a minor nit :thumbsup:

otfrom12:04:10

hmm... tricky. I think both are essential, but having the data science skills are what make it a data science job rather than a "public sector consultant" job. I'll have a think about that. thx 🙂

guy12:04:20

I think its just a minor thing really, you know the job best, but I think communication sounds like a really strong part of the job. 😄, either way it looks good

👍 4
rickmoynihan14:04:00

@otfrom: The Job Description reads really, really well to my eyes. Much, much better than almost everything I’ve seen. My only comment; which isn’t so much about the JD; is that I think you’re probably a much more interesting company to work for than the advert implies. So you could perhaps consider including something about the interesting nature of the work you do; beyond just the mechanics of it, i.e. something to make this applicant really want to work for you, above anyone else they’ve applied to… IIRC that prescriptions stuff you did was pretty groundbreaking at the time. If you don’t want to increase the word length then you could possibly just link to stuff that addresses that point.

otfrom14:04:56

@rickmoynihan thx. We do need to be better at blowing our own trumpet. 🙂

rickmoynihan14:04:58

Yeah, we’re pretty low key about that stuff too. It’s a tricky one to write in my book, as the kind of hyperbole you often see job ads is pretty grating - but it’s far too easy to find yourself writing out the standard cliches

otfrom14:04:36

I've added some links to the blog, case studies and our github

agile_geek07:04:53

I'm sorry, I take offence at the notion the prescription stuff you did was ground breaking. I wrote reports that analysed the exact same thing in 1992. OK most of it went to GPs and NHS professionals.

agile_geek07:04:35

Interestingly, the percentages around generics haven't changed too much in all that time!

rickmoynihan08:04:03

Well those were my words, not @otfrom’s who was steadfastly refusing to blow his own 🎺. As an impartial observer in all this, with no connection at all what I will say to defend the claim is something I learned from MIT’s entrepreneurship course which is that “Innovation is Invention + Marketing”, and that innovations are rarely original; and are almost always small increments on existing ideas; that come from an existing community zeitgeist… (Related Kuhn’s theory of scientific revolutoins.) More importantly, all hyperbole aside, it was a nice piece of work.

agile_geek11:04:18

I agree on all counts.... I was just being a little protective of some cool work I did when I was fairly junior but never got the credit or the wide spread publication it deserved. It was a batch COBOL system that printed reports on massive laser printers (in colour no less!) that were run by there own dedicated mainframe (separate from the m/f that ran the jobs to produce the data). We had to hand code the stuff to produce histograms as there weren't any libraries for it.

agile_geek11:04:15

We also wrote a fully interactive reporting system for the health authorities (in 1997) that enabled on line querying of prescribing data from practice level up to national level at any level of the BNF (individual drug/strength/volume/packaging up to the full BNF of all drugs). It was a home spun Java client server system that used applets in a browser to display the text and charts. Again all the charts were produced using our code to draw lines and bars as there were no libraries for that in Java. Effectively it was a bespoke reporting system that was also a bespoke Java application server. This was before servlets let alone JSP so all hand cranked mutli threaded stuff.

agile_geek11:04:32

Both those systems were only retired last year!

rickmoynihan12:04:19

Sounds really nice… I’ve definitely had the same feeling about some projects I’ve worked on which we’re pretty cutting edge at the time, but never widely known or appreciated… For example pitching, and building a bunch of mobile social networking J2ME apps to france telecom in 2001 (I’m sure we weren’t the only ones though), or my first production clojure project circa 2008 which did clinical trials recruitment, identifying eligible patients in GP practices, getting consent via the GP whilst they were in consultation… 80% of clinical trials are either substantially delayed or fail entirely because of recruitment problems, and every day a new drug is late to market is worth an estimated $800M… Sadly the startup folded due to an inadequate runway - despite having working technology deployed into maybe a dozen or more practices. The code was pretty cool too… a Clojure DSL/query language that mapped 1-1 to consort diagrams. We were targeting a GUI at the DSL so researchers could draw the diagram and it would generate a corresponding query. I think if that startup had been in silicon valley, we would have easily secured venture funding.

otfrom12:04:14

@U05390U2P I knew of your work after you told me before, so I don't see it as fundamentally groundbreaking, if anything was innovative, it was using the open data to create a story that was interesting to Economist/Independent/BBC/others that they should have seen in the same data, so the embarrassment should have been there really.

otfrom14:04:12

I should probably mention the 5% pension match and the profit related bonus as well

guy14:04:33

Yeah stick that under the salary part

guy14:04:56

Also :thinking_face: you’ve only got like 20ish days to apply for it?

guy14:04:21

seems pretty tight deadline wise haha

otfrom14:04:45

I'm going to extend that a bit, but I'd like to get people interviewing in mid-may really, so it will be a month from when it goes out.

👍 4
otfrom14:04:35

I also found this when looking around from Thayer Prime (who knows what she's on about and has an awesome name) https://looperinsights.com/careers/

alexlynham15:04:37

20% time, that’s how you can tell they’re serious

alexlynham15:04:50

isn’t that a starbase, not a person?

Ben Hammond15:04:10

if she's `Interim' Hiring Director, does that mean she's still on probabation?

Ben Hammond15:04:39

or is looking out for own replacement

Ben Hammond15:04:22

or should Interim bind to 'People' rather than 'Director'?

guy15:04:56

Interim Ben Hammond

guy15:04:00

:thinking_face:

guy15:04:11

feels like it should be on job rather than person

Ben Hammond15:04:17

well I'm in the process of becoming something else

guy15:04:06

I would argue thats your norm rather than your Interim though.

guy15:04:14

:face_with_monocle:

Ben Hammond15:04:43

so does she hire temps? or is she a temp?

Ben Hammond15:04:18

(what does the monocle represent?)

alexlynham15:04:35

a person is required constantly but might not be available

alexlynham15:04:44

hence interregnum

alexlynham15:04:17

sorry interrex

otfrom15:04:32

she's there while they look for someone permanent

otfrom15:04:38

Thayer knows what she's on about

Ben Hammond16:04:24

wonders: how are those two facts correlated? :thinking_face: :suspicious-narrowed-eyes:

otfrom16:04:39

she's got her own thing but was helping out some friends

😁 4
otfrom16:04:24

I'm sure she's got some nefarious plan though that we should be suspicious of. I think you are right. :thinking_face:

Ben Hammond16:04:49

there's definitely an emoji missing from the emoji pallette

Conor16:04:32

Clearly Thayer Prime is the derivative of Thayer

Ben Hammond16:04:26

with-respect-to-why?

otfrom16:04:15

anyway, she's good and she has an awesome name and I'm feeling a little uncomfortable about the amount of teasing even tho it is good natured