Fork me on GitHub

When you use a map instead of positional arguments, do you namespace the keys and which namespace? Say the function is called from another namespace


@benjamin.schwerdtner I think it's pretty rare to see qualified keys for named arguments mostly because the context is very narrow -- just the call site (well, and the definition site) -- so there's no change of collision, so unqualified keys are fine.

👍 1

a question about with-precision which sets the precision and rounding mode for bigdec calculations. If I do a lazy operation like map:

(with-precision 10 (map #(/ % 3) (map bigdec (range 100))))
will the with-precision apply even though the clause is exited and the lazy sequence realized later on outside the with-precision context


ah…assuming no as I get an ArithmeticException…so I would need to litter the code with with-precision calls in the “leaves of the calculation”, i.e. #(with-precision 10 (/ % 3))


any way to make this global and not litter the code?

Martin Půda19:02:33

I guess you will get Exception because REPL is trying to print that list- so maybe do all your calculations inside with-precision block?

Martin Půda19:02:47

(with-precision 10
  (->> (range 10)
       (map bigdec)
       (map #(/ % 3))
(0M 0.3333333333M 0.6666666667M 1M 1.333333333M 1.666666667M 2M 2.333333333M 2.666666667M 3M)
=> nil


yeah problem is when there is no println inside the with-precision and that lazy sequence is returned to some other part of the program which is not inside a with-precision block and the lazy sequence is realized there



  (with-precision 10
    (->> (range 10)
         (map bigdec)
         (map #(/ % 3)))))
Execution error (ArithmeticException) at java.math.BigDecimal/divide (
Non-terminating decimal expansion; no exact representable decimal result.

Martin Půda20:02:10

Did you consider using ratios and rationalize ?


it seems to me from random fiddling that rationals get very slow when dealing with larger data sets


also rationals become quite unreadable as intermediate values (i.e. 453234/2343)…not a hard issue, but doesn’t improve the ergonomics either


the numbers in question represent monetary values so I figured bigdec was the way


did not know about rationalize though…thanks for that one, adding it to my bag of tricks


I do not know if this will work globally, but have you tried doing something like this?

(set! *math-context* <some-desired-value>)


All that with-precision is doing is creating a dynamic binding of *math-context* to a desired value, which of course has the run-time behavior of restoring its original value when the execution leaves the binding form. Perhaps doing set! can assign it a value globally.


aha…off my repl right now but that does sound like an option

Rob Haisfield21:02:16

I’m interested in practice problems for domain modeling in data and suggested solutions so I can strengthen my mental models around it. Anyone know good examples? I figure if Clojure is geared towards data-oriented programming, then I should get really good at domain modeling with data and then a bunch of other stuff should fall into place!;t=92ruKcRCY45l406OKYlTMQ


Your thesis rings true with me. can help your search

Drew Verlee03:02:07

I learned a lot from the book "building data intensive applications" as watching videos by Michael drogalis. My impression is that data modeling is the art of synchronizing the business need with technology. E.g picking the right data base is a function of the business need and in a way, vise versa.