Fork me on GitHub
#beginners
<
2016-10-04
>
josh_tackett01:10:39

is a do loop async?

lmergen13:10:37

hmmm, is it possible to combine :as with prefix lists to bind the “whole” prefix to a var? consider this:

[taoensso.timbre :as log]
[taoensso.timbre.profiling :refer [profile]]
how would i specify a prefix list to handle this ?

lmergen13:10:00

(ehr, for completeness sakes, this of course is about library imports)

dominicm13:10:10

@lmergen Just testing using :CCleanNS on a clj-time I already had in my project

dominicm13:10:17

[clj-time
 [core :as ctime]
 [periodic :refer [periodic-seq]]]

dominicm13:10:23

Ah, you want to know for more like clj-time.core.foo, I understand now

dominicm13:10:23

@lmergen yeah, nothing really wants to touch that. 😛

lmergen13:10:00

this was mostly just an annoyance

dominicm13:10:07

Ah, there's a good reason.

dominicm13:10:29

Within a prefix you cannot include a dot. So the logical nesting doesn't work.

lmergen13:10:30

i figured i could do something like

[clj-time :as ctime [periodic :refer [periodic-seq]]

dominicm13:10:53

I wouldn't worry about it too much - you won't spend much time looking at your ns declaration

dominicm13:10:16

Despite the "tidiness" of doing your namespaces in the nested form, they're significantly harder to grep for as well. So there's that.

lmergen13:10:30

you underestimate the amount of bikeshedding i can get myself into

dominicm13:10:50

You clearly don't know how much I do 😉

dominicm13:10:02

I'm going for a Yak Shaver of the year award

lmergen13:10:19

we should get a beer sometime and discuss meaningless things

dominicm13:10:04

@lmergen XT16? EuroClojure?

lmergen13:10:47

i wish i could be at XT16, but alas

pawel.kapala14:10:45

Hey. How do I “combine” (min) and (recur)? It keeps saying that I Can only recur from tail position...

dominicm14:10:01

@pawel.kapala you'll need to give us a bigger example I think.

dominicm14:10:24

But it seems like you're doing not doing (recur) in the final position as it's supposed to be used.

pawel.kapala15:10:36

yes I’m not doing it as a tail position, I’m aware of that, but I’m trying to find a solution for recursive function, that needs to calculate minimum of three recursive returns, something like that:

(if exit-condition exit-value
  (min
    (recur args)
    (recur different-args)
    (recur yet-another-args)))

dominicm15:10:07

Yep, that's the problem. My thoughts are to: Call back into the function in place of recur - this will blow up depending on how recursive your stack is, shouldn't be used for large values

dominicm15:10:06

In order to prevent overflowing the stack, you probably want a non-recursive version of the function, especially given that you're recur'ing multiple times, this prevents you from taking advantage of any form of TCO

pawel.kapala15:10:22

yeah it works without recur, but I’m trying to fix that to use TCO

dominicm15:10:17

I don't think you can get TCO unless in the tail position. But I never fully wrapped my head around that part of the SICP book.

dominicm15:10:29

Yeah ^^ That statement is true.

dominicm15:10:45

You can only get TCO if your function has "nothing left to do"

dominicm15:10:06

In this case, at (recur args) you still have 2 recurs and min to run.

pawel.kapala15:10:08

So this essentially means you wouldn’t be able (as in mathematically impossible) to use recursion multiple times and get TCO, right?

dominicm15:10:34

I believe so. That's my understanding.

pawel.kapala15:10:41

@dominicm thank you very much for your help, I’m gonna stick for non-recur version for now, and I’ll think about the algorithm itself to potentially eliminate multi-recursion. Thanks again!