Fork me on GitHub
#clojure-uk
<
2018-03-14
>
thomas08:03:36

moin moin morning

yogidevbear14:03:06

Curiosity got the better of me. Seeing some discussion which mentioned the FIZZBUZZ example so wrote it out quickly using map and was curious how others here might tackle the solution differently?

(map
  #(cond
    (= 0 (mod % 3) (mod % 5)) "FIZZBUZZ"
    (= 0 (mod % 3)) "FIZZ"
    (= 0 (mod % 5)) "BUZZ"
    :else %)
  (range 1 101))

danielneal14:03:26

Think that's how I'd do it too 🙂

sundarj14:03:32

i would use condp but yeah same thing

Rachel Westmacott14:03:22

I might use zero? - but it’s pretty readable thumbsup_all

sundarj14:03:12

it's a little unfortunate that condp only works for binary predicates

Rachel Westmacott14:03:15

It slightly irks me that you might have to calculate (mod % [3|5]) more than once…

thanos19:03:47

(def mmod (memoize mod)) ? 😄

maleghast14:03:41

'Ello everyone 🙂

yogidevbear16:03:14

Another FP meetup in Horsham for anyone that might be able to make it (looking at you @mccraigmccraig😉) https://www.meetup.com/Horsham-Functional-Programming/events/248732589/

mccraigmccraig16:03:48

added to my diary @yogidevbear... not sure if i can yet - my calendar is subject to concurrent modifications and rollbacks